From ddd36a90fca6ccd48e9981308e71e99aa976ce91 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 13 Feb 2015 18:19:18 +0100 Subject: [PATCH] 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 --- .../ifupdown/files/busybox-yocto-compat.patch | 58 ++++++++++++++++++- recipes-extra/ifupdown/ifupdown_0.7.52.bb | 2 + 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/recipes-extra/ifupdown/files/busybox-yocto-compat.patch b/recipes-extra/ifupdown/files/busybox-yocto-compat.patch index d5cd6dd..fc32e07 100644 --- a/recipes-extra/ifupdown/files/busybox-yocto-compat.patch +++ b/recipes-extra/ifupdown/files/busybox-yocto-compat.patch @@ -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; diff --git a/recipes-extra/ifupdown/ifupdown_0.7.52.bb b/recipes-extra/ifupdown/ifupdown_0.7.52.bb index c99b123..0b9048a 100644 --- a/recipes-extra/ifupdown/ifupdown_0.7.52.bb +++ b/recipes-extra/ifupdown/ifupdown_0.7.52.bb @@ -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 }