diff options
author | Eric Andersen <andersen@codepoet.org> | 2003-06-05 19:37:01 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2003-06-05 19:37:01 +0000 |
commit | 233b170a8567c396b0836ec17c82a50d212b8a8d (patch) | |
tree | 5b65c4e0ec1f38523a8314fcaf07f1939a687a23 | |
parent | d130973f349d70571e517c362d480ebcfab936bc (diff) | |
download | busybox-w32-233b170a8567c396b0836ec17c82a50d212b8a8d.tar.gz busybox-w32-233b170a8567c396b0836ec17c82a50d212b8a8d.tar.bz2 busybox-w32-233b170a8567c396b0836ec17c82a50d212b8a8d.zip |
Patch from Lars Kellogg-Stedman, lars at larsshack.org, to
make ifupdown's mapping function work as documented.
-rw-r--r-- | networking/ifupdown.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 6c79c2004..5b37c3ab7 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -49,6 +49,9 @@ | |||
49 | #define EUNDEFVAR 10002 | 49 | #define EUNDEFVAR 10002 |
50 | #define EUNBALPER 10000 | 50 | #define EUNBALPER 10000 |
51 | 51 | ||
52 | #ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING | ||
53 | #define MAX_INTERFACE_LENGTH 10 | ||
54 | #endif | ||
52 | 55 | ||
53 | #if 0 | 56 | #if 0 |
54 | #define debug_noise(fmt, args...) printf(fmt, ## args) | 57 | #define debug_noise(fmt, args...) printf(fmt, ## args) |
@@ -1106,12 +1109,13 @@ static int popen2(FILE **in, FILE **out, char *command, ...) | |||
1106 | /* unreached */ | 1109 | /* unreached */ |
1107 | } | 1110 | } |
1108 | 1111 | ||
1109 | static int run_mapping(char *physical, char *logical, int len, struct mapping_defn_t * map) | 1112 | static char * run_mapping(char *physical, char *logical, int len, struct mapping_defn_t * map) |
1110 | { | 1113 | { |
1111 | FILE *in, *out; | 1114 | FILE *in, *out; |
1112 | int i, status; | 1115 | int i, status; |
1113 | pid_t pid; | 1116 | pid_t pid; |
1114 | 1117 | ||
1118 | char *new_logical = NULL; | ||
1115 | 1119 | ||
1116 | pid = popen2(&in, &out, map->script, physical, NULL); | 1120 | pid = popen2(&in, &out, map->script, physical, NULL); |
1117 | if (pid == 0) { | 1121 | if (pid == 0) { |
@@ -1123,16 +1127,18 @@ static int run_mapping(char *physical, char *logical, int len, struct mapping_de | |||
1123 | fclose(in); | 1127 | fclose(in); |
1124 | waitpid(pid, &status, 0); | 1128 | waitpid(pid, &status, 0); |
1125 | if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { | 1129 | if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { |
1126 | if (fgets(logical, len, out)) { | 1130 | new_logical = (char *)xmalloc(MAX_INTERFACE_LENGTH); |
1127 | char *pch = logical + bb_strlen(logical) - 1; | 1131 | |
1132 | if (fgets(new_logical, MAX_INTERFACE_LENGTH, out)) { | ||
1133 | char *pch = new_logical + bb_strlen(new_logical) - 1; | ||
1128 | 1134 | ||
1129 | while (pch >= logical && isspace(*pch)) | 1135 | while (pch >= new_logical && isspace(*pch)) |
1130 | *(pch--) = '\0'; | 1136 | *(pch--) = '\0'; |
1131 | } | 1137 | } |
1132 | } | 1138 | } |
1133 | fclose(out); | 1139 | fclose(out); |
1134 | 1140 | ||
1135 | return 1; | 1141 | return new_logical ? new_logical : logical; |
1136 | } | 1142 | } |
1137 | #endif /* CONFIG_FEATURE_IFUPDOWN_IPV6 */ | 1143 | #endif /* CONFIG_FEATURE_IFUPDOWN_IPV6 */ |
1138 | 1144 | ||
@@ -1318,7 +1324,7 @@ extern int ifupdown_main(int argc, char **argv) | |||
1318 | if (verbose) { | 1324 | if (verbose) { |
1319 | printf("Running mapping script %s on %s\n", currmap->script, liface); | 1325 | printf("Running mapping script %s on %s\n", currmap->script, liface); |
1320 | } | 1326 | } |
1321 | run_mapping(iface, liface, sizeof(liface), currmap); | 1327 | liface = run_mapping(iface, liface, sizeof(liface), currmap); |
1322 | break; | 1328 | break; |
1323 | } | 1329 | } |
1324 | } | 1330 | } |