summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authormurray <murray@FreeBSD.org>2001-09-22 18:10:56 +0000
committermurray <murray@FreeBSD.org>2001-09-22 18:10:56 +0000
commit0e9a3ecd09c9a1c980b455127f6835e4e29b17d8 (patch)
treec80fbd758ae04d9625cfdb8e1669e7cd204fafb3 /usr.sbin
parentc71a3e927a672b31aa2ee41630d9101bfebc001e (diff)
downloadFreeBSD-src-0e9a3ecd09c9a1c980b455127f6835e4e29b17d8.zip
FreeBSD-src-0e9a3ecd09c9a1c980b455127f6835e4e29b17d8.tar.gz
Add a function to free all of sysinstall's internal variables from the
environment. This fixes an annoying bug where hitting Ctrl-C and telling sysinstall to 'restart' will do no such thing since many of the options are still set and so you won't be prompted for them again. MFC after: 1 week
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/sade/sade.h1
-rw-r--r--usr.sbin/sade/system.c5
-rw-r--r--usr.sbin/sade/variable.c34
-rw-r--r--usr.sbin/sysinstall/sysinstall.h1
-rw-r--r--usr.sbin/sysinstall/system.c5
-rw-r--r--usr.sbin/sysinstall/variable.c34
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;
+ }
+}
OpenPOWER on IntegriCloud