aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-12-19 23:15:46 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-12-19 23:15:46 +0000
commit2375d75f3267e6e4370f221fea485eac8e73d402 (patch)
tree05a36e8cad639b9f33bc756a7ea1b738248d2a62
parent8cd1a288fa15c8db5701ad94592c5a6a4562b1a9 (diff)
downloadbusybox-w32-2375d75f3267e6e4370f221fea485eac8e73d402.tar.gz
busybox-w32-2375d75f3267e6e4370f221fea485eac8e73d402.tar.bz2
busybox-w32-2375d75f3267e6e4370f221fea485eac8e73d402.zip
ifupdown: do not print and/or execute empty commands ("").
-rw-r--r--networking/ifupdown.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index 90c05444b..b53d2330d 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -291,9 +291,11 @@ static int execute(const char *command, struct interface_defn_t *ifd, execfn *ex
291 291
292 out = parse(command, ifd); 292 out = parse(command, ifd);
293 if (!out) { 293 if (!out) {
294 /* parse error? */
294 return 0; 295 return 0;
295 } 296 }
296 ret = (*exec)(out); 297 /* out == "": parsed ok but not all needed variables known, skip */
298 ret = out[0] ? (*exec)(out) : 1;
297 299
298 free(out); 300 free(out);
299 if (ret != 1) { 301 if (ret != 1) {
@@ -903,15 +905,13 @@ static int doit(char *str)
903 if (option_mask32 & (OPT_no_act|OPT_verbose)) { 905 if (option_mask32 & (OPT_no_act|OPT_verbose)) {
904 puts(str); 906 puts(str);
905 } 907 }
906 /* FIXME: is it true that we can reach this place with str = ""? */
907 /* how? in execute() parse() may return "", then we do (*exec)(""); */
908 /* Please add a comment... */
909 if (!(option_mask32 & OPT_no_act)) { 908 if (!(option_mask32 & OPT_no_act)) {
910 pid_t child; 909 pid_t child;
911 int status; 910 int status;
912 911
913 fflush(NULL); 912 fflush(NULL);
914 switch (child = fork()) { 913 child = fork();
914 switch (child) {
915 case -1: /* failure */ 915 case -1: /* failure */
916 return 0; 916 return 0;
917 case 0: /* child */ 917 case 0: /* child */
@@ -939,10 +939,8 @@ static int execute_all(struct interface_defn_t *ifd, const char *opt)
939 } 939 }
940 940
941 buf = xasprintf("run-parts /etc/network/if-%s.d", opt); 941 buf = xasprintf("run-parts /etc/network/if-%s.d", opt);
942 if (doit(buf) != 1) { 942 /* heh, we don't bother free'ing it */
943 return 0; 943 return doit(buf);
944 }
945 return 1;
946} 944}
947 945
948static int check(char *str) 946static int check(char *str)