Only add interface lines if they're not there already.

This commit is contained in:
Jordan K. Hubbard 1997-02-15 12:24:02 +00:00
parent 80671631f8
commit 136b318913
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=22745
3 changed files with 36 additions and 18 deletions

View File

@ -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]);
}

View File

@ -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]);
}

View File

@ -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]);
}