ifupdown: Attempt to initiliaze the environment in all cases

$ ifup br0.6

would go throup _none_up of links.defn and never call the
set_environ for any of the files. Check for environ being
null and then call the set_environ function to initialize
the PATH. This is changing the semantic to allow the iface,
mode and phase to be NULL. I tried to add proper null checks
This commit is contained in:
Holger Hans Peter Freyther 2015-02-13 18:19:18 +01:00
parent 86dda7481f
commit ddd36a90fc
2 changed files with 59 additions and 1 deletions

View File

@ -2,7 +2,51 @@ Index: ifupdown-0.7.52/execute.c
===================================================================
--- ifupdown-0.7.52.orig/execute.c
+++ ifupdown-0.7.52/execute.c
@@ -168,8 +168,7 @@ int execute_scripts(interface_defn * ifd
@@ -25,7 +25,7 @@ static void set_environ(interface_defn *
{
char **environend;
int i;
- const int n_env_entries = iface->n_options + 8;
+ const int n_env_entries = (iface ? iface->n_options : 0) + 8;
{
char **ppch;
@@ -42,7 +42,7 @@ static void set_environ(interface_defn *
environend = environ;
*environend = NULL;
- for (i = 0; i < iface->n_options; i++) {
+ for (i = 0; iface && i < iface->n_options; i++) {
if (strcmp(iface->option[i].name, "pre-up") == 0 || strcmp(iface->option[i].name, "up") == 0 || strcmp(iface->option[i].name, "down") == 0 || strcmp(iface->option[i].name, "post-down") == 0) {
continue;
}
@@ -52,6 +52,7 @@ static void set_environ(interface_defn *
*environend = NULL;
}
+ if (iface) {
*(environend++) = setlocalenv("%s=%s", "IFACE", iface->real_iface);
*environend = NULL;
@@ -63,12 +64,17 @@ static void set_environ(interface_defn *
*(environend++) = setlocalenv("%s=%s", "METHOD", iface->method->name);
*environend = NULL;
+ }
+ if (mode) {
*(environend++) = setlocalenv("%s=%s", "MODE", mode);
*environend = NULL;
+ }
+ if (phase) {
*(environend++) = setlocalenv("%s=%s", "PHASE", phase);
*environend = NULL;
+ }
*(environend++) = setlocalenv("%s=%s", "VERBOSITY", verbose ? "1" : "0");
*environend = NULL;
@@ -168,8 +174,7 @@ int execute_scripts(interface_defn * ifd
return 1;
char buf[100];
@ -12,3 +56,15 @@ Index: ifupdown-0.7.52/execute.c
verbose ? "--verbose " : "", opt);
int result = (*exec)(buf);
@@ -285,6 +290,11 @@ int execute(char *command, interface_def
char *out;
int ret;
+ if (!environ) {
+ /* initialize the environment to find /sbin/ip */
+ set_environ(NULL, NULL, NULL);
+ }
+
out = parse(command, ifd);
if (!out) {
return 0;

View File

@ -14,6 +14,8 @@ SRC_URI[sha256sum] = "8a0647c59ee0606f5da9205c5b3c5b000fea98fe39348f6bb2cba5fecf
CFLAGS += "-D'IFUPDOWN_VERSION="0.7"'"
PR = "r1"
do_configure() {
chmod a+rx makecdep.sh makenwdep.sh
}