b2a945614a8e196f17c808f7ef4c6ddb6cde8653
[busybox-power] / debian / patches / hotfixes / busybox-1.20.1-ifupdown.patch
1 --- busybox-1.20.1/networking/ifupdown.c
2 +++ busybox-1.20.1-ifupdown/networking/ifupdown.c
3 @@ -140,8 +140,6 @@ static const char keywords_up_down[] ALI
4         "up\0"
5         "down\0"
6         "pre-up\0"
7 -       "pre-down\0"
8 -       "post-up\0"
9         "post-down\0"
10  ;
11  
12 @@ -895,6 +893,11 @@ static struct interfaces_file_t *read_in
13                                 if (rest_of_line[0] == '\0')
14                                         bb_error_msg_and_die("option with empty value \"%s\"", buf);
15  
16 +                               if (strcmp(first_word, "post-up") == 0)
17 +                                       first_word += 5; /* "up" */
18 +                               else if (strcmp(first_word, "pre-down") == 0)
19 +                                       first_word += 4; /* "down" */
20 +
21                                 /* If not one of "up", "down",... words... */
22                                 if (index_in_strings(keywords_up_down, first_word) < 0) {
23                                         int i;
24 @@ -963,7 +966,7 @@ static char *setlocalenv(const char *for
25         return result;
26  }
27  
28 -static void set_environ(struct interface_defn_t *iface, const char *mode)
29 +static void set_environ(struct interface_defn_t *iface, const char *mode, const char *opt)
30  {
31         int i;
32         char **pp;
33 @@ -976,7 +979,7 @@ static void set_environ(struct interface
34         }
35  
36         /* note: last element will stay NULL: */
37 -       G.my_environ = xzalloc(sizeof(char *) * (iface->n_options + 6));
38 +       G.my_environ = xzalloc(sizeof(char *) * (iface->n_options + 7));
39         pp = G.my_environ;
40  
41         for (i = 0; i < iface->n_options; i++) {
42 @@ -990,6 +993,7 @@ static void set_environ(struct interface
43         *pp++ = setlocalenv("%s=%s", "ADDRFAM", iface->address_family->name);
44         *pp++ = setlocalenv("%s=%s", "METHOD", iface->method->name);
45         *pp++ = setlocalenv("%s=%s", "MODE", mode);
46 +       *pp++ = setlocalenv("%s=%s", "PHASE", opt);
47         if (G.startup_PATH)
48                 *pp++ = setlocalenv("%s=%s", "PATH", G.startup_PATH);
49  }
50 @@ -1044,21 +1048,21 @@ static int check(char *str)
51  static int iface_up(struct interface_defn_t *iface)
52  {
53         if (!iface->method->up(iface, check)) return -1;
54 -       set_environ(iface, "start");
55 +       set_environ(iface, "start", "pre-up");
56         if (!execute_all(iface, "pre-up")) return 0;
57         if (!iface->method->up(iface, doit)) return 0;
58 +       set_environ(iface, "start", "post-up");
59         if (!execute_all(iface, "up")) return 0;
60 -       if (!execute_all(iface, "post-up")) return 0;
61         return 1;
62  }
63  
64  static int iface_down(struct interface_defn_t *iface)
65  {
66         if (!iface->method->down(iface,check)) return -1;
67 -       set_environ(iface, "stop");
68 -       if (!execute_all(iface, "pre-down")) return 0;
69 +       set_environ(iface, "stop", "pre-down");
70         if (!execute_all(iface, "down")) return 0;
71         if (!iface->method->down(iface, doit)) return 0;
72 +       set_environ(iface, "stop", "post-down");
73         if (!execute_all(iface, "post-down")) return 0;
74         return 1;
75  }