Sun Sep 23 17:37:51 2012 UTC ()
Prevent sysinst from setting an fqdn in rc.conf when the user entered no domain
(i.e., sets only the hostname).  Fix for PR install/46946.


(jdf)
diff -r1.132 -r1.133 src/distrib/utils/sysinst/net.c

cvs diff -r1.132 -r1.133 src/distrib/utils/sysinst/Attic/net.c (expand / switch to unified diff)

--- src/distrib/utils/sysinst/Attic/net.c 2012/05/01 18:28:47 1.132
+++ src/distrib/utils/sysinst/Attic/net.c 2012/09/23 17:37:51 1.133
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: net.c,v 1.132 2012/05/01 18:28:47 riz Exp $ */ 1/* $NetBSD: net.c,v 1.133 2012/09/23 17:37:51 jdf Exp $ */
2 2
3/* 3/*
4 * Copyright 1997 Piermont Information Systems Inc. 4 * Copyright 1997 Piermont Information Systems Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Philip A. Nelson for Piermont Information Systems Inc. 7 * Written by Philip A. Nelson for Piermont Information Systems Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -425,29 +425,29 @@ get_host_info(void) @@ -425,29 +425,29 @@ get_host_info(void)
425 425
426/* 426/*
427 * recombine name parts split in get_host_info and config_network 427 * recombine name parts split in get_host_info and config_network
428 * (common code moved here from write_etc_hosts) 428 * (common code moved here from write_etc_hosts)
429 */ 429 */
430static char * 430static char *
431recombine_host_domain(void) 431recombine_host_domain(void)
432{ 432{
433 static char recombined[MAXHOSTNAMELEN + 1]; 433 static char recombined[MAXHOSTNAMELEN + 1];
434 int l = strlen(net_host) - strlen(net_domain); 434 int l = strlen(net_host) - strlen(net_domain);
435 435
436 strlcpy(recombined, net_host, sizeof(recombined)); 436 strlcpy(recombined, net_host, sizeof(recombined));
437 437
438 if (l <= 0 || 438 if (strlen(net_domain) != 0 && (l <= 0 ||
439 net_host[l - 1] != '.' || 439 net_host[l - 1] != '.' ||
440 strcasecmp(net_domain, net_host + l) != 0) { 440 strcasecmp(net_domain, net_host + l) != 0)) {
441 /* net_host isn't an FQDN. */ 441 /* net_host isn't an FQDN. */
442 strlcat(recombined, ".", sizeof(recombined)); 442 strlcat(recombined, ".", sizeof(recombined));
443 strlcat(recombined, net_domain, sizeof(recombined)); 443 strlcat(recombined, net_domain, sizeof(recombined));
444 } 444 }
445 return recombined; 445 return recombined;
446} 446}
447 447
448#ifdef INET6 448#ifdef INET6
449static int 449static int
450is_v6kernel(void) 450is_v6kernel(void)
451{ 451{
452 int s; 452 int s;
453 453