Module Name:    src
Committed By:   jmcneill
Date:           Sun May 15 17:42:32 UTC 2022

Modified Files:
        src/usr.sbin/sysinst: net.c

Log Message:
sysinst: Write custom hostname to rc.conf when using DHCP

If the user changes the suggested hostname from DHCP, ensure that the
new hostname is written to rc.conf by clearing the appropriate
DHCPCONF_* flags.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/sysinst/net.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sysinst/net.c
diff -u src/usr.sbin/sysinst/net.c:1.41 src/usr.sbin/sysinst/net.c:1.42
--- src/usr.sbin/sysinst/net.c:1.41	Sun May 15 17:02:37 2022
+++ src/usr.sbin/sysinst/net.c	Sun May 15 17:42:32 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: net.c,v 1.41 2022/05/15 17:02:37 jmcneill Exp $	*/
+/*	$NetBSD: net.c,v 1.42 2022/05/15 17:42:32 jmcneill Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -493,6 +493,7 @@ config_network(void)
  	int  pid, status;
  	char **ap, *slcmd[10], *in_buf;
  	char buffer[STRSIZE];
+	char hostname[MAXHOSTNAMELEN + 1];
  	struct statvfs sb;
 	struct net_desc net_devs[MAX_NETS];
 	menu_ent *net_menu;
@@ -657,10 +658,14 @@ again:
 	 * discovered on the network may not match the desired values
 	 * for the target system.
 	 */ 
+	strlcpy(hostname, recombine_host_domain(), MAXHOSTNAMELEN);
 	msg_prompt_add(MSG_net_host, net_host, net_host,
 	    sizeof net_host);
 	msg_prompt_add(MSG_net_domain, net_domain, net_domain,
 	    sizeof net_domain);
+	if (strcmp(hostname, recombine_host_domain()) != 0) {
+		net_dhcpconf &= ~(DHCPCONF_DOMAIN|DHCPCONF_HOST);
+	}
 
 	if (!dhcp_config) {
 		/* Manually configure IPv4 */

Reply via email to