[BusyBox-cvs] busybox/networking ifupdown.c,1.26,1.27
Erik Andersen
andersen at busybox.net
Tue Jul 29 07:05:44 UTC 2003
Update of /var/cvs/busybox/networking
In directory winder:/tmp/cvs-serv8695/networking
Modified Files:
ifupdown.c
Log Message:
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
Index: ifupdown.c
===================================================================
RCS file: /var/cvs/busybox/networking/ifupdown.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- ifupdown.c 3 Jul 2003 10:20:29 -0000 1.26
+++ ifupdown.c 29 Jul 2003 07:05:40 -0000 1.27
@@ -1019,7 +1019,7 @@
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 @@
}
}
- 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);
}
More information about the busybox-cvs
mailing list