diff options
author | jkh <jkh@FreeBSD.org> | 1995-05-26 20:45:20 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1995-05-26 20:45:20 +0000 |
commit | 2c1aa198eb5de34b73c883882ddee0739fd5f447 (patch) | |
tree | fc57a9165a12e93458ba530ae017299f96ef8665 /usr.sbin/sade | |
parent | 9a596693ad74d8bcb1b6c3764f0be96f1198f0ac (diff) | |
download | FreeBSD-src-2c1aa198eb5de34b73c883882ddee0739fd5f447.zip FreeBSD-src-2c1aa198eb5de34b73c883882ddee0739fd5f447.tar.gz |
Clean up the variable handling code a little.
Write /etc/hosts in the right place.
Diffstat (limited to 'usr.sbin/sade')
-rw-r--r-- | usr.sbin/sade/config.c | 7 | ||||
-rw-r--r-- | usr.sbin/sade/install.c | 10 | ||||
-rw-r--r-- | usr.sbin/sade/variable.c | 37 |
3 files changed, 29 insertions, 25 deletions
diff --git a/usr.sbin/sade/config.c b/usr.sbin/sade/config.c index a9a6637..83eb98b 100644 --- a/usr.sbin/sade/config.c +++ b/usr.sbin/sade/config.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: config.c,v 1.7 1995/05/26 08:41:35 jkh Exp $ + * $Id: config.c,v 1.8 1995/05/26 19:28:00 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -311,11 +311,6 @@ configResolv(void) fprintf(fp, "nameserver\t%s\n", getenv(VAR_NAMESERVER)); msgNotify("Wrote /etc/resolv.conf"); fclose(fp); - if (getenv(VAR_IPADDR)) { - fp = fopen("/etc/hosts", "a"); - fprintf(fp, "%s\t\t%s\n", getenv(VAR_IPADDR), getenv(VAR_HOSTNAME)); - fclose(fp); - } alreadyDone = TRUE; } diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c index fad31d7..6d6f86d 100644 --- a/usr.sbin/sade/install.c +++ b/usr.sbin/sade/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.58 1995/05/26 10:20:46 jkh Exp $ + * $Id: install.c,v 1.59 1995/05/26 10:32:28 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -220,12 +220,20 @@ static void installFinal(void) { static Boolean alreadyDone = FALSE; + FILE *fp; if (alreadyDone) return; configFstab(); configSysconfig(); configResolv(); + + /* Tack ourselves at the end of /etc/hosts */ + if (getenv(VAR_IPADDR)) { + fp = fopen("/etc/hosts", "a"); + fprintf(fp, "%s\t\t%s\n", getenv(VAR_IPADDR), getenv(VAR_HOSTNAME)); + fclose(fp); + } alreadyDone = TRUE; msgConfirm("Installation completed successfully.\nHit return now to go back to the main menu."); SystemWasInstalled = TRUE; diff --git a/usr.sbin/sade/variable.c b/usr.sbin/sade/variable.c index 993828c..ec3c5b1 100644 --- a/usr.sbin/sade/variable.c +++ b/usr.sbin/sade/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.1 1995/05/01 21:56:32 jkh Exp $ + * $Id: variable.c,v 1.2 1995/05/20 10:33:13 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -45,19 +45,15 @@ /* Routines for dealing with variable lists */ -void -variable_set(char *var) +static void +make_variable(char *var, char *value) { - char tmp[VAR_NAME_MAX + VAR_VALUE_MAX], *cp; Variable *newvar; + setenv(var, value, 1); newvar = (Variable *)safe_malloc(sizeof(Variable)); - strncpy(tmp, var, VAR_NAME_MAX + VAR_VALUE_MAX); - if ((cp = index(tmp, '=')) == NULL) - msgFatal("Invalid variable format: %s", var); - *cp = '\0'; - strncpy(newvar->name, tmp, VAR_NAME_MAX); - strncpy(newvar->value, cp + 1, VAR_VALUE_MAX); + strncpy(newvar->name, var, VAR_NAME_MAX); + strncpy(newvar->value, value, VAR_VALUE_MAX); newvar->next = VarHead; VarHead = newvar; setenv(newvar->name, newvar->value, 1); @@ -65,18 +61,23 @@ variable_set(char *var) } void +variable_set(char *var) +{ + char tmp[VAR_NAME_MAX + VAR_VALUE_MAX], *cp; + + strncpy(tmp, var, VAR_NAME_MAX + VAR_VALUE_MAX); + if ((cp = index(tmp, '=')) == NULL) + msgFatal("Invalid variable format: %s", var); + *(cp++) = '\0'; + make_variable(tmp, cp); +} + +void variable_set2(char *var, char *value) { Variable *newvar; if (!var || !value) msgFatal("Null name or value passed to set_variable2!"); - setenv(var, value, 1); - newvar = (Variable *)safe_malloc(sizeof(Variable)); - strncpy(newvar->name, var, VAR_NAME_MAX); - strncpy(newvar->value, value, VAR_VALUE_MAX); - newvar->next = VarHead; - VarHead = newvar; - setenv(newvar->name, newvar->value, 1); - msgInfo("Set %s to %s", newvar->name, newvar->value); + make_variable(var, value); } |