summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sysinstall
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1999-07-16 11:13:09 +0000
committerjkh <jkh@FreeBSD.org>1999-07-16 11:13:09 +0000
commit62771172f4e1b703f46fbece196e1c900c35dd79 (patch)
tree85fa8dd97edf88f579dd64c9af0b98050ce011ac /usr.sbin/sysinstall
parent62a15a73f51b97c0ffc57c2da9aaa25cffb8cc07 (diff)
downloadFreeBSD-src-62771172f4e1b703f46fbece196e1c900c35dd79.zip
FreeBSD-src-62771172f4e1b703f46fbece196e1c900c35dd79.tar.gz
Re-enable DHCP client support again (but optional and turned off by default
for the time being) for debugging purposes. Fix bug in options selection.
Diffstat (limited to 'usr.sbin/sysinstall')
-rw-r--r--usr.sbin/sysinstall/install.c5
-rw-r--r--usr.sbin/sysinstall/options.c16
-rw-r--r--usr.sbin/sysinstall/sysinstall.h3
-rw-r--r--usr.sbin/sysinstall/tcpip.c71
-rw-r--r--usr.sbin/sysinstall/variable.c7
5 files changed, 80 insertions, 22 deletions
diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c
index 2ba3aa8..17ff049 100644
--- a/usr.sbin/sysinstall/install.c
+++ b/usr.sbin/sysinstall/install.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: install.c,v 1.239 1999/07/06 08:45:36 jkh Exp $
+ * $Id: install.c,v 1.240 1999/07/06 09:19:35 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -1031,6 +1031,7 @@ installVarDefaults(dialogMenuItem *self)
variable_set2(VAR_TAPE_BLOCKSIZE, DEFAULT_TAPE_BLOCKSIZE, 0);
variable_set2(VAR_INSTALL_ROOT, "/", 0);
variable_set2(VAR_INSTALL_CFG, "install.cfg", 0);
+ variable_set2(VAR_TRY_DHCP, "NO", 0); /* For now */
cp = getenv("EDITOR");
if (!cp)
cp = "/usr/bin/ee";
@@ -1039,7 +1040,7 @@ installVarDefaults(dialogMenuItem *self)
variable_set2(VAR_BROWSER_PACKAGE, "lynx", 0);
variable_set2(VAR_BROWSER_BINARY, "/usr/local/bin/lynx", 0);
variable_set2(VAR_FTP_STATE, "passive", 0);
- variable_set2(VAR_NFS_SECURE, "YES", 0);
+ variable_set2(VAR_NFS_SECURE, "NO", -1);
variable_set2(VAR_PKG_TMPDIR, "/usr/tmp", 0);
variable_set2(VAR_MEDIA_TIMEOUT, itoa(MEDIA_TIMEOUT), 0);
if (getpid() != 1)
diff --git a/usr.sbin/sysinstall/options.c b/usr.sbin/sysinstall/options.c
index 59b5727..f8f7de9 100644
--- a/usr.sbin/sysinstall/options.c
+++ b/usr.sbin/sysinstall/options.c
@@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated for what's essentially a complete rewrite.
*
- * $Id: options.c,v 1.59 1999/04/27 14:33:28 jkh Exp $
+ * $Id: options.c,v 1.60 1999/05/07 11:02:57 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -113,6 +113,8 @@ static Option Options[] = {
OPT_IS_VAR, NULL, VAR_NO_WARN, varCheck },
{ "Yes to All", "Assume \"Yes\" answers to all non-critical dialogs",
OPT_IS_VAR, NULL, VAR_NO_CONFIRM, varCheck },
+{ "DHCP", "Attempt automatic DHCP configuration of interfaces",
+ OPT_IS_VAR, NULL, VAR_TRY_DHCP, varCheck },
{ "FTP username", "Username and password to use instead of anonymous",
OPT_IS_FUNC, mediaSetFTPUserPass, VAR_FTP_USER, varCheck },
{ "Editor", "Which text editor to use during installation",
@@ -187,13 +189,17 @@ fire(Option opt)
}
else if (opt.type == OPT_IS_VAR) {
if (opt.data) {
- (void)variable_get_value(opt.aux, opt.data, 1);
+ (void)variable_get_value(opt.aux, opt.data, -1);
status = 1;
}
- else if (variable_get(opt.aux))
- variable_unset(opt.aux);
+ else if (variable_get(opt.aux)) {
+ if (!variable_cmp(opt.aux, "YES"))
+ variable_set2(opt.aux, "NO", -1);
+ else
+ variable_set2(opt.aux, "YES", -1);
+ }
else
- variable_set2(opt.aux, "YES", 1);
+ variable_set2(opt.aux, "YES", 0);
}
if (opt.check)
opt.check(opt);
diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h
index c907586..02e44dd 100644
--- a/usr.sbin/sysinstall/sysinstall.h
+++ b/usr.sbin/sysinstall/sysinstall.h
@@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
- * $Id: sysinstall.h,v 1.167 1999/07/02 22:36:14 jkh Exp $
+ * $Id: sysinstall.h,v 1.168 1999/07/06 08:45:40 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -157,6 +157,7 @@
#define VAR_SLOW_ETHER "slowEthernetCard"
#define VAR_SWAP_SIZE "swapSize"
#define VAR_TAPE_BLOCKSIZE "tapeBlocksize"
+#define VAR_TRY_DHCP "tryDHCP"
#define VAR_UFS_PATH "ufs"
#define VAR_USR_SIZE "usrSize"
#define VAR_VAR_SIZE "varSize"
diff --git a/usr.sbin/sysinstall/tcpip.c b/usr.sbin/sysinstall/tcpip.c
index 8ccd6e8..269ab3e 100644
--- a/usr.sbin/sysinstall/tcpip.c
+++ b/usr.sbin/sysinstall/tcpip.c
@@ -1,5 +1,5 @@
/*
- * $Id: tcpip.c,v 1.78 1999/05/07 05:15:17 jkh Exp $
+ * $Id: tcpip.c,v 1.79 1999/05/07 11:45:26 jkh Exp $
*
* Copyright (c) 1995
* Gary J Palmer. All rights reserved.
@@ -153,6 +153,7 @@ tcpOpenDialog(Device *devp)
ComposeObj *obj = NULL;
int n = 0, filled = 0, cancel = FALSE;
int max, ret = DITEM_SUCCESS;
+ int use_dhcp = 0;
char *tmp;
char title[80];
@@ -167,17 +168,60 @@ tcpOpenDialog(Device *devp)
else { /* See if there are any defaults */
char *cp;
-#ifdef notdef /* This is just a test stub which doesn't work yet either */
- /* First try a DHCP scan */
- msgNotify("Scanning for DHCP servers...");
- Mkdir("/var/db");
- vsystem("ifconfig %s inet 0.0.0.0 netmask 0.0.0.0 broadcast 255.255.255.255 up", devp->name);
- if (!vsystem("dhclient")) {
- msgConfirm("Successful return from dhclient");
+ /* First try a DHCP scan if such behavior is desired */
+ if (!variable_cmp(VAR_TRY_DHCP, "YES")) {
+ Mkdir("/var/db");
+ Mkdir("/var/run");
+ msgNotify("Scanning for DHCP servers...");
+ vsystem("ifconfig %s inet 0.0.0.0 netmask 0.0.0.0 broadcast 255.255.255.255 up", devp->name);
+ if (!vsystem("dhclient")) {
+ FILE *ifp;
+ char cmd[256];
+
+ if (isDebug())
+ msgConfirm("Successful return from dhclient");
+ snprintf(cmd, sizeof cmd, "ifconfig %s", devp->name);
+ ifp = popen(cmd, "r");
+ if (ifp) {
+ char *cp, data[1024];
+ int i = 0, j = 0;
+
+ while ((j = fread(data + i, 1, 512, ifp)) > 0)
+ i += j;
+ fclose(ifp);
+ data[i] = 0;
+ if (isDebug())
+ msgDebug("DHCP configured interface returns %s\n", data);
+ /* XXX This is gross as it assumes a certain ordering to
+ ifconfig's output! XXX */
+ if ((cp = strstr(data, "inet")) != NULL) {
+ i = 0;
+ cp += 5; /* move over keyword */
+ while (*cp != ' ')
+ ipaddr[i++] = *(cp++);
+ ipaddr[i] = '\0';
+ if (!strncmp(++cp, "netmask", 7)) {
+ i = 0;
+ cp += 8;
+ while (*cp != ' ')
+ netmask[i++] = *(cp++);
+ netmask[i] = '\0';
+ }
+ if (file_readable("/etc/resolv.conf"))
+ configEnvironmentResolv("/etc/resolv.conf");
+ /* See if we have a hostname */
+ if (!gethostname(data, sizeof data - 1) && data[0])
+ variable_set2(VAR_HOSTNAME, data, 1);
+ use_dhcp = TRUE;
+ }
+ }
+ }
+ else {
+ if (isDebug())
+ msgConfirm("Unsuccessful return from dhclient");
+ use_dhcp = FALSE;
+ }
}
- else
- msgConfirm("Unsuccessful return from dhclient");
-#endif
/* Get old IP address from variable space, if available */
if (!ipaddr[0]) {
@@ -321,8 +365,11 @@ netconfig:
SAFE_STRCPY(di->netmask, netmask);
SAFE_STRCPY(di->extras, extras);
- sprintf(temp, "inet %s %s netmask %s", ipaddr, extras, netmask);
sprintf(ifn, "%s%s", VAR_IFCONFIG, devp->name);
+ if (use_dhcp)
+ sprintf(temp, "DHCP");
+ else
+ sprintf(temp, "inet %s %s netmask %s", ipaddr, extras, netmask);
variable_set2(ifn, temp, 1);
ifaces = variable_get(VAR_INTERFACES);
if (!ifaces)
diff --git a/usr.sbin/sysinstall/variable.c b/usr.sbin/sysinstall/variable.c
index ab39a47..8cbf433 100644
--- a/usr.sbin/sysinstall/variable.c
+++ b/usr.sbin/sysinstall/variable.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: variable.c,v 1.24 1998/07/18 09:42:02 jkh Exp $
+ * $Id: variable.c,v 1.25 1999/02/05 22:15:52 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -58,7 +58,8 @@ make_variable(char *var, char *value, int dirty)
setenv(var, value, 1);
free(vp->value);
vp->value = strdup(value);
- vp->dirty = dirty;
+ if (dirty != -1)
+ vp->dirty = dirty;
return;
}
}
@@ -68,6 +69,8 @@ make_variable(char *var, char *value, int dirty)
vp = (Variable *)safe_malloc(sizeof(Variable));
vp->name = strdup(var);
vp->value = strdup(value);
+ if (dirty == -1)
+ dirty = 0;
vp->dirty = dirty;
vp->next = VarHead;
VarHead = vp;
OpenPOWER on IntegriCloud