aboutsummaryrefslogtreecommitdiff
path: root/networking/ifupdown.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-07-29 07:05:40 +0000
committerEric Andersen <andersen@codepoet.org>2003-07-29 07:05:40 +0000
commit2a186890ee664be41b8f9ea572a9ae3498f06eca (patch)
tree13ec20ed6ec7dd51ab4ffe84530d9dd37b77b091 /networking/ifupdown.c
parent81fe123040b53490b239b3d2abc8cc93d6d462ae (diff)
downloadbusybox-2a186890ee664be41b8f9ea572a9ae3498f06eca.tar.gz
Bruno Randolf writes:
this patch fixes run_parts when it's called by ifupdown. 1) argv has to be a NULL terminated char* array, not just a string. 2) run_parts now explicitly sets the environment. this environment is populated from the /etc/network/interfaces config file and is needed by the scripts in /etc/network/if-pre-up.d/. when run-parts is called from the command line the environment is taken from the current process. Vladimir Oleynik then wrote: You can simplify this if use: + bb_xasprintf(&buf[0], "/etc/network/if-%s.d", opt); + buf[1] = NULL; + + run_parts(&buf, 2, environ); + free(buf[0]); --w vodz
Diffstat (limited to 'networking/ifupdown.c')
-rw-r--r--networking/ifupdown.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index 818bec2d6..f91eddae8 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -1019,7 +1019,7 @@ static int doit(char *str)
static int execute_all(struct interface_defn_t *ifd, execfn *exec, const char *opt)
{
int i;
- char *buf;
+ char *buf[2];
for (i = 0; i < ifd->n_options; i++) {
if (strcmp(ifd->option[i].name, opt) == 0) {
@@ -1029,10 +1029,11 @@ static int execute_all(struct interface_defn_t *ifd, execfn *exec, const char *o
}
}
- buf = xmalloc(bb_strlen(opt) + 19);
- sprintf(buf, "/etc/network/if-%s.d", opt);
- run_parts(&buf, 2);
- free(buf);
+ bb_xasprintf(&buf[0], "/etc/network/if-%s.d", opt);
+ buf[1] = NULL;
+
+ run_parts(&buf, 2, environ);
+ free(buf[0]);
return (1);
}