From f865c8d9dbf5459d27a197b69d26a5da26320c8f Mon Sep 17 00:00:00 2001 From: delphij Date: Sun, 12 Feb 2006 15:23:50 +0000 Subject: [PATCH] MFC a set of changes that fixes DHCP handling in sysinstall(8) * network.c,v 1.53 (by ceri): Fixes DHCP handling to use a more robust way to determine whether DHCP should be used. * tcpip.c,v 1.134: Avoid adding unnecessary tailing space when no media option(s) is specified. Approved by: re (scottl) --- usr.sbin/sysinstall/network.c | 10 ++++++++-- usr.sbin/sysinstall/tcpip.c | 9 ++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/usr.sbin/sysinstall/network.c b/usr.sbin/sysinstall/network.c index c57ad3de90a..92c6e356a3e 100644 --- a/usr.sbin/sysinstall/network.c +++ b/usr.sbin/sysinstall/network.c @@ -126,8 +126,12 @@ mediaInitNetwork(Device *dev) snprintf(ifconfig, 255, "%s%s", VAR_IFCONFIG, dev->name); cp = variable_get(ifconfig); if (cp) { - if (strcmp(cp, "DHCP")) { - msgDebug("ifconfig %s %s\n", dev->name, cp); + /* + * If this interface isn't a DHCP one, bring it up. + * If it is, then it's already up. + */ + if (strstr(cp, "DHCP") == NULL) { + msgDebug("Not a DHCP interface.\n"); i = vsystem("ifconfig %s %s", dev->name, cp); if (i) { msgConfirm("Unable to configure the %s interface!\n" @@ -144,6 +148,8 @@ mediaInitNetwork(Device *dev) msgDebug("Adding default route to %s.\n", rp); vsystem("route -n add default %s", rp); } + } else { + msgDebug("A DHCP interface. Should already be up.\n"); } } else if ((cp = variable_get(VAR_IPV6ADDR)) == NULL || *cp == '\0') { msgConfirm("The %s device is not configured. You will need to do so\n" diff --git a/usr.sbin/sysinstall/tcpip.c b/usr.sbin/sysinstall/tcpip.c index 10c9c2c9a31..6c21226f764 100644 --- a/usr.sbin/sysinstall/tcpip.c +++ b/usr.sbin/sysinstall/tcpip.c @@ -596,9 +596,12 @@ tcpOpenDialog(Device *devp) ipv4_enable = TRUE; if (ipv4_enable) { sprintf(ifn, "%s%s", VAR_IFCONFIG, devp->name); - if (use_dhcp) - sprintf(temp, "DHCP %s", extras); - else + if (use_dhcp) { + if (strlen(extras) > 0) + sprintf(temp, "DHCP %s", extras); + else + sprintf(temp, "DHCP"); + } else sprintf(temp, "inet %s %s netmask %s", ipaddr, extras, netmask); variable_set2(ifn, temp, 1); -- 2.45.2