ifupdown: parse() returning NULL and returning "" is not the same,
it turned out! wow... okay, fixing my buglet...
This commit is contained in:
3
Makefile
3
Makefile
@@ -573,7 +573,8 @@ ifdef CONFIG_STATIC
|
|||||||
-Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \
|
-Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \
|
||||||
-Wl,--start-group $(busybox-all) -Wl,--end-group
|
-Wl,--start-group $(busybox-all) -Wl,--end-group
|
||||||
else
|
else
|
||||||
cmd_busybox__ ?= $(srctree)/scripts/trylink $(CC) -o $@ $(LDFLAGS) \
|
cmd_busybox__ ?= $(srctree)/scripts/trylink $(CC) $(LDFLAGS) \
|
||||||
|
-o $@ \
|
||||||
-Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \
|
-Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \
|
||||||
-Wl,--start-group $(busybox-all) -Wl,--end-group
|
-Wl,--start-group $(busybox-all) -Wl,--end-group
|
||||||
endif
|
endif
|
||||||
|
@@ -103,7 +103,7 @@ enum {
|
|||||||
#define FORCE (option_mask32 & OPT_force)
|
#define FORCE (option_mask32 & OPT_force)
|
||||||
#define NO_MAPPINGS (option_mask32 & OPT_no_mappings)
|
#define NO_MAPPINGS (option_mask32 & OPT_no_mappings)
|
||||||
|
|
||||||
static char **__myenviron;
|
static char **my_environ;
|
||||||
|
|
||||||
static char *startup_PATH;
|
static char *startup_PATH;
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ static char *parse(const char *command, struct interface_defn_t *ifd)
|
|||||||
size_t old_pos[MAX_OPT_DEPTH] = { 0 };
|
size_t old_pos[MAX_OPT_DEPTH] = { 0 };
|
||||||
int okay[MAX_OPT_DEPTH] = { 1 };
|
int okay[MAX_OPT_DEPTH] = { 1 };
|
||||||
int opt_depth = 1;
|
int opt_depth = 1;
|
||||||
char *result = xstrdup("");
|
char *result = NULL;
|
||||||
|
|
||||||
while (*command) {
|
while (*command) {
|
||||||
switch (*command) {
|
switch (*command) {
|
||||||
@@ -206,7 +206,7 @@ static char *parse(const char *command, struct interface_defn_t *ifd)
|
|||||||
break;
|
break;
|
||||||
case '[':
|
case '[':
|
||||||
if (command[1] == '[' && opt_depth < MAX_OPT_DEPTH) {
|
if (command[1] == '[' && opt_depth < MAX_OPT_DEPTH) {
|
||||||
old_pos[opt_depth] = strlen(result);
|
old_pos[opt_depth] = result ? strlen(result) : 0;
|
||||||
okay[opt_depth] = 1;
|
okay[opt_depth] = 1;
|
||||||
opt_depth++;
|
opt_depth++;
|
||||||
command += 2;
|
command += 2;
|
||||||
@@ -290,7 +290,7 @@ static int execute(const char *command, struct interface_defn_t *ifd, execfn *ex
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
out = parse(command, ifd);
|
out = parse(command, ifd);
|
||||||
if (!out || !out[0]) {
|
if (!out) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ret = (*exec)(out);
|
ret = (*exec)(out);
|
||||||
@@ -871,15 +871,15 @@ static void set_environ(struct interface_defn_t *iface, const char *mode)
|
|||||||
const int n_env_entries = iface->n_options + 5;
|
const int n_env_entries = iface->n_options + 5;
|
||||||
char **ppch;
|
char **ppch;
|
||||||
|
|
||||||
if (__myenviron != NULL) {
|
if (my_environ != NULL) {
|
||||||
for (ppch = __myenviron; *ppch; ppch++) {
|
for (ppch = my_environ; *ppch; ppch++) {
|
||||||
free(*ppch);
|
free(*ppch);
|
||||||
*ppch = NULL;
|
*ppch = NULL;
|
||||||
}
|
}
|
||||||
free(__myenviron);
|
free(my_environ);
|
||||||
}
|
}
|
||||||
__myenviron = xzalloc(sizeof(char *) * (n_env_entries + 1 /* for final NULL */ ));
|
my_environ = xzalloc(sizeof(char *) * (n_env_entries + 1 /* for final NULL */ ));
|
||||||
environend = __myenviron;
|
environend = my_environ;
|
||||||
|
|
||||||
for (i = 0; i < iface->n_options; i++) {
|
for (i = 0; i < iface->n_options; i++) {
|
||||||
if (strcmp(iface->option[i].name, "up") == 0
|
if (strcmp(iface->option[i].name, "up") == 0
|
||||||
@@ -903,6 +903,9 @@ static int doit(char *str)
|
|||||||
if (option_mask32 & (OPT_no_act|OPT_verbose)) {
|
if (option_mask32 & (OPT_no_act|OPT_verbose)) {
|
||||||
puts(str);
|
puts(str);
|
||||||
}
|
}
|
||||||
|
/* FIXME: is it true that we can reach this place with str = ""? */
|
||||||
|
/* how? in execute() parse() may return "", then we do (*exec)(""); */
|
||||||
|
/* Please add a comment... */
|
||||||
if (!(option_mask32 & OPT_no_act)) {
|
if (!(option_mask32 & OPT_no_act)) {
|
||||||
pid_t child;
|
pid_t child;
|
||||||
int status;
|
int status;
|
||||||
@@ -912,7 +915,7 @@ static int doit(char *str)
|
|||||||
case -1: /* failure */
|
case -1: /* failure */
|
||||||
return 0;
|
return 0;
|
||||||
case 0: /* child */
|
case 0: /* child */
|
||||||
execle(DEFAULT_SHELL, DEFAULT_SHELL, "-c", str, NULL, __myenviron);
|
execle(DEFAULT_SHELL, DEFAULT_SHELL, "-c", str, NULL, my_environ);
|
||||||
exit(127);
|
exit(127);
|
||||||
}
|
}
|
||||||
waitpid(child, &status, 0);
|
waitpid(child, &status, 0);
|
||||||
@@ -1206,7 +1209,7 @@ int ifupdown_main(int argc, char **argv)
|
|||||||
okay = 1;
|
okay = 1;
|
||||||
currif->iface = iface;
|
currif->iface = iface;
|
||||||
|
|
||||||
debug_noise("\nZ Configuring interface %s (%s)\n", liface, currif->address_family->name);
|
debug_noise("\nConfiguring interface %s (%s)\n", liface, currif->address_family->name);
|
||||||
|
|
||||||
/* Call the cmds function pointer, does either iface_up() or iface_down() */
|
/* Call the cmds function pointer, does either iface_up() or iface_down() */
|
||||||
cmds_ret = cmds(currif);
|
cmds_ret = cmds(currif);
|
||||||
|
Reference in New Issue
Block a user