diff options
Diffstat (limited to 'networking')
-rw-r--r-- | networking/ifupdown.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index ccebecd95..c7cb85350 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -1091,6 +1091,7 @@ int ifupdown_main(int argc, char **argv) | |||
1091 | llist_t *state_list = NULL; | 1091 | llist_t *state_list = NULL; |
1092 | llist_t *target_list = NULL; | 1092 | llist_t *target_list = NULL; |
1093 | const char *interfaces = "/etc/network/interfaces"; | 1093 | const char *interfaces = "/etc/network/interfaces"; |
1094 | FILE *state_fp; | ||
1094 | int any_failures = 0; | 1095 | int any_failures = 0; |
1095 | 1096 | ||
1096 | cmds = iface_down; | 1097 | cmds = iface_down; |
@@ -1117,6 +1118,19 @@ int ifupdown_main(int argc, char **argv) | |||
1117 | startup_PATH = getenv("PATH"); | 1118 | startup_PATH = getenv("PATH"); |
1118 | if (!startup_PATH) startup_PATH = ""; | 1119 | if (!startup_PATH) startup_PATH = ""; |
1119 | 1120 | ||
1121 | /* Read the previous state from the state file */ | ||
1122 | state_fp = fopen_or_warn("/var/run/ifstate", "r"); | ||
1123 | if (state_fp) { | ||
1124 | char *start, *end_ptr; | ||
1125 | while ((start = xmalloc_fgets(state_fp)) != NULL) { | ||
1126 | /* We should only need to check for a single character */ | ||
1127 | end_ptr = start + strcspn(start, " \t\n"); | ||
1128 | *end_ptr = '\0'; | ||
1129 | llist_add_to(&state_list, start); | ||
1130 | } | ||
1131 | fclose(state_fp); | ||
1132 | } | ||
1133 | |||
1120 | /* Create a list of interfaces to work on */ | 1134 | /* Create a list of interfaces to work on */ |
1121 | if (DO_ALL) { | 1135 | if (DO_ALL) { |
1122 | if (cmds == iface_up) { | 1136 | if (cmds == iface_up) { |
@@ -1166,7 +1180,7 @@ int ifupdown_main(int argc, char **argv) | |||
1166 | } | 1180 | } |
1167 | } else { | 1181 | } else { |
1168 | /* ifdown */ | 1182 | /* ifdown */ |
1169 | if (iface_state) { | 1183 | if (!iface_state) { |
1170 | bb_error_msg("interface %s not configured", iface); | 1184 | bb_error_msg("interface %s not configured", iface); |
1171 | continue; | 1185 | continue; |
1172 | } | 1186 | } |
@@ -1236,7 +1250,8 @@ int ifupdown_main(int argc, char **argv) | |||
1236 | iface_state->data = newiface; | 1250 | iface_state->data = newiface; |
1237 | } | 1251 | } |
1238 | } else { | 1252 | } else { |
1239 | /* Remove an interface from the linked list */ | 1253 | /* Remove an interface from state_list */ |
1254 | llist_unlink(&state_list, iface_state); | ||
1240 | free(llist_pop(&iface_state)); | 1255 | free(llist_pop(&iface_state)); |
1241 | } | 1256 | } |
1242 | } | 1257 | } |
@@ -1244,8 +1259,6 @@ int ifupdown_main(int argc, char **argv) | |||
1244 | 1259 | ||
1245 | /* Actually write the new state */ | 1260 | /* Actually write the new state */ |
1246 | if (!NO_ACT) { | 1261 | if (!NO_ACT) { |
1247 | FILE *state_fp; | ||
1248 | |||
1249 | state_fp = xfopen("/var/run/ifstate", "w"); | 1262 | state_fp = xfopen("/var/run/ifstate", "w"); |
1250 | while (state_list) { | 1263 | while (state_list) { |
1251 | if (state_list->data) { | 1264 | if (state_list->data) { |