I forgot some tabs and added an extra whitespace in usage.h. I re-submitted the patch with fixed whitespacing.
--
Mierswa, Daniel
If you still don't like it, that's ok: that's why I'm boss. I simply
know better than you do.
--- Linus Torvalds, comp.os.linux.advocacy, 1996/07/22
diff -Nur ../busybox-1.7.1.orig/include/usage.h ./include/usage.h
--- ../busybox-1.7.1.orig/include/usage.h 2007-09-03 11:48:46 +0000
+++ ./include/usage.h 2007-10-10 17:12:21 +0000
@@ -1420,7 +1420,7 @@
" [up|down] ..."
#define ifup_trivial_usage \
- "[-ahinv] ifaces..."
+ "[-ahinv"USE_FEATURE_IFUPDOWN_SCRIPTS("Pp")"] ifaces..."
#define ifup_full_usage \
"Options:\n" \
" -a De/configure all interfaces automatically\n" \
@@ -1429,10 +1429,13 @@
" (note that this option doesn't disable mappings)\n" \
" -v Print out what would happen before doing it\n" \
" -m Don't run any mappings\n" \
- " -f Force de/configuration"
+ " -f Force de/configuration" \
+ USE_FEATURE_IFUPDOWN_SCRIPTS( \
+ "\n -P FILE Script to run before bringing the interface up
(default: none)" \
+ "\n -p FILE Script to run after bringing the interface up (default:
none)")
#define ifdown_trivial_usage \
- "[-ahinv] ifaces..."
+ "[-ahinv"USE_FEATURE_IFUPDOWN_SCRIPTS("Pp")"] ifaces..."
#define ifdown_full_usage \
"Options:\n" \
" -a De/configure all interfaces automatically\n" \
@@ -1441,7 +1444,10 @@
" (note that this option doesn't disable mappings)\n" \
" -v Print out what would happen before doing it\n" \
" -m Don't run any mappings\n" \
- " -f Force de/configuration"
+ " -f Force de/configuration" \
+ USE_FEATURE_IFUPDOWN_SCRIPTS( \
+ "\n -P FILE Script to run before bringing the interface down
(default: none)" \
+ "\n -p FILE Script to run after bringing the interface down
(default: none)")
#define inetd_trivial_usage \
"[-f] [-q len] [conf]"
diff -Nur ../busybox-1.7.1.orig/networking/Config.in ./networking/Config.in
--- ../busybox-1.7.1.orig/networking/Config.in 2007-09-03 11:48:27 +0000
+++ ./networking/Config.in 2007-10-10 17:00:16 +0000
@@ -323,6 +323,15 @@
This enables support for the "mapping" stanza, unless you have
a weird network setup you don't need it.
+config FEATURE_IFUPDOWN_SCRIPTS
+ bool "Enable ifup/ifdown scripts"
+ default n
+ depends on IFUPDOWN
+ select RUN_PARTS
+ help
+ This enables support for scripts which can be called
+ once an interface comes up/down.
+
config FEATURE_IFUPDOWN_EXTERNAL_DHCP
bool "Enable support for external dhcp clients"
default n
diff -Nur ../busybox-1.7.1.orig/networking/ifupdown.c ./networking/ifupdown.c
--- ../busybox-1.7.1.orig/networking/ifupdown.c 2007-09-03 11:48:27 +0000
+++ ./networking/ifupdown.c 2007-10-10 16:49:04 +0000
@@ -86,7 +86,7 @@
struct mapping_defn_t *mappings;
};
-#define OPTION_STR "anvf" USE_FEATURE_IFUPDOWN_MAPPING("m") "i:"
+#define OPTION_STR "anvf" USE_FEATURE_IFUPDOWN_MAPPING("m")
USE_FEATURE_IFUPDOWN_SCRIPTS("P:p:") "i:"
enum {
OPT_do_all = 0x1,
OPT_no_act = 0x2,
@@ -950,6 +950,7 @@
return 1;
}
+#ifdef ENABLE_FEATURE_IFUPDOWN_SCRIPTS
static int execute_all(struct interface_defn_t *ifd, const char *opt)
{
int i;
@@ -962,33 +963,58 @@
}
}
- buf = xasprintf("run-parts /etc/network/if-%s.d", opt);
+ buf = xasprintf("run-parts %s", opt);
/* heh, we don't bother free'ing it */
return doit(buf);
}
+#endif
static int check(char *str)
{
return str != NULL;
}
+#ifdef ENABLE_FEATURE_IFUPDOWN_SCRIPTS
+static int iface_up(struct interface_defn_t *iface, const char *pre_up_script,
const char *up_script)
+#else
static int iface_up(struct interface_defn_t *iface)
+#endif
{
if (!iface->method->up(iface, check)) return -1;
set_environ(iface, "start");
- if (!execute_all(iface, "pre-up")) return 0;
+#ifdef ENABLE_FEATURE_IFUPDOWN_SCRIPTS
+ if (pre_up_script) {
+ if (!execute_all(iface, pre_up_script)) return 0;
+ }
+#endif
if (!iface->method->up(iface, doit)) return 0;
- if (!execute_all(iface, "up")) return 0;
+#ifdef ENABLE_FEATURE_IFUPDOWN_SCRIPTS
+ if (up_script) {
+ if (!execute_all(iface, up_script)) return 0;
+ }
+#endif
return 1;
}
+#ifdef ENABLE_FEATURE_IFUPDOWN_SCRIPTS
+static int iface_down(struct interface_defn_t *iface, const char *down_script,
const char *post_down_script)
+#else
static int iface_down(struct interface_defn_t *iface)
+#endif
{
if (!iface->method->down(iface,check)) return -1;
set_environ(iface, "stop");
- if (!execute_all(iface, "down")) return 0;
+#ifdef ENABLE_FEATURE_IFUPDOWN_SCRIPTS
+ if (down_script) {
+ if (!execute_all(iface, down_script)) return 0;
+ }
+#endif
if (!iface->method->down(iface, doit)) return 0;
- if (!execute_all(iface, "post-down")) return 0;
+#ifdef ENABLE_FEATURE_IFUPDOWN_SCRIPTS
+ if (post_down_script) {
+ if (!execute_all(iface, post_down_script)) return 0;
+ }
+#endif
return 1;
}
@@ -1136,10 +1162,18 @@
int ifupdown_main(int argc, char **argv);
int ifupdown_main(int argc, char **argv)
{
+#ifdef ENABLE_FEATURE_IFUPDOWN_SCRIPTS
+ int (*cmds)(struct interface_defn_t *, const char *, const char *) =
NULL;
+#else
int (*cmds)(struct interface_defn_t *) = NULL;
+#endif
struct interfaces_file_t *defn;
llist_t *target_list = NULL;
const char *interfaces = "/etc/network/interfaces";
+#ifdef ENABLE_FEATURE_IFUPDOWN_SCRIPTS
+ const char *pre_script = NULL;
+ const char *post_script = NULL;
+#endif
bool any_failures = 0;
cmds = iface_down;
@@ -1148,7 +1182,11 @@
cmds = iface_up;
}
+#ifdef ENABLE_FEATURE_IFUPDOWN_SCRIPTS
+ getopt32(argv, OPTION_STR, &interfaces, &pre_script, &post_script);
+#else
getopt32(argv, OPTION_STR, &interfaces);
+#endif
if (argc - optind > 0) {
if (DO_ALL) bb_show_usage();
} else {
@@ -1245,7 +1283,11 @@
debug_noise("\nConfiguring interface %s
(%s)\n", liface, currif->address_family->name);
/* Call the cmds function pointer, does either
iface_up() or iface_down() */
+#ifdef ENABLE_FEATURE_IFUPDOWN_SCRIPTS
+ cmds_ret = cmds(currif, pre_script,
post_script);
+#else
cmds_ret = cmds(currif);
+#endif
if (cmds_ret == -1) {
bb_error_msg("don't seem to have all
the variables for %s/%s",
liface,
currif->address_family->name);
signature.asc
Description: OpenPGP digital signature
_______________________________________________ busybox mailing list [email protected] http://busybox.net/cgi-bin/mailman/listinfo/busybox
