diff options
-rw-r--r-- | usr.sbin/sade/sade.h | 1 | ||||
-rw-r--r-- | usr.sbin/sade/system.c | 5 | ||||
-rw-r--r-- | usr.sbin/sade/variable.c | 34 | ||||
-rw-r--r-- | usr.sbin/sysinstall/sysinstall.h | 1 | ||||
-rw-r--r-- | usr.sbin/sysinstall/system.c | 5 | ||||
-rw-r--r-- | usr.sbin/sysinstall/variable.c | 34 |
6 files changed, 74 insertions, 6 deletions
diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h index b473ab6..2b1a06d 100644 --- a/usr.sbin/sade/sade.h +++ b/usr.sbin/sade/sade.h @@ -771,6 +771,7 @@ extern void variable_unset(char *var); extern char *variable_get_value(char *var, char *prompt, int dirty); extern int variable_check(char *data); extern int dump_variables(dialogMenuItem *self); +extern void free_variables(void); /* wizard.c */ extern void slice_wizard(Disk *d); diff --git a/usr.sbin/sade/system.c b/usr.sbin/sade/system.c index 077cf82..0a1a040 100644 --- a/usr.sbin/sade/system.c +++ b/usr.sbin/sade/system.c @@ -56,7 +56,10 @@ intr_reboot(dialogMenuItem *self) static int intr_restart(dialogMenuItem *self) { - execl(StartName, StartName, (char *)NULL); + int ret; + free_variables(); + ret = execl(StartName, StartName, (char *)NULL); + msgDebug("execl failed (%s)\n", strerror(errno)); /* NOTREACHED */ return -1; } diff --git a/usr.sbin/sade/variable.c b/usr.sbin/sade/variable.c index ee56279..2def090 100644 --- a/usr.sbin/sade/variable.c +++ b/usr.sbin/sade/variable.c @@ -171,8 +171,8 @@ variable_get_value(char *var, char *prompt, int dirty) return cp; } -/* Check if value passed in data (in the form "variable=value") is equal to value of - variable stored in env */ +/* Check if value passed in data (in the form "variable=value") is + equal to value of variable stored in env */ int variable_check(char *data) { @@ -227,3 +227,33 @@ dump_variables(dialogMenuItem *unused) return DITEM_SUCCESS; } + +/* Free all of the variables, useful to really start over as when the + user selects "restart" from the interrupt menu. */ +void +free_variables(void) +{ + Variable *vp; + + /* Free the variables from our list, if we have one.. */ + if (!VarHead) + return; + else if (!VarHead->next) { + unsetenv(VarHead->name); + safe_free(VarHead->name); + safe_free(VarHead->value); + free(VarHead); + VarHead = NULL; + } + else { + for (vp = VarHead; vp; ) { + Variable *save = vp; + unsetenv(vp->name); + safe_free(vp->name); + safe_free(vp->value); + vp = vp->next; + safe_free(save); + } + VarHead = NULL; + } +} diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h index b473ab6..2b1a06d 100644 --- a/usr.sbin/sysinstall/sysinstall.h +++ b/usr.sbin/sysinstall/sysinstall.h @@ -771,6 +771,7 @@ extern void variable_unset(char *var); extern char *variable_get_value(char *var, char *prompt, int dirty); extern int variable_check(char *data); extern int dump_variables(dialogMenuItem *self); +extern void free_variables(void); /* wizard.c */ extern void slice_wizard(Disk *d); diff --git a/usr.sbin/sysinstall/system.c b/usr.sbin/sysinstall/system.c index 077cf82..0a1a040 100644 --- a/usr.sbin/sysinstall/system.c +++ b/usr.sbin/sysinstall/system.c @@ -56,7 +56,10 @@ intr_reboot(dialogMenuItem *self) static int intr_restart(dialogMenuItem *self) { - execl(StartName, StartName, (char *)NULL); + int ret; + free_variables(); + ret = execl(StartName, StartName, (char *)NULL); + msgDebug("execl failed (%s)\n", strerror(errno)); /* NOTREACHED */ return -1; } diff --git a/usr.sbin/sysinstall/variable.c b/usr.sbin/sysinstall/variable.c index ee56279..2def090 100644 --- a/usr.sbin/sysinstall/variable.c +++ b/usr.sbin/sysinstall/variable.c @@ -171,8 +171,8 @@ variable_get_value(char *var, char *prompt, int dirty) return cp; } -/* Check if value passed in data (in the form "variable=value") is equal to value of - variable stored in env */ +/* Check if value passed in data (in the form "variable=value") is + equal to value of variable stored in env */ int variable_check(char *data) { @@ -227,3 +227,33 @@ dump_variables(dialogMenuItem *unused) return DITEM_SUCCESS; } + +/* Free all of the variables, useful to really start over as when the + user selects "restart" from the interrupt menu. */ +void +free_variables(void) +{ + Variable *vp; + + /* Free the variables from our list, if we have one.. */ + if (!VarHead) + return; + else if (!VarHead->next) { + unsetenv(VarHead->name); + safe_free(VarHead->name); + safe_free(VarHead->value); + free(VarHead); + VarHead = NULL; + } + else { + for (vp = VarHead; vp; ) { + Variable *save = vp; + unsetenv(vp->name); + safe_free(vp->name); + safe_free(vp->value); + vp = vp->next; + safe_free(save); + } + VarHead = NULL; + } +} |