diff options
-rw-r--r-- | release/sysinstall/config.c | 18 | ||||
-rw-r--r-- | usr.sbin/sade/config.c | 18 | ||||
-rw-r--r-- | usr.sbin/sysinstall/config.c | 18 |
3 files changed, 36 insertions, 18 deletions
diff --git a/release/sysinstall/config.c b/release/sysinstall/config.c index 31dba62..2ef56a2 100644 --- a/release/sysinstall/config.c +++ b/release/sysinstall/config.c @@ -376,25 +376,31 @@ configSysconfig(char *config) fp = fopen(config, "w"); } for (i = 0; i < nlines; i++) { - static Boolean firstTime = TRUE; - fprintf(fp, lines[i]); /* Stand by for bogus special case handling - we try to dump the interface specs here */ - if (firstTime && !strncmp(lines[i], VAR_INTERFACES, strlen(VAR_INTERFACES))) { + if (!strncmp(lines[i], VAR_INTERFACES, strlen(VAR_INTERFACES))) { Device **devp; int j, cnt; devp = deviceFind(NULL, DEVICE_TYPE_NETWORK); cnt = deviceCount(devp); for (j = 0; j < cnt; j++) { - char iname[255]; + char iname[255], toadd[512]; + int k, addit = TRUE; snprintf(iname, 255, "%s%s", VAR_IFCONFIG, devp[j]->name); if ((cp = variable_get(iname))) { - fprintf(fp, "%s=\"%s\"\n", iname, cp); + snprintf(toadd, sizeof toadd, "%s=\"%s\"\n", iname, cp); + for (k = 0; k < nlines; k++) { + if (!strcmp(lines[k], toadd)) { + addit = FALSE; + break; + } + } + if (addit) + fprintf(fp, toadd); } } - firstTime = FALSE; } free(lines[i]); } diff --git a/usr.sbin/sade/config.c b/usr.sbin/sade/config.c index 31dba62..2ef56a2 100644 --- a/usr.sbin/sade/config.c +++ b/usr.sbin/sade/config.c @@ -376,25 +376,31 @@ configSysconfig(char *config) fp = fopen(config, "w"); } for (i = 0; i < nlines; i++) { - static Boolean firstTime = TRUE; - fprintf(fp, lines[i]); /* Stand by for bogus special case handling - we try to dump the interface specs here */ - if (firstTime && !strncmp(lines[i], VAR_INTERFACES, strlen(VAR_INTERFACES))) { + if (!strncmp(lines[i], VAR_INTERFACES, strlen(VAR_INTERFACES))) { Device **devp; int j, cnt; devp = deviceFind(NULL, DEVICE_TYPE_NETWORK); cnt = deviceCount(devp); for (j = 0; j < cnt; j++) { - char iname[255]; + char iname[255], toadd[512]; + int k, addit = TRUE; snprintf(iname, 255, "%s%s", VAR_IFCONFIG, devp[j]->name); if ((cp = variable_get(iname))) { - fprintf(fp, "%s=\"%s\"\n", iname, cp); + snprintf(toadd, sizeof toadd, "%s=\"%s\"\n", iname, cp); + for (k = 0; k < nlines; k++) { + if (!strcmp(lines[k], toadd)) { + addit = FALSE; + break; + } + } + if (addit) + fprintf(fp, toadd); } } - firstTime = FALSE; } free(lines[i]); } diff --git a/usr.sbin/sysinstall/config.c b/usr.sbin/sysinstall/config.c index 31dba62..2ef56a2 100644 --- a/usr.sbin/sysinstall/config.c +++ b/usr.sbin/sysinstall/config.c @@ -376,25 +376,31 @@ configSysconfig(char *config) fp = fopen(config, "w"); } for (i = 0; i < nlines; i++) { - static Boolean firstTime = TRUE; - fprintf(fp, lines[i]); /* Stand by for bogus special case handling - we try to dump the interface specs here */ - if (firstTime && !strncmp(lines[i], VAR_INTERFACES, strlen(VAR_INTERFACES))) { + if (!strncmp(lines[i], VAR_INTERFACES, strlen(VAR_INTERFACES))) { Device **devp; int j, cnt; devp = deviceFind(NULL, DEVICE_TYPE_NETWORK); cnt = deviceCount(devp); for (j = 0; j < cnt; j++) { - char iname[255]; + char iname[255], toadd[512]; + int k, addit = TRUE; snprintf(iname, 255, "%s%s", VAR_IFCONFIG, devp[j]->name); if ((cp = variable_get(iname))) { - fprintf(fp, "%s=\"%s\"\n", iname, cp); + snprintf(toadd, sizeof toadd, "%s=\"%s\"\n", iname, cp); + for (k = 0; k < nlines; k++) { + if (!strcmp(lines[k], toadd)) { + addit = FALSE; + break; + } + } + if (addit) + fprintf(fp, toadd); } } - firstTime = FALSE; } free(lines[i]); } |