aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-11-14 18:31:07 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2016-11-14 18:31:07 +0100
commita8c696bf09d8151323f6e99348c4bc8989f829c8 (patch)
tree34b59ab83132296ea7c1c9618fdb58276a077d22
parentf417ffd88f194bbfd18605882ee242190c1bab34 (diff)
downloadbusybox-w32-a8c696bf09d8151323f6e99348c4bc8989f829c8.tar.gz
busybox-w32-a8c696bf09d8151323f6e99348c4bc8989f829c8.tar.bz2
busybox-w32-a8c696bf09d8151323f6e99348c4bc8989f829c8.zip
Make ifup and ifdown individually selectable.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--include/applets.src.h2
-rw-r--r--networking/Config.src105
-rw-r--r--networking/Kbuild.src1
-rw-r--r--networking/ifupdown.c135
4 files changed, 127 insertions, 116 deletions
diff --git a/include/applets.src.h b/include/applets.src.h
index f2c754b74..36e1f0266 100644
--- a/include/applets.src.h
+++ b/include/applets.src.h
@@ -160,10 +160,8 @@ IF_HEXDUMP(APPLET_NOEXEC(hexdump, hexdump, BB_DIR_USR_BIN, BB_SUID_DROP, hexdump
160IF_HTTPD(APPLET(httpd, BB_DIR_USR_SBIN, BB_SUID_DROP)) 160IF_HTTPD(APPLET(httpd, BB_DIR_USR_SBIN, BB_SUID_DROP))
161IF_HWCLOCK(APPLET(hwclock, BB_DIR_SBIN, BB_SUID_DROP)) 161IF_HWCLOCK(APPLET(hwclock, BB_DIR_SBIN, BB_SUID_DROP))
162IF_IFCONFIG(APPLET(ifconfig, BB_DIR_SBIN, BB_SUID_DROP)) 162IF_IFCONFIG(APPLET(ifconfig, BB_DIR_SBIN, BB_SUID_DROP))
163IF_IFUPDOWN(APPLET_ODDNAME(ifdown, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifdown))
164IF_IFENSLAVE(APPLET(ifenslave, BB_DIR_SBIN, BB_SUID_DROP)) 163IF_IFENSLAVE(APPLET(ifenslave, BB_DIR_SBIN, BB_SUID_DROP))
165IF_IFPLUGD(APPLET(ifplugd, BB_DIR_USR_SBIN, BB_SUID_DROP)) 164IF_IFPLUGD(APPLET(ifplugd, BB_DIR_USR_SBIN, BB_SUID_DROP))
166IF_IFUPDOWN(APPLET_ODDNAME(ifup, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifup))
167IF_INETD(APPLET(inetd, BB_DIR_USR_SBIN, BB_SUID_DROP)) 165IF_INETD(APPLET(inetd, BB_DIR_USR_SBIN, BB_SUID_DROP))
168IF_INOTIFYD(APPLET(inotifyd, BB_DIR_SBIN, BB_SUID_DROP)) 166IF_INOTIFYD(APPLET(inotifyd, BB_DIR_SBIN, BB_SUID_DROP))
169IF_INSTALL(APPLET(install, BB_DIR_USR_BIN, BB_SUID_DROP)) 167IF_INSTALL(APPLET(install, BB_DIR_USR_BIN, BB_SUID_DROP))
diff --git a/networking/Config.src b/networking/Config.src
index 398a5ee25..43667fe6a 100644
--- a/networking/Config.src
+++ b/networking/Config.src
@@ -342,111 +342,6 @@ config IFPLUGD
342 help 342 help
343 Network interface plug detection daemon. 343 Network interface plug detection daemon.
344 344
345config IFUPDOWN
346 bool "ifupdown"
347 default y
348 help
349 Activate or deactivate the specified interfaces. This applet makes
350 use of either "ifconfig" and "route" or the "ip" command to actually
351 configure network interfaces. Therefore, you will probably also want
352 to enable either IFCONFIG and ROUTE, or enable
353 FEATURE_IFUPDOWN_IP and the various IP options. Of
354 course you could use non-busybox versions of these programs, so
355 against my better judgement (since this will surely result in plenty
356 of support questions on the mailing list), I do not force you to
357 enable these additional options. It is up to you to supply either
358 "ifconfig", "route" and "run-parts" or the "ip" command, either
359 via busybox or via standalone utilities.
360
361config IFUPDOWN_IFSTATE_PATH
362 string "Absolute path to ifstate file"
363 default "/var/run/ifstate"
364 depends on IFUPDOWN
365 help
366 ifupdown keeps state information in a file called ifstate.
367 Typically it is located in /var/run/ifstate, however
368 some distributions tend to put it in other places
369 (debian, for example, uses /etc/network/run/ifstate).
370 This config option defines location of ifstate.
371
372config FEATURE_IFUPDOWN_IP
373 bool "Use ip applet"
374 default y
375 depends on IFUPDOWN
376 help
377 Use the iproute "ip" command to implement "ifup" and "ifdown", rather
378 than the default of using the older 'ifconfig' and 'route' utilities.
379
380config FEATURE_IFUPDOWN_IP_BUILTIN
381 bool "Use busybox ip applet"
382 default y
383 depends on FEATURE_IFUPDOWN_IP
384 select PLATFORM_LINUX
385 select IP
386 select FEATURE_IP_ADDRESS
387 select FEATURE_IP_LINK
388 select FEATURE_IP_ROUTE
389 help
390 Use the busybox iproute "ip" applet to implement "ifupdown".
391
392 If left disabled, you must install the full-blown iproute2
393 utility or the "ifup" and "ifdown" applets will not work.
394
395config FEATURE_IFUPDOWN_IFCONFIG_BUILTIN
396 bool "Use busybox ifconfig and route applets"
397 default n
398 depends on IFUPDOWN && !FEATURE_IFUPDOWN_IP
399 select IFCONFIG
400 select ROUTE
401 help
402 Use the busybox iproute "ifconfig" and "route" applets to
403 implement the "ifup" and "ifdown" utilities.
404
405 If left disabled, you must install the full-blown ifconfig
406 and route utilities, or the "ifup" and "ifdown" applets will not
407 work.
408
409config FEATURE_IFUPDOWN_IPV4
410 bool "Support for IPv4"
411 default y
412 depends on IFUPDOWN
413 help
414 If you want ifup/ifdown to talk IPv4, leave this on.
415
416config FEATURE_IFUPDOWN_IPV6
417 bool "Support for IPv6"
418 default y
419 depends on IFUPDOWN && FEATURE_IPV6
420 help
421 If you need support for IPv6, turn this option on.
422
423### UNUSED
424###config FEATURE_IFUPDOWN_IPX
425### bool "Support for IPX"
426### default y
427### depends on IFUPDOWN
428### help
429### If this option is selected you can use busybox to work with IPX
430### networks.
431
432config FEATURE_IFUPDOWN_MAPPING
433 bool "Enable mapping support"
434 default y
435 depends on IFUPDOWN
436 help
437 This enables support for the "mapping" stanza, unless you have
438 a weird network setup you don't need it.
439
440config FEATURE_IFUPDOWN_EXTERNAL_DHCP
441 bool "Support for external dhcp clients"
442 default n
443 depends on IFUPDOWN
444 help
445 This enables support for the external dhcp clients. Clients are
446 tried in the following order: dhcpcd, dhclient, pump and udhcpc.
447 Otherwise, if udhcpc applet is enabled, it is used.
448 Otherwise, ifup/ifdown will have no support for DHCP.
449
450config INETD 345config INETD
451 bool "inetd" 346 bool "inetd"
452 default y 347 default y
diff --git a/networking/Kbuild.src b/networking/Kbuild.src
index e14070647..4ad750283 100644
--- a/networking/Kbuild.src
+++ b/networking/Kbuild.src
@@ -20,7 +20,6 @@ lib-$(CONFIG_HTTPD) += httpd.o
20lib-$(CONFIG_IFCONFIG) += ifconfig.o interface.o 20lib-$(CONFIG_IFCONFIG) += ifconfig.o interface.o
21lib-$(CONFIG_IFENSLAVE) += ifenslave.o interface.o 21lib-$(CONFIG_IFENSLAVE) += ifenslave.o interface.o
22lib-$(CONFIG_IFPLUGD) += ifplugd.o 22lib-$(CONFIG_IFPLUGD) += ifplugd.o
23lib-$(CONFIG_IFUPDOWN) += ifupdown.o
24lib-$(CONFIG_INETD) += inetd.o 23lib-$(CONFIG_INETD) += inetd.o
25lib-$(CONFIG_IP) += ip.o 24lib-$(CONFIG_IP) += ip.o
26lib-$(CONFIG_IPCALC) += ipcalc.o 25lib-$(CONFIG_IPCALC) += ipcalc.o
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index 1d0fc53cf..7ac517afd 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -1,6 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * ifupdown for busybox 3 * ifup/ifdown for busybox
4 * Copyright (c) 2002 Glenn McGrath 4 * Copyright (c) 2002 Glenn McGrath
5 * Copyright (c) 2003-2004 Erik Andersen <andersen@codepoet.org> 5 * Copyright (c) 2003-2004 Erik Andersen <andersen@codepoet.org>
6 * 6 *
@@ -17,10 +17,127 @@
17 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 17 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
18 */ 18 */
19 19
20//config:config IFUP
21//config: bool "ifup"
22//config: default y
23//config: help
24//config: Activate the specified interfaces. This applet makes use
25//config: of either "ifconfig" and "route" or the "ip" command to actually
26//config: configure network interfaces. Therefore, you will probably also want
27//config: to enable either IFCONFIG and ROUTE, or enable
28//config: FEATURE_IFUPDOWN_IP and the various IP options. Of
29//config: course you could use non-busybox versions of these programs, so
30//config: against my better judgement (since this will surely result in plenty
31//config: of support questions on the mailing list), I do not force you to
32//config: enable these additional options. It is up to you to supply either
33//config: "ifconfig", "route" and "run-parts" or the "ip" command, either
34//config: via busybox or via standalone utilities.
35//config:
36//config:config IFDOWN
37//config: bool "ifdown"
38//config: default y
39//config: help
40//config: Deactivate the specified interfaces.
41//config:
42//config:config IFUPDOWN_IFSTATE_PATH
43//config: string "Absolute path to ifstate file"
44//config: default "/var/run/ifstate"
45//config: depends on IFUP || IFDOWN
46//config: help
47//config: ifupdown keeps state information in a file called ifstate.
48//config: Typically it is located in /var/run/ifstate, however
49//config: some distributions tend to put it in other places
50//config: (debian, for example, uses /etc/network/run/ifstate).
51//config: This config option defines location of ifstate.
52//config:
53//config:config FEATURE_IFUPDOWN_IP
54//config: bool "Use ip applet"
55//config: default y
56//config: depends on IFUP || IFDOWN
57//config: help
58//config: Use the iproute "ip" command to implement "ifup" and "ifdown", rather
59//config: than the default of using the older 'ifconfig' and 'route' utilities.
60//config:
61//config:config FEATURE_IFUPDOWN_IP_BUILTIN
62//config: bool "Use busybox ip applet"
63//config: default y
64//config: depends on FEATURE_IFUPDOWN_IP
65//config: select PLATFORM_LINUX
66//config: select IP
67//config: select FEATURE_IP_ADDRESS
68//config: select FEATURE_IP_LINK
69//config: select FEATURE_IP_ROUTE
70//config: help
71//config: Use the busybox iproute "ip" applet to implement "ifupdown".
72//config:
73//config: If left disabled, you must install the full-blown iproute2
74//config: utility or the "ifup" and "ifdown" applets will not work.
75//config:
76//config:config FEATURE_IFUPDOWN_IFCONFIG_BUILTIN
77//config: bool "Use busybox ifconfig and route applets"
78//config: default n
79//config: depends on (IFUP || IFDOWN) && !FEATURE_IFUPDOWN_IP
80//config: select IFCONFIG
81//config: select ROUTE
82//config: help
83//config: Use the busybox iproute "ifconfig" and "route" applets to
84//config: implement the "ifup" and "ifdown" utilities.
85//config:
86//config: If left disabled, you must install the full-blown ifconfig
87//config: and route utilities, or the "ifup" and "ifdown" applets will not
88//config: work.
89//config:
90//config:config FEATURE_IFUPDOWN_IPV4
91//config: bool "Support for IPv4"
92//config: default y
93//config: depends on IFUP || IFDOWN
94//config: help
95//config: If you want ifup/ifdown to talk IPv4, leave this on.
96//config:
97//config:config FEATURE_IFUPDOWN_IPV6
98//config: bool "Support for IPv6"
99//config: default y
100//config: depends on (IFUP || IFDOWN) && FEATURE_IPV6
101//config: help
102//config: If you need support for IPv6, turn this option on.
103//config:
104//UNUSED:
105////////:config FEATURE_IFUPDOWN_IPX
106////////: bool "Support for IPX"
107////////: default y
108////////: depends on IFUP || IFDOWN
109////////: help
110////////: If this option is selected you can use busybox to work with IPX
111////////: networks.
112//config:
113//config:config FEATURE_IFUPDOWN_MAPPING
114//config: bool "Enable mapping support"
115//config: default y
116//config: depends on IFUP || IFDOWN
117//config: help
118//config: This enables support for the "mapping" stanza, unless you have
119//config: a weird network setup you don't need it.
120//config:
121//config:config FEATURE_IFUPDOWN_EXTERNAL_DHCP
122//config: bool "Support for external dhcp clients"
123//config: default n
124//config: depends on IFUP || IFDOWN
125//config: help
126//config: This enables support for the external dhcp clients. Clients are
127//config: tried in the following order: dhcpcd, dhclient, pump and udhcpc.
128//config: Otherwise, if udhcpc applet is enabled, it is used.
129//config: Otherwise, ifup/ifdown will have no support for DHCP.
130
131//applet:IF_IFUP(APPLET_ODDNAME(ifup, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifup))
132//applet:IF_IFDOWN(APPLET_ODDNAME(ifdown, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifdown))
133
134//kbuild:lib-$(CONFIG_IFUP) += ifupdown.o
135//kbuild:lib-$(CONFIG_IFDOWN) += ifupdown.o
136
20//usage:#define ifup_trivial_usage 137//usage:#define ifup_trivial_usage
21//usage: "[-an"IF_FEATURE_IFUPDOWN_MAPPING("m")"vf] [-i FILE] IFACE..." 138//usage: "[-an"IF_FEATURE_IFUPDOWN_MAPPING("m")"vf] [-i FILE] IFACE..."
22//usage:#define ifup_full_usage "\n\n" 139//usage:#define ifup_full_usage "\n\n"
23//usage: " -a De/configure all interfaces automatically" 140//usage: " -a Configure all interfaces"
24//usage: "\n -i FILE Use FILE instead of /etc/network/interfaces" 141//usage: "\n -i FILE Use FILE instead of /etc/network/interfaces"
25//usage: "\n -n Print out what would happen, but don't do it" 142//usage: "\n -n Print out what would happen, but don't do it"
26//usage: IF_FEATURE_IFUPDOWN_MAPPING( 143//usage: IF_FEATURE_IFUPDOWN_MAPPING(
@@ -28,12 +145,12 @@
28//usage: "\n -m Don't run any mappings" 145//usage: "\n -m Don't run any mappings"
29//usage: ) 146//usage: )
30//usage: "\n -v Print out what would happen before doing it" 147//usage: "\n -v Print out what would happen before doing it"
31//usage: "\n -f Force de/configuration" 148//usage: "\n -f Force configuration"
32//usage: 149//usage:
33//usage:#define ifdown_trivial_usage 150//usage:#define ifdown_trivial_usage
34//usage: "[-an"IF_FEATURE_IFUPDOWN_MAPPING("m")"vf] [-i FILE] IFACE..." 151//usage: "[-an"IF_FEATURE_IFUPDOWN_MAPPING("m")"vf] [-i FILE] IFACE..."
35//usage:#define ifdown_full_usage "\n\n" 152//usage:#define ifdown_full_usage "\n\n"
36//usage: " -a De/configure all interfaces automatically" 153//usage: " -a Deconfigure all interfaces"
37//usage: "\n -i FILE Use FILE for interface definitions" 154//usage: "\n -i FILE Use FILE for interface definitions"
38//usage: "\n -n Print out what would happen, but don't do it" 155//usage: "\n -n Print out what would happen, but don't do it"
39//usage: IF_FEATURE_IFUPDOWN_MAPPING( 156//usage: IF_FEATURE_IFUPDOWN_MAPPING(
@@ -41,7 +158,7 @@
41//usage: "\n -m Don't run any mappings" 158//usage: "\n -m Don't run any mappings"
42//usage: ) 159//usage: )
43//usage: "\n -v Print out what would happen before doing it" 160//usage: "\n -v Print out what would happen before doing it"
44//usage: "\n -f Force de/configuration" 161//usage: "\n -f Force deconfiguration"
45 162
46#include "libbb.h" 163#include "libbb.h"
47#include "common_bufsiz.h" 164#include "common_bufsiz.h"
@@ -1248,7 +1365,6 @@ static FILE *open_new_state_file(void)
1248 return xfdopen_for_write(fd); 1365 return xfdopen_for_write(fd);
1249} 1366}
1250 1367
1251
1252int ifupdown_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 1368int ifupdown_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
1253int ifupdown_main(int argc UNUSED_PARAM, char **argv) 1369int ifupdown_main(int argc UNUSED_PARAM, char **argv)
1254{ 1370{
@@ -1263,10 +1379,13 @@ int ifupdown_main(int argc UNUSED_PARAM, char **argv)
1263 G.startup_PATH = getenv("PATH"); 1379 G.startup_PATH = getenv("PATH");
1264 G.shell = xstrdup(get_shell_name()); 1380 G.shell = xstrdup(get_shell_name());
1265 1381
1266 cmds = iface_down; 1382 if (ENABLE_IFUP
1267 if (applet_name[2] == 'u') { 1383 && (!ENABLE_IFDOWN || applet_name[2] == 'u')
1384 ) {
1268 /* ifup command */ 1385 /* ifup command */
1269 cmds = iface_up; 1386 cmds = iface_up;
1387 } else {
1388 cmds = iface_down;
1270 } 1389 }
1271 1390
1272 getopt32(argv, OPTION_STR, &interfaces); 1391 getopt32(argv, OPTION_STR, &interfaces);