diff options
author | Ron Yorston <rmy@pobox.com> | 2017-08-22 14:56:12 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2017-08-22 14:56:12 +0100 |
commit | ce9af1cc5ea23f754587448cf35b5120c77bfeef (patch) | |
tree | 69e5eaba5e75ab909ed92d5045393471b8ff3c13 /networking | |
parent | c170026700eabb10147dd848c45c06995b43a32e (diff) | |
parent | e837a0dbbebf4229306df98fe9ee3b9bb30630c4 (diff) | |
download | busybox-w32-ce9af1cc5ea23f754587448cf35b5120c77bfeef.tar.gz busybox-w32-ce9af1cc5ea23f754587448cf35b5120c77bfeef.tar.bz2 busybox-w32-ce9af1cc5ea23f754587448cf35b5120c77bfeef.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'networking')
31 files changed, 243 insertions, 269 deletions
diff --git a/networking/arping.c b/networking/arping.c index 71672957e..f9967d81e 100644 --- a/networking/arping.c +++ b/networking/arping.c | |||
@@ -295,8 +295,8 @@ int arping_main(int argc UNUSED_PARAM, char **argv) | |||
295 | 295 | ||
296 | sock_fd = xsocket(AF_PACKET, SOCK_DGRAM, 0); | 296 | sock_fd = xsocket(AF_PACKET, SOCK_DGRAM, 0); |
297 | 297 | ||
298 | // Drop suid root privileges | 298 | // If you ever change BB_SUID_DROP to BB_SUID_REQUIRE, |
299 | // Need to remove SUID_NEVER from applets.h for this to work | 299 | // drop suid root privileges here: |
300 | //xsetuid(getuid()); | 300 | //xsetuid(getuid()); |
301 | 301 | ||
302 | { | 302 | { |
@@ -306,9 +306,9 @@ int arping_main(int argc UNUSED_PARAM, char **argv) | |||
306 | /* Dad also sets quit_on_reply. | 306 | /* Dad also sets quit_on_reply. |
307 | * Advert also sets unsolicited. | 307 | * Advert also sets unsolicited. |
308 | */ | 308 | */ |
309 | opt_complementary = "=1:Df:AU"; | 309 | opt = getopt32(argv, "^" "DUAqfbc:+w:I:s:" "\0" "=1:Df:AU", |
310 | opt = getopt32(argv, "DUAqfbc:+w:I:s:", | 310 | &count, &str_timeout, &device, &source |
311 | &count, &str_timeout, &device, &source); | 311 | ); |
312 | if (opt & 0x80) /* -w: timeout */ | 312 | if (opt & 0x80) /* -w: timeout */ |
313 | timeout_us = xatou_range(str_timeout, 0, INT_MAX/2000000) * 1000000 + 500000; | 313 | timeout_us = xatou_range(str_timeout, 0, INT_MAX/2000000) * 1000000 + 500000; |
314 | //if (opt & 0x200) /* -s: source */ | 314 | //if (opt & 0x200) /* -s: source */ |
diff --git a/networking/brctl.c b/networking/brctl.c index 690791e4c..5d5f0af30 100644 --- a/networking/brctl.c +++ b/networking/brctl.c | |||
@@ -39,7 +39,7 @@ | |||
39 | //config: Add support for option which prints the current config: | 39 | //config: Add support for option which prints the current config: |
40 | //config: show | 40 | //config: show |
41 | 41 | ||
42 | //applet:IF_BRCTL(APPLET(brctl, BB_DIR_USR_SBIN, BB_SUID_DROP)) | 42 | //applet:IF_BRCTL(APPLET_NOEXEC(brctl, brctl, BB_DIR_USR_SBIN, BB_SUID_DROP, brctl)) |
43 | 43 | ||
44 | //kbuild:lib-$(CONFIG_BRCTL) += brctl.o | 44 | //kbuild:lib-$(CONFIG_BRCTL) += brctl.o |
45 | 45 | ||
diff --git a/networking/ether-wake.c b/networking/ether-wake.c index 52522e76d..6677f07d5 100644 --- a/networking/ether-wake.c +++ b/networking/ether-wake.c | |||
@@ -212,8 +212,7 @@ int ether_wake_main(int argc UNUSED_PARAM, char **argv) | |||
212 | struct whereto_t whereto; /* who to wake up */ | 212 | struct whereto_t whereto; /* who to wake up */ |
213 | 213 | ||
214 | /* handle misc user options */ | 214 | /* handle misc user options */ |
215 | opt_complementary = "=1"; | 215 | flags = getopt32(argv, "^" "bi:p:" "\0" "=1", &ifname, &pass); |
216 | flags = getopt32(argv, "bi:p:", &ifname, &pass); | ||
217 | if (flags & 4) /* -p */ | 216 | if (flags & 4) /* -p */ |
218 | wol_passwd_sz = get_wol_pw(pass, wol_passwd); | 217 | wol_passwd_sz = get_wol_pw(pass, wol_passwd); |
219 | flags &= 1; /* we further interested only in -b [bcast] flag */ | 218 | flags &= 1; /* we further interested only in -b [bcast] flag */ |
diff --git a/networking/ftpd.c b/networking/ftpd.c index c562c2886..8af5acac2 100644 --- a/networking/ftpd.c +++ b/networking/ftpd.c | |||
@@ -1174,17 +1174,20 @@ int ftpd_main(int argc UNUSED_PARAM, char **argv) | |||
1174 | abs_timeout = 1 * 60 * 60; | 1174 | abs_timeout = 1 * 60 * 60; |
1175 | verbose_S = 0; | 1175 | verbose_S = 0; |
1176 | G.timeout = 2 * 60; | 1176 | G.timeout = 2 * 60; |
1177 | opt_complementary = "vv:SS"; | ||
1178 | #if BB_MMU | 1177 | #if BB_MMU |
1179 | opts = getopt32(argv, "vS" | 1178 | opts = getopt32(argv, "^" "vS" |
1180 | IF_FEATURE_FTPD_WRITE("w") "t:+T:+" IF_FEATURE_FTPD_AUTHENTICATION("a:"), | 1179 | IF_FEATURE_FTPD_WRITE("w") "t:+T:+" IF_FEATURE_FTPD_AUTHENTICATION("a:") |
1180 | "\0" "vv:SS", | ||
1181 | &G.timeout, &abs_timeout, IF_FEATURE_FTPD_AUTHENTICATION(&anon_opt,) | 1181 | &G.timeout, &abs_timeout, IF_FEATURE_FTPD_AUTHENTICATION(&anon_opt,) |
1182 | &G.verbose, &verbose_S); | 1182 | &G.verbose, &verbose_S |
1183 | ); | ||
1183 | #else | 1184 | #else |
1184 | opts = getopt32(argv, "l1AvS" | 1185 | opts = getopt32(argv, "^" "l1AvS" |
1185 | IF_FEATURE_FTPD_WRITE("w") "t:+T:+" IF_FEATURE_FTPD_AUTHENTICATION("a:"), | 1186 | IF_FEATURE_FTPD_WRITE("w") "t:+T:+" IF_FEATURE_FTPD_AUTHENTICATION("a:") |
1187 | "\0" "vv:SS", | ||
1186 | &G.timeout, &abs_timeout, IF_FEATURE_FTPD_AUTHENTICATION(&anon_opt,) | 1188 | &G.timeout, &abs_timeout, IF_FEATURE_FTPD_AUTHENTICATION(&anon_opt,) |
1187 | &G.verbose, &verbose_S); | 1189 | &G.verbose, &verbose_S |
1190 | ); | ||
1188 | if (opts & (OPT_l|OPT_1)) { | 1191 | if (opts & (OPT_l|OPT_1)) { |
1189 | /* Our secret backdoor to ls */ | 1192 | /* Our secret backdoor to ls */ |
1190 | if (fchdir(3) != 0) | 1193 | if (fchdir(3) != 0) |
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index cb0a96b59..029587aa2 100644 --- a/networking/ftpgetput.c +++ b/networking/ftpgetput.c | |||
@@ -39,37 +39,20 @@ | |||
39 | //usage: "[OPTIONS] HOST [LOCAL_FILE] REMOTE_FILE" | 39 | //usage: "[OPTIONS] HOST [LOCAL_FILE] REMOTE_FILE" |
40 | //usage:#define ftpget_full_usage "\n\n" | 40 | //usage:#define ftpget_full_usage "\n\n" |
41 | //usage: "Download a file via FTP\n" | 41 | //usage: "Download a file via FTP\n" |
42 | //usage: IF_FEATURE_FTPGETPUT_LONG_OPTIONS( | ||
43 | //usage: "\n -c,--continue Continue previous transfer" | ||
44 | //usage: "\n -v,--verbose Verbose" | ||
45 | //usage: "\n -u,--username USER Username" | ||
46 | //usage: "\n -p,--password PASS Password" | ||
47 | //usage: "\n -P,--port NUM Port" | ||
48 | //usage: ) | ||
49 | //usage: IF_NOT_FEATURE_FTPGETPUT_LONG_OPTIONS( | ||
50 | //usage: "\n -c Continue previous transfer" | 42 | //usage: "\n -c Continue previous transfer" |
51 | //usage: "\n -v Verbose" | 43 | //usage: "\n -v Verbose" |
52 | //usage: "\n -u USER Username" | 44 | //usage: "\n -u USER Username" |
53 | //usage: "\n -p PASS Password" | 45 | //usage: "\n -p PASS Password" |
54 | //usage: "\n -P NUM Port" | 46 | //usage: "\n -P NUM Port" |
55 | //usage: ) | ||
56 | //usage: | 47 | //usage: |
57 | //usage:#define ftpput_trivial_usage | 48 | //usage:#define ftpput_trivial_usage |
58 | //usage: "[OPTIONS] HOST [REMOTE_FILE] LOCAL_FILE" | 49 | //usage: "[OPTIONS] HOST [REMOTE_FILE] LOCAL_FILE" |
59 | //usage:#define ftpput_full_usage "\n\n" | 50 | //usage:#define ftpput_full_usage "\n\n" |
60 | //usage: "Upload a file to a FTP server\n" | 51 | //usage: "Upload a file to a FTP server\n" |
61 | //usage: IF_FEATURE_FTPGETPUT_LONG_OPTIONS( | ||
62 | //usage: "\n -v,--verbose Verbose" | ||
63 | //usage: "\n -u,--username USER Username" | ||
64 | //usage: "\n -p,--password PASS Password" | ||
65 | //usage: "\n -P,--port NUM Port" | ||
66 | //usage: ) | ||
67 | //usage: IF_NOT_FEATURE_FTPGETPUT_LONG_OPTIONS( | ||
68 | //usage: "\n -v Verbose" | 52 | //usage: "\n -v Verbose" |
69 | //usage: "\n -u USER Username" | 53 | //usage: "\n -u USER Username" |
70 | //usage: "\n -p PASS Password" | 54 | //usage: "\n -p PASS Password" |
71 | //usage: "\n -P NUM Port number" | 55 | //usage: "\n -P NUM Port number" |
72 | //usage: ) | ||
73 | 56 | ||
74 | #include "libbb.h" | 57 | #include "libbb.h" |
75 | #include "common_bufsiz.h" | 58 | #include "common_bufsiz.h" |
@@ -367,12 +350,15 @@ int ftpgetput_main(int argc UNUSED_PARAM, char **argv) | |||
367 | /* | 350 | /* |
368 | * Decipher the command line | 351 | * Decipher the command line |
369 | */ | 352 | */ |
353 | /* must have 2 to 3 params; -v and -c count */ | ||
354 | #define OPTSTRING "^cvu:p:P:" "\0" "-2:?3:vv:cc" | ||
370 | #if ENABLE_FEATURE_FTPGETPUT_LONG_OPTIONS | 355 | #if ENABLE_FEATURE_FTPGETPUT_LONG_OPTIONS |
371 | applet_long_options = ftpgetput_longopts; | 356 | getopt32long(argv, OPTSTRING, ftpgetput_longopts, |
357 | #else | ||
358 | getopt32(argv, OPTSTRING, | ||
372 | #endif | 359 | #endif |
373 | opt_complementary = "-2:vv:cc"; /* must have 2 to 3 params; -v and -c count */ | 360 | &user, &password, &port, &verbose_flag, &do_continue |
374 | getopt32(argv, "cvu:p:P:", &user, &password, &port, | 361 | ); |
375 | &verbose_flag, &do_continue); | ||
376 | argv += optind; | 362 | argv += optind; |
377 | 363 | ||
378 | /* We want to do exactly _one_ DNS lookup, since some | 364 | /* We want to do exactly _one_ DNS lookup, since some |
diff --git a/networking/hostname.c b/networking/hostname.c index 4b305d2b6..d87f6562f 100644 --- a/networking/hostname.c +++ b/networking/hostname.c | |||
@@ -22,9 +22,9 @@ | |||
22 | //config: help | 22 | //config: help |
23 | //config: Alias to "hostname -d". | 23 | //config: Alias to "hostname -d". |
24 | 24 | ||
25 | // APPLET_ODDNAME:name main location suid_type help | 25 | // APPLET_NOEXEC:name main location suid_type help |
26 | //applet:IF_DNSDOMAINNAME(APPLET_ODDNAME(dnsdomainname, hostname, BB_DIR_BIN, BB_SUID_DROP, dnsdomainname)) | 26 | //applet:IF_DNSDOMAINNAME(APPLET_NOEXEC(dnsdomainname, hostname, BB_DIR_BIN, BB_SUID_DROP, dnsdomainname)) |
27 | //applet:IF_HOSTNAME(APPLET(hostname, BB_DIR_BIN, BB_SUID_DROP)) | 27 | //applet:IF_HOSTNAME( APPLET_NOEXEC(hostname, hostname, BB_DIR_BIN, BB_SUID_DROP, hostname )) |
28 | 28 | ||
29 | //kbuild: lib-$(CONFIG_HOSTNAME) += hostname.o | 29 | //kbuild: lib-$(CONFIG_HOSTNAME) += hostname.o |
30 | //kbuild: lib-$(CONFIG_DNSDOMAINNAME) += hostname.o | 30 | //kbuild: lib-$(CONFIG_DNSDOMAINNAME) += hostname.o |
@@ -114,7 +114,7 @@ static void do_sethostname(char *s, int isfile) | |||
114 | * { bbox: not supported } | 114 | * { bbox: not supported } |
115 | * -F, --file filename | 115 | * -F, --file filename |
116 | * Read the host name from the specified file. Comments (lines | 116 | * Read the host name from the specified file. Comments (lines |
117 | * starting with a `#') are ignored. | 117 | * starting with a '#') are ignored. |
118 | */ | 118 | */ |
119 | int hostname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 119 | int hostname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
120 | int hostname_main(int argc UNUSED_PARAM, char **argv) | 120 | int hostname_main(int argc UNUSED_PARAM, char **argv) |
@@ -132,8 +132,9 @@ int hostname_main(int argc UNUSED_PARAM, char **argv) | |||
132 | char *buf; | 132 | char *buf; |
133 | char *hostname_str; | 133 | char *hostname_str; |
134 | 134 | ||
135 | #if ENABLE_LONG_OPTS | 135 | /* dnsdomainname from net-tools 1.60, hostname 1.100 (2001-04-14), |
136 | applet_long_options = | 136 | * supports hostname's options too (not just -v as manpage says) */ |
137 | opts = getopt32(argv, "dfisF:v", &hostname_str, | ||
137 | "domain\0" No_argument "d" | 138 | "domain\0" No_argument "d" |
138 | "fqdn\0" No_argument "f" | 139 | "fqdn\0" No_argument "f" |
139 | //Enable if seen in active use in some distro: | 140 | //Enable if seen in active use in some distro: |
@@ -142,12 +143,7 @@ int hostname_main(int argc UNUSED_PARAM, char **argv) | |||
142 | // "short\0" No_argument "s" | 143 | // "short\0" No_argument "s" |
143 | // "verbose\0" No_argument "v" | 144 | // "verbose\0" No_argument "v" |
144 | "file\0" No_argument "F" | 145 | "file\0" No_argument "F" |
145 | ; | 146 | ); |
146 | |||
147 | #endif | ||
148 | /* dnsdomainname from net-tools 1.60, hostname 1.100 (2001-04-14), | ||
149 | * supports hostname's options too (not just -v as manpage says) */ | ||
150 | opts = getopt32(argv, "dfisF:v", &hostname_str); | ||
151 | argv += optind; | 147 | argv += optind; |
152 | buf = safe_gethostname(); | 148 | buf = safe_gethostname(); |
153 | if (ENABLE_DNSDOMAINNAME) { | 149 | if (ENABLE_DNSDOMAINNAME) { |
diff --git a/networking/httpd.c b/networking/httpd.c index 079145757..9369de824 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -2636,17 +2636,19 @@ int httpd_main(int argc UNUSED_PARAM, char **argv) | |||
2636 | #endif | 2636 | #endif |
2637 | 2637 | ||
2638 | home_httpd = xrealloc_getcwd_or_warn(NULL); | 2638 | home_httpd = xrealloc_getcwd_or_warn(NULL); |
2639 | /* -v counts, -i implies -f */ | ||
2640 | opt_complementary = "vv:if"; | ||
2641 | /* We do not "absolutize" path given by -h (home) opt. | 2639 | /* We do not "absolutize" path given by -h (home) opt. |
2642 | * If user gives relative path in -h, | 2640 | * If user gives relative path in -h, |
2643 | * $SCRIPT_FILENAME will not be set. */ | 2641 | * $SCRIPT_FILENAME will not be set. */ |
2644 | opt = getopt32(argv, "c:d:h:" | 2642 | opt = getopt32(argv, "^" |
2643 | "c:d:h:" | ||
2645 | IF_FEATURE_HTTPD_ENCODE_URL_STR("e:") | 2644 | IF_FEATURE_HTTPD_ENCODE_URL_STR("e:") |
2646 | IF_FEATURE_HTTPD_BASIC_AUTH("r:") | 2645 | IF_FEATURE_HTTPD_BASIC_AUTH("r:") |
2647 | IF_FEATURE_HTTPD_AUTH_MD5("m:") | 2646 | IF_FEATURE_HTTPD_AUTH_MD5("m:") |
2648 | IF_FEATURE_HTTPD_SETUID("u:") | 2647 | IF_FEATURE_HTTPD_SETUID("u:") |
2649 | "p:ifv", | 2648 | "p:ifv" |
2649 | "\0" | ||
2650 | /* -v counts, -i implies -f */ | ||
2651 | "vv:if", | ||
2650 | &opt_c_configFile, &url_for_decode, &home_httpd | 2652 | &opt_c_configFile, &url_for_decode, &home_httpd |
2651 | IF_FEATURE_HTTPD_ENCODE_URL_STR(, &url_for_encode) | 2653 | IF_FEATURE_HTTPD_ENCODE_URL_STR(, &url_for_encode) |
2652 | IF_FEATURE_HTTPD_BASIC_AUTH(, &g_realm) | 2654 | IF_FEATURE_HTTPD_BASIC_AUTH(, &g_realm) |
diff --git a/networking/ifenslave.c b/networking/ifenslave.c index 26e5e8cf3..5e769b61d 100644 --- a/networking/ifenslave.c +++ b/networking/ifenslave.c | |||
@@ -105,7 +105,7 @@ | |||
105 | //config: Userspace application to bind several interfaces | 105 | //config: Userspace application to bind several interfaces |
106 | //config: to a logical interface (use with kernel bonding driver). | 106 | //config: to a logical interface (use with kernel bonding driver). |
107 | 107 | ||
108 | //applet:IF_IFENSLAVE(APPLET(ifenslave, BB_DIR_SBIN, BB_SUID_DROP)) | 108 | //applet:IF_IFENSLAVE(APPLET_NOEXEC(ifenslave, ifenslave, BB_DIR_SBIN, BB_SUID_DROP, ifenslave)) |
109 | 109 | ||
110 | //kbuild:lib-$(CONFIG_IFENSLAVE) += ifenslave.o interface.o | 110 | //kbuild:lib-$(CONFIG_IFENSLAVE) += ifenslave.o interface.o |
111 | 111 | ||
@@ -113,10 +113,10 @@ | |||
113 | //usage: "[-cdf] MASTER_IFACE SLAVE_IFACE..." | 113 | //usage: "[-cdf] MASTER_IFACE SLAVE_IFACE..." |
114 | //usage:#define ifenslave_full_usage "\n\n" | 114 | //usage:#define ifenslave_full_usage "\n\n" |
115 | //usage: "Configure network interfaces for parallel routing\n" | 115 | //usage: "Configure network interfaces for parallel routing\n" |
116 | //usage: "\n -c,--change-active Change active slave" | 116 | //usage: "\n -c Change active slave" |
117 | //usage: "\n -d,--detach Remove slave interface from bonding device" | 117 | //usage: "\n -d Remove slave interface from bonding device" |
118 | //usage: "\n -f,--force Force, even if interface is not Ethernet" | 118 | //usage: "\n -f Force, even if interface is not Ethernet" |
119 | /* //usage: "\n -r,--receive-slave Create a receive-only slave" */ | 119 | /* //usage: "\n -r Create a receive-only slave" */ |
120 | //usage: | 120 | //usage: |
121 | //usage:#define ifenslave_example_usage | 121 | //usage:#define ifenslave_example_usage |
122 | //usage: "To create a bond device, simply follow these three steps:\n" | 122 | //usage: "To create a bond device, simply follow these three steps:\n" |
@@ -493,19 +493,15 @@ int ifenslave_main(int argc UNUSED_PARAM, char **argv) | |||
493 | OPT_d = (1 << 1), | 493 | OPT_d = (1 << 1), |
494 | OPT_f = (1 << 2), | 494 | OPT_f = (1 << 2), |
495 | }; | 495 | }; |
496 | #if ENABLE_LONG_OPTS | 496 | |
497 | static const char ifenslave_longopts[] ALIGN1 = | 497 | INIT_G(); |
498 | |||
499 | opt = getopt32long(argv, "cdfa", | ||
498 | "change-active\0" No_argument "c" | 500 | "change-active\0" No_argument "c" |
499 | "detach\0" No_argument "d" | 501 | "detach\0" No_argument "d" |
500 | "force\0" No_argument "f" | 502 | "force\0" No_argument "f" |
501 | /* "all-interfaces\0" No_argument "a" */ | 503 | /* "all-interfaces\0" No_argument "a" */ |
502 | ; | 504 | ); |
503 | |||
504 | applet_long_options = ifenslave_longopts; | ||
505 | #endif | ||
506 | INIT_G(); | ||
507 | |||
508 | opt = getopt32(argv, "cdfa"); | ||
509 | argv += optind; | 505 | argv += optind; |
510 | if (opt & (opt-1)) /* Only one option can be given */ | 506 | if (opt & (opt-1)) /* Only one option can be given */ |
511 | bb_show_usage(); | 507 | bb_show_usage(); |
diff --git a/networking/inetd.c b/networking/inetd.c index 91545d0a3..67984accb 100644 --- a/networking/inetd.c +++ b/networking/inetd.c | |||
@@ -217,7 +217,6 @@ | |||
217 | //config: bool "Support RPC services" | 217 | //config: bool "Support RPC services" |
218 | //config: default n # very rarely used, and needs Sun RPC support in libc | 218 | //config: default n # very rarely used, and needs Sun RPC support in libc |
219 | //config: depends on INETD | 219 | //config: depends on INETD |
220 | //config: select FEATURE_HAVE_RPC | ||
221 | //config: help | 220 | //config: help |
222 | //config: Support Sun-RPC based services | 221 | //config: Support Sun-RPC based services |
223 | 222 | ||
diff --git a/networking/ipcalc.c b/networking/ipcalc.c index 9888a6ff2..cdae8eea8 100644 --- a/networking/ipcalc.c +++ b/networking/ipcalc.c | |||
@@ -31,7 +31,7 @@ | |||
31 | //config: Adds the options hostname, prefix and silent to the output of | 31 | //config: Adds the options hostname, prefix and silent to the output of |
32 | //config: "ipcalc". | 32 | //config: "ipcalc". |
33 | 33 | ||
34 | //applet:IF_IPCALC(APPLET(ipcalc, BB_DIR_BIN, BB_SUID_DROP)) | 34 | //applet:IF_IPCALC(APPLET_NOEXEC(ipcalc, ipcalc, BB_DIR_BIN, BB_SUID_DROP, ipcalc)) |
35 | 35 | ||
36 | //kbuild:lib-$(CONFIG_IPCALC) += ipcalc.o | 36 | //kbuild:lib-$(CONFIG_IPCALC) += ipcalc.o |
37 | 37 | ||
@@ -39,26 +39,14 @@ | |||
39 | //usage: "[OPTIONS] ADDRESS" | 39 | //usage: "[OPTIONS] ADDRESS" |
40 | //usage: IF_FEATURE_IPCALC_FANCY("[/PREFIX]") " [NETMASK]" | 40 | //usage: IF_FEATURE_IPCALC_FANCY("[/PREFIX]") " [NETMASK]" |
41 | //usage:#define ipcalc_full_usage "\n\n" | 41 | //usage:#define ipcalc_full_usage "\n\n" |
42 | //usage: "Calculate IP network settings from a IP address\n" | 42 | //usage: "Calculate and display network settings from IP address\n" |
43 | //usage: IF_FEATURE_IPCALC_LONG_OPTIONS( | 43 | //usage: "\n -b Broadcast address" |
44 | //usage: "\n -b,--broadcast Display calculated broadcast address" | 44 | //usage: "\n -n Network address" |
45 | //usage: "\n -n,--network Display calculated network address" | 45 | //usage: "\n -m Default netmask for IP" |
46 | //usage: "\n -m,--netmask Display default netmask for IP" | ||
47 | //usage: IF_FEATURE_IPCALC_FANCY( | 46 | //usage: IF_FEATURE_IPCALC_FANCY( |
48 | //usage: "\n -p,--prefix Display the prefix for IP/NETMASK" | 47 | //usage: "\n -p Prefix for IP/NETMASK" |
49 | //usage: "\n -h,--hostname Display first resolved host name" | 48 | //usage: "\n -h Resolved host name" |
50 | //usage: "\n -s,--silent Don't ever display error messages" | 49 | //usage: "\n -s No error messages" |
51 | //usage: ) | ||
52 | //usage: ) | ||
53 | //usage: IF_NOT_FEATURE_IPCALC_LONG_OPTIONS( | ||
54 | //usage: "\n -b Display calculated broadcast address" | ||
55 | //usage: "\n -n Display calculated network address" | ||
56 | //usage: "\n -m Display default netmask for IP" | ||
57 | //usage: IF_FEATURE_IPCALC_FANCY( | ||
58 | //usage: "\n -p Display the prefix for IP/NETMASK" | ||
59 | //usage: "\n -h Display first resolved host name" | ||
60 | //usage: "\n -s Don't ever display error messages" | ||
61 | //usage: ) | ||
62 | //usage: ) | 50 | //usage: ) |
63 | 51 | ||
64 | #include "libbb.h" | 52 | #include "libbb.h" |
@@ -120,6 +108,11 @@ int get_prefix(unsigned long netmask); | |||
120 | "silent\0" No_argument "s" // don’t ever display error messages | 108 | "silent\0" No_argument "s" // don’t ever display error messages |
121 | # endif | 109 | # endif |
122 | ; | 110 | ; |
111 | # define GETOPT32 getopt32long | ||
112 | # define LONGOPTS ,ipcalc_longopts | ||
113 | #else | ||
114 | # define GETOPT32 getopt32 | ||
115 | # define LONGOPTS | ||
123 | #endif | 116 | #endif |
124 | 117 | ||
125 | int ipcalc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 118 | int ipcalc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
@@ -137,11 +130,11 @@ int ipcalc_main(int argc UNUSED_PARAM, char **argv) | |||
137 | #define ipaddr (s_ipaddr.s_addr) | 130 | #define ipaddr (s_ipaddr.s_addr) |
138 | char *ipstr; | 131 | char *ipstr; |
139 | 132 | ||
140 | #if ENABLE_FEATURE_IPCALC_LONG_OPTIONS | 133 | opt = GETOPT32(argv, "^" |
141 | applet_long_options = ipcalc_longopts; | 134 | "mbn" IF_FEATURE_IPCALC_FANCY("phs") |
142 | #endif | 135 | "\0" "-1:?2"/*min 1, max 2 args*/ |
143 | opt_complementary = "-1:?2"; /* minimum 1 arg, maximum 2 args */ | 136 | LONGOPTS |
144 | opt = getopt32(argv, "mbn" IF_FEATURE_IPCALC_FANCY("phs")); | 137 | ); |
145 | argv += optind; | 138 | argv += optind; |
146 | if (opt & SILENT) | 139 | if (opt & SILENT) |
147 | logmode = LOGMODE_NONE; /* suppress error_msg() output */ | 140 | logmode = LOGMODE_NONE; /* suppress error_msg() output */ |
diff --git a/networking/nameif.c b/networking/nameif.c index 31ee98a39..1f2695495 100644 --- a/networking/nameif.c +++ b/networking/nameif.c | |||
@@ -40,7 +40,7 @@ | |||
40 | //config: new_interface_name mac=00:80:C8:38:91:B5 | 40 | //config: new_interface_name mac=00:80:C8:38:91:B5 |
41 | //config: new_interface_name 00:80:C8:38:91:B5 | 41 | //config: new_interface_name 00:80:C8:38:91:B5 |
42 | 42 | ||
43 | //applet:IF_NAMEIF(APPLET(nameif, BB_DIR_SBIN, BB_SUID_DROP)) | 43 | //applet:IF_NAMEIF(APPLET_NOEXEC(nameif, nameif, BB_DIR_SBIN, BB_SUID_DROP, nameif)) |
44 | 44 | ||
45 | //kbuild:lib-$(CONFIG_NAMEIF) += nameif.o | 45 | //kbuild:lib-$(CONFIG_NAMEIF) += nameif.o |
46 | 46 | ||
diff --git a/networking/nbd-client.c b/networking/nbd-client.c index a5e25e6aa..cf1857231 100644 --- a/networking/nbd-client.c +++ b/networking/nbd-client.c | |||
@@ -7,7 +7,7 @@ | |||
7 | #include <netinet/tcp.h> | 7 | #include <netinet/tcp.h> |
8 | #include <linux/fs.h> | 8 | #include <linux/fs.h> |
9 | 9 | ||
10 | //applet:IF_NBDCLIENT(APPLET_ODDNAME(nbd-client, nbdclient, BB_DIR_USR_SBIN, BB_SUID_DROP, nbdclient)) | 10 | //applet:IF_NBDCLIENT(APPLET_NOEXEC(nbd-client, nbdclient, BB_DIR_USR_SBIN, BB_SUID_DROP, nbdclient)) |
11 | 11 | ||
12 | //kbuild:lib-$(CONFIG_NBDCLIENT) += nbd-client.o | 12 | //kbuild:lib-$(CONFIG_NBDCLIENT) += nbd-client.o |
13 | 13 | ||
@@ -43,7 +43,7 @@ | |||
43 | //blocksizes other than 1024 without patches | 43 | //blocksizes other than 1024 without patches |
44 | 44 | ||
45 | int nbdclient_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 45 | int nbdclient_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
46 | int nbdclient_main(int argc, char **argv) | 46 | int nbdclient_main(int argc UNUSED_PARAM, char **argv) |
47 | { | 47 | { |
48 | unsigned long timeout = 0; | 48 | unsigned long timeout = 0; |
49 | #if BB_MMU | 49 | #if BB_MMU |
@@ -61,7 +61,7 @@ int nbdclient_main(int argc, char **argv) | |||
61 | BUILD_BUG_ON(offsetof(struct nbd_header_t, data) != 8+8+8+4); | 61 | BUILD_BUG_ON(offsetof(struct nbd_header_t, data) != 8+8+8+4); |
62 | 62 | ||
63 | // Parse command line stuff (just a stub now) | 63 | // Parse command line stuff (just a stub now) |
64 | if (argc != 4) | 64 | if (!argv[1] || !argv[2] || !argv[3] || argv[4]) |
65 | bb_show_usage(); | 65 | bb_show_usage(); |
66 | 66 | ||
67 | #if !BB_MMU | 67 | #if !BB_MMU |
diff --git a/networking/nc_bloaty.c b/networking/nc_bloaty.c index 3db784982..64098648a 100644 --- a/networking/nc_bloaty.c +++ b/networking/nc_bloaty.c | |||
@@ -787,11 +787,15 @@ int nc_main(int argc UNUSED_PARAM, char **argv) | |||
787 | e_found: | 787 | e_found: |
788 | 788 | ||
789 | // -g -G -t -r deleted, unimplemented -a deleted too | 789 | // -g -G -t -r deleted, unimplemented -a deleted too |
790 | opt_complementary = "?2:vv:ll"; /* max 2 params; -v and -l are counters; -w N */ | 790 | getopt32(argv, "^" |
791 | getopt32(argv, "np:s:uvw:+" IF_NC_SERVER("lk") | 791 | "np:s:uvw:+"/* -w N */ IF_NC_SERVER("lk") |
792 | IF_NC_EXTRA("i:o:z"), | 792 | IF_NC_EXTRA("i:o:z") |
793 | &str_p, &str_s, &o_wait | 793 | "\0" |
794 | IF_NC_EXTRA(, &str_i, &str_o), &o_verbose IF_NC_SERVER(, &cnt_l)); | 794 | "?2:vv:ll", /* max 2 params; -v and -l are counters */ |
795 | &str_p, &str_s, &o_wait | ||
796 | IF_NC_EXTRA(, &str_i, &str_o) | ||
797 | , &o_verbose IF_NC_SERVER(, &cnt_l) | ||
798 | ); | ||
795 | argv += optind; | 799 | argv += optind; |
796 | #if ENABLE_NC_EXTRA | 800 | #if ENABLE_NC_EXTRA |
797 | if (option_mask32 & OPT_i) /* line-interval time */ | 801 | if (option_mask32 & OPT_i) /* line-interval time */ |
diff --git a/networking/ntpd.c b/networking/ntpd.c index f21f9513d..25fa44389 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c | |||
@@ -2230,15 +2230,16 @@ static NOINLINE void ntp_init(char **argv) | |||
2230 | 2230 | ||
2231 | /* Parse options */ | 2231 | /* Parse options */ |
2232 | peers = NULL; | 2232 | peers = NULL; |
2233 | opt_complementary = "dd:wn" /* -d: counter; -p: list; -w implies -n */ | 2233 | opts = getopt32(argv, "^" |
2234 | IF_FEATURE_NTPD_SERVER(":Il"); /* -I implies -l */ | ||
2235 | opts = getopt32(argv, | ||
2236 | "nqNx" /* compat */ | 2234 | "nqNx" /* compat */ |
2237 | "wp:*S:"IF_FEATURE_NTPD_SERVER("l") /* NOT compat */ | 2235 | "wp:*S:"IF_FEATURE_NTPD_SERVER("l") /* NOT compat */ |
2238 | IF_FEATURE_NTPD_SERVER("I:") /* compat */ | 2236 | IF_FEATURE_NTPD_SERVER("I:") /* compat */ |
2239 | "d" /* compat */ | 2237 | "d" /* compat */ |
2240 | "46aAbgL", /* compat, ignored */ | 2238 | "46aAbgL", /* compat, ignored */ |
2241 | &peers, &G.script_name, | 2239 | "\0" |
2240 | "dd:wn" /* -d: counter; -p: list; -w implies -n */ | ||
2241 | IF_FEATURE_NTPD_SERVER(":Il") /* -I implies -l */ | ||
2242 | , &peers, &G.script_name, | ||
2242 | #if ENABLE_FEATURE_NTPD_SERVER | 2243 | #if ENABLE_FEATURE_NTPD_SERVER |
2243 | &G.if_name, | 2244 | &G.if_name, |
2244 | #endif | 2245 | #endif |
diff --git a/networking/ping.c b/networking/ping.c index 506e7b11b..7460e4414 100644 --- a/networking/ping.c +++ b/networking/ping.c | |||
@@ -340,7 +340,8 @@ static int common_ping_main(sa_family_t af, char **argv) | |||
340 | 340 | ||
341 | /* Full(er) version */ | 341 | /* Full(er) version */ |
342 | 342 | ||
343 | #define OPT_STRING ("qvc:+s:t:+w:+W:+I:np:4" IF_PING6("6")) | 343 | /* -c NUM, -t NUM, -w NUM, -W NUM */ |
344 | #define OPT_STRING "qvc:+s:t:+w:+W:+I:np:4"IF_PING6("6") | ||
344 | enum { | 345 | enum { |
345 | OPT_QUIET = 1 << 0, | 346 | OPT_QUIET = 1 << 0, |
346 | OPT_VERBOSE = 1 << 1, | 347 | OPT_VERBOSE = 1 << 1, |
@@ -863,9 +864,12 @@ static int common_ping_main(int opt, char **argv) | |||
863 | 864 | ||
864 | INIT_G(); | 865 | INIT_G(); |
865 | 866 | ||
866 | /* exactly one argument needed; -v and -q don't mix; -c NUM, -t NUM, -w NUM, -W NUM */ | 867 | opt |= getopt32(argv, "^" |
867 | opt_complementary = "=1:q--v:v--q"; | 868 | OPT_STRING |
868 | opt |= getopt32(argv, OPT_STRING, &pingcount, &str_s, &opt_ttl, &deadline, &timeout, &str_I, &str_p); | 869 | /* exactly one arg; -v and -q don't mix */ |
870 | "\0" "=1:q--v:v--q", | ||
871 | &pingcount, &str_s, &opt_ttl, &deadline, &timeout, &str_I, &str_p | ||
872 | ); | ||
869 | if (opt & OPT_s) | 873 | if (opt & OPT_s) |
870 | datalen = xatou16(str_s); // -s | 874 | datalen = xatou16(str_s); // -s |
871 | if (opt & OPT_I) { // -I | 875 | if (opt & OPT_I) { // -I |
@@ -953,7 +957,7 @@ int ping6_main(int argc UNUSED_PARAM, char **argv) | |||
953 | * may be used to endorse or promote products derived from this software | 957 | * may be used to endorse or promote products derived from this software |
954 | * without specific prior written permission. | 958 | * without specific prior written permission. |
955 | * | 959 | * |
956 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | 960 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND |
957 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 961 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
958 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 962 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
959 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | 963 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
diff --git a/networking/pscan.c b/networking/pscan.c index 17985d2c8..95b0a937d 100644 --- a/networking/pscan.c +++ b/networking/pscan.c | |||
@@ -75,8 +75,11 @@ int pscan_main(int argc UNUSED_PARAM, char **argv) | |||
75 | unsigned rtt_4; | 75 | unsigned rtt_4; |
76 | unsigned start, diff; | 76 | unsigned start, diff; |
77 | 77 | ||
78 | opt_complementary = "=1"; /* exactly one non-option */ | 78 | opt = getopt32(argv, "^" |
79 | opt = getopt32(argv, "cbp:P:t:T:", &opt_min_port, &opt_max_port, &opt_timeout, &opt_min_rtt); | 79 | "cbp:P:t:T:" |
80 | "\0" "=1", /* exactly one non-option */ | ||
81 | &opt_min_port, &opt_max_port, &opt_timeout, &opt_min_rtt | ||
82 | ); | ||
80 | argv += optind; | 83 | argv += optind; |
81 | max_port = xatou_range(opt_max_port, 1, 65535); | 84 | max_port = xatou_range(opt_max_port, 1, 65535); |
82 | port = xatou_range(opt_min_port, 1, max_port); | 85 | port = xatou_range(opt_min_port, 1, max_port); |
diff --git a/networking/slattach.c b/networking/slattach.c index 71b5bf427..e0a388926 100644 --- a/networking/slattach.c +++ b/networking/slattach.c | |||
@@ -17,23 +17,23 @@ | |||
17 | //config: default y | 17 | //config: default y |
18 | //config: select PLATFORM_LINUX | 18 | //config: select PLATFORM_LINUX |
19 | //config: help | 19 | //config: help |
20 | //config: slattach is a small utility to attach network interfaces to serial | 20 | //config: slattach configures serial line as SLIP network interface. |
21 | //config: lines. | ||
22 | 21 | ||
23 | //applet:IF_SLATTACH(APPLET(slattach, BB_DIR_SBIN, BB_SUID_DROP)) | 22 | //applet:IF_SLATTACH(APPLET(slattach, BB_DIR_SBIN, BB_SUID_DROP)) |
23 | /* shouldn't be NOEXEC: may sleep indefinitely */ | ||
24 | 24 | ||
25 | //kbuild:lib-$(CONFIG_SLATTACH) += slattach.o | 25 | //kbuild:lib-$(CONFIG_SLATTACH) += slattach.o |
26 | 26 | ||
27 | //usage:#define slattach_trivial_usage | 27 | //usage:#define slattach_trivial_usage |
28 | //usage: "[-cehmLF] [-s SPEED] [-p PROTOCOL] DEVICE" | 28 | //usage: "[-ehmLF] [-c SCRIPT] [-s BAUD] [-p PROTOCOL] SERIAL_DEVICE" |
29 | //usage:#define slattach_full_usage "\n\n" | 29 | //usage:#define slattach_full_usage "\n\n" |
30 | //usage: "Attach network interface(s) to serial line(s)\n" | 30 | //usage: "Configure serial line as SLIP network interface\n" |
31 | //usage: "\n -p PROT Set protocol (slip, cslip, slip6, clisp6 or adaptive)" | 31 | //usage: "\n -p PROT Protocol: slip, cslip (default), slip6, clisp6, adaptive" |
32 | //usage: "\n -s SPD Set line speed" | 32 | //usage: "\n -s BAUD Line speed" |
33 | //usage: "\n -e Exit after initializing device" | 33 | //usage: "\n -e Exit after initialization" |
34 | //usage: "\n -h Exit when the carrier is lost" | 34 | //usage: "\n -h Exit if carrier is lost (else never exits)" |
35 | //usage: "\n -c PROG Run PROG when the line is hung up" | 35 | //usage: "\n -c PROG Run PROG on carrier loss" |
36 | //usage: "\n -m Do NOT initialize the line in raw 8 bits mode" | 36 | //usage: "\n -m Do NOT set raw 8bit mode" |
37 | //usage: "\n -L Enable 3-wire operation" | 37 | //usage: "\n -L Enable 3-wire operation" |
38 | //usage: "\n -F Disable RTS/CTS flow control" | 38 | //usage: "\n -F Disable RTS/CTS flow control" |
39 | 39 | ||
@@ -42,103 +42,53 @@ | |||
42 | #include "libiproute/utils.h" /* invarg_1_to_2() */ | 42 | #include "libiproute/utils.h" /* invarg_1_to_2() */ |
43 | 43 | ||
44 | struct globals { | 44 | struct globals { |
45 | int handle; | ||
46 | int saved_disc; | 45 | int saved_disc; |
47 | struct termios saved_state; | 46 | struct termios saved_state; |
48 | } FIX_ALIASING; | 47 | } FIX_ALIASING; |
49 | #define G (*(struct globals*)bb_common_bufsiz1) | 48 | #define G (*(struct globals*)bb_common_bufsiz1) |
50 | #define handle (G.handle ) | ||
51 | #define saved_disc (G.saved_disc ) | ||
52 | #define saved_state (G.saved_state ) | ||
53 | #define INIT_G() do { setup_common_bufsiz(); } while (0) | 49 | #define INIT_G() do { setup_common_bufsiz(); } while (0) |
54 | 50 | ||
51 | #define serial_fd 3 | ||
55 | 52 | ||
56 | /* | 53 | static int tcsetattr_serial_or_warn(struct termios *state) |
57 | * Save tty state and line discipline | ||
58 | * | ||
59 | * It is fine here to bail out on errors, since we haven modified anything yet | ||
60 | */ | ||
61 | static void save_state(void) | ||
62 | { | ||
63 | /* Save line status */ | ||
64 | if (tcgetattr(handle, &saved_state) < 0) | ||
65 | bb_perror_msg_and_die("get state"); | ||
66 | |||
67 | /* Save line discipline */ | ||
68 | xioctl(handle, TIOCGETD, &saved_disc); | ||
69 | } | ||
70 | |||
71 | static int set_termios_state_or_warn(struct termios *state) | ||
72 | { | 54 | { |
73 | int ret; | 55 | int ret; |
74 | 56 | ||
75 | ret = tcsetattr(handle, TCSANOW, state); | 57 | ret = tcsetattr(serial_fd, TCSANOW, state); |
76 | if (ret < 0) { | 58 | if (ret != 0) { |
77 | bb_perror_msg("set state"); | 59 | bb_perror_msg("tcsetattr"); |
78 | return 1; /* used as exitcode */ | 60 | return 1; /* used as exitcode */ |
79 | } | 61 | } |
80 | return 0; | 62 | return ret; /* 0 */ |
81 | } | 63 | } |
82 | 64 | ||
83 | /* | ||
84 | * Restore state and line discipline for ALL managed ttys | ||
85 | * | ||
86 | * Restoring ALL managed ttys is the only way to have a single | ||
87 | * hangup delay. | ||
88 | * | ||
89 | * Go on after errors: we want to restore as many controlled ttys | ||
90 | * as possible. | ||
91 | */ | ||
92 | static void restore_state_and_exit(int exitcode) NORETURN; | 65 | static void restore_state_and_exit(int exitcode) NORETURN; |
93 | static void restore_state_and_exit(int exitcode) | 66 | static void restore_state_and_exit(int exitcode) |
94 | { | 67 | { |
95 | struct termios state; | 68 | struct termios state; |
96 | 69 | ||
97 | /* Restore line discipline */ | 70 | /* Restore line discipline */ |
98 | if (ioctl_or_warn(handle, TIOCSETD, &saved_disc) < 0) { | 71 | if (ioctl_or_warn(serial_fd, TIOCSETD, &G.saved_disc)) { |
99 | exitcode = 1; | 72 | exitcode = 1; |
100 | } | 73 | } |
101 | 74 | ||
102 | /* Hangup */ | 75 | /* Hangup */ |
103 | memcpy(&state, &saved_state, sizeof(state)); | 76 | memcpy(&state, &G.saved_state, sizeof(state)); |
104 | cfsetispeed(&state, B0); | 77 | cfsetispeed(&state, B0); |
105 | cfsetospeed(&state, B0); | 78 | cfsetospeed(&state, B0); |
106 | if (set_termios_state_or_warn(&state)) | 79 | exitcode |= tcsetattr_serial_or_warn(&state); |
107 | exitcode = 1; | ||
108 | sleep(1); | 80 | sleep(1); |
109 | 81 | ||
110 | /* Restore line status */ | 82 | /* Restore line status */ |
111 | if (set_termios_state_or_warn(&saved_state)) | 83 | if (tcsetattr_serial_or_warn(&G.saved_state)) |
112 | exit(EXIT_FAILURE); | 84 | exit(EXIT_FAILURE); |
85 | |||
113 | if (ENABLE_FEATURE_CLEAN_UP) | 86 | if (ENABLE_FEATURE_CLEAN_UP) |
114 | close(handle); | 87 | close(serial_fd); |
115 | 88 | ||
116 | exit(exitcode); | 89 | exit(exitcode); |
117 | } | 90 | } |
118 | 91 | ||
119 | /* | ||
120 | * Set tty state, line discipline and encapsulation | ||
121 | */ | ||
122 | static void set_state(struct termios *state, int encap) | ||
123 | { | ||
124 | int disc; | ||
125 | |||
126 | /* Set line status */ | ||
127 | if (set_termios_state_or_warn(state)) | ||
128 | goto bad; | ||
129 | /* Set line discliple (N_SLIP always) */ | ||
130 | disc = N_SLIP; | ||
131 | if (ioctl_or_warn(handle, TIOCSETD, &disc) < 0) { | ||
132 | goto bad; | ||
133 | } | ||
134 | |||
135 | /* Set encapsulation (SLIP, CSLIP, etc) */ | ||
136 | if (ioctl_or_warn(handle, SIOCSIFENCAP, &encap) < 0) { | ||
137 | bad: | ||
138 | restore_state_and_exit(EXIT_FAILURE); | ||
139 | } | ||
140 | } | ||
141 | |||
142 | static void sig_handler(int signo UNUSED_PARAM) | 92 | static void sig_handler(int signo UNUSED_PARAM) |
143 | { | 93 | { |
144 | restore_state_and_exit(EXIT_SUCCESS); | 94 | restore_state_and_exit(EXIT_SUCCESS); |
@@ -155,13 +105,14 @@ int slattach_main(int argc UNUSED_PARAM, char **argv) | |||
155 | "cslip6\0" /* 3 */ | 105 | "cslip6\0" /* 3 */ |
156 | "adaptive\0" /* 8 */ | 106 | "adaptive\0" /* 8 */ |
157 | ; | 107 | ; |
108 | static const int int_N_SLIP = N_SLIP; | ||
158 | 109 | ||
159 | int i, encap, opt; | 110 | int encap, opt, fd; |
160 | struct termios state; | 111 | struct termios state; |
161 | const char *proto = "cslip"; | 112 | const char *proto = "cslip"; |
162 | const char *extcmd; /* Command to execute after hangup */ | 113 | const char *extcmd; /* Command to execute after hangup */ |
163 | const char *baud_str; | 114 | const char *baud_str; |
164 | int baud_code = -1; /* Line baud rate (system code) */ | 115 | int baud_code = baud_code; /* for compiler */ |
165 | 116 | ||
166 | enum { | 117 | enum { |
167 | OPT_p_proto = 1 << 0, | 118 | OPT_p_proto = 1 << 0, |
@@ -177,15 +128,13 @@ int slattach_main(int argc UNUSED_PARAM, char **argv) | |||
177 | INIT_G(); | 128 | INIT_G(); |
178 | 129 | ||
179 | /* Parse command line options */ | 130 | /* Parse command line options */ |
180 | opt = getopt32(argv, "p:s:c:ehmLF", &proto, &baud_str, &extcmd); | 131 | opt = getopt32(argv, "^" "p:s:c:ehmLF" "\0" "=1", |
132 | &proto, &baud_str, &extcmd | ||
133 | ); | ||
181 | /*argc -= optind;*/ | 134 | /*argc -= optind;*/ |
182 | argv += optind; | 135 | argv += optind; |
183 | 136 | ||
184 | if (!*argv) | ||
185 | bb_show_usage(); | ||
186 | |||
187 | encap = index_in_strings(proto_names, proto); | 137 | encap = index_in_strings(proto_names, proto); |
188 | |||
189 | if (encap < 0) | 138 | if (encap < 0) |
190 | invarg_1_to_2(proto, "protocol"); | 139 | invarg_1_to_2(proto, "protocol"); |
191 | if (encap > 3) | 140 | if (encap > 3) |
@@ -198,6 +147,22 @@ int slattach_main(int argc UNUSED_PARAM, char **argv) | |||
198 | invarg_1_to_2(baud_str, "baud rate"); | 147 | invarg_1_to_2(baud_str, "baud rate"); |
199 | } | 148 | } |
200 | 149 | ||
150 | /* Open tty */ | ||
151 | fd = open(*argv, O_RDWR | O_NDELAY); | ||
152 | if (fd < 0) { | ||
153 | char *buf = concat_path_file("/dev", *argv); | ||
154 | fd = xopen(buf, O_RDWR | O_NDELAY); | ||
155 | /* maybe if (ENABLE_FEATURE_CLEAN_UP) ?? */ | ||
156 | free(buf); | ||
157 | } | ||
158 | xmove_fd(fd, serial_fd); | ||
159 | |||
160 | /* Save current tty state */ | ||
161 | if (tcgetattr(serial_fd, &G.saved_state) != 0) | ||
162 | bb_perror_msg_and_die("tcgetattr"); | ||
163 | /* Save line discipline */ | ||
164 | xioctl(serial_fd, TIOCGETD, &G.saved_disc); | ||
165 | |||
201 | /* Trap signals in order to restore tty states upon exit */ | 166 | /* Trap signals in order to restore tty states upon exit */ |
202 | if (!(opt & OPT_e_quit)) { | 167 | if (!(opt & OPT_e_quit)) { |
203 | bb_signals(0 | 168 | bb_signals(0 |
@@ -208,43 +173,37 @@ int slattach_main(int argc UNUSED_PARAM, char **argv) | |||
208 | , sig_handler); | 173 | , sig_handler); |
209 | } | 174 | } |
210 | 175 | ||
211 | /* Open tty */ | ||
212 | handle = open(*argv, O_RDWR | O_NDELAY); | ||
213 | if (handle < 0) { | ||
214 | char *buf = concat_path_file("/dev", *argv); | ||
215 | handle = xopen(buf, O_RDWR | O_NDELAY); | ||
216 | /* maybe if (ENABLE_FEATURE_CLEAN_UP) ?? */ | ||
217 | free(buf); | ||
218 | } | ||
219 | |||
220 | /* Save current tty state */ | ||
221 | save_state(); | ||
222 | |||
223 | /* Configure tty */ | 176 | /* Configure tty */ |
224 | memcpy(&state, &saved_state, sizeof(state)); | 177 | memcpy(&state, &G.saved_state, sizeof(state)); |
225 | if (!(opt & OPT_m_nonraw)) { /* raw not suppressed */ | 178 | if (!(opt & OPT_m_nonraw)) { /* raw not suppressed */ |
226 | memset(&state.c_cc, 0, sizeof(state.c_cc)); | 179 | memset(&state.c_cc, 0, sizeof(state.c_cc)); |
227 | state.c_cc[VMIN] = 1; | 180 | state.c_cc[VMIN] = 1; |
228 | state.c_iflag = IGNBRK | IGNPAR; | 181 | state.c_iflag = IGNBRK | IGNPAR; |
229 | state.c_oflag = 0; | 182 | /*state.c_oflag = 0;*/ |
230 | state.c_lflag = 0; | 183 | /*state.c_lflag = 0;*/ |
231 | state.c_cflag = CS8 | HUPCL | CREAD | 184 | state.c_cflag = CS8 | HUPCL | CREAD |
232 | | ((opt & OPT_L_local) ? CLOCAL : 0) | 185 | | ((opt & OPT_L_local) ? CLOCAL : 0) |
233 | | ((opt & OPT_F_noflow) ? 0 : CRTSCTS); | 186 | | ((opt & OPT_F_noflow) ? 0 : CRTSCTS); |
234 | cfsetispeed(&state, cfgetispeed(&saved_state)); | 187 | cfsetispeed(&state, cfgetispeed(&G.saved_state)); |
235 | cfsetospeed(&state, cfgetospeed(&saved_state)); | 188 | cfsetospeed(&state, cfgetospeed(&G.saved_state)); |
236 | } | 189 | } |
237 | |||
238 | if (opt & OPT_s_baud) { | 190 | if (opt & OPT_s_baud) { |
239 | cfsetispeed(&state, baud_code); | 191 | cfsetispeed(&state, baud_code); |
240 | cfsetospeed(&state, baud_code); | 192 | cfsetospeed(&state, baud_code); |
241 | } | 193 | } |
242 | 194 | /* Set line status */ | |
243 | set_state(&state, encap); | 195 | if (tcsetattr_serial_or_warn(&state)) |
196 | goto bad; | ||
197 | /* Set line disclipline (N_SLIP always) */ | ||
198 | if (ioctl_or_warn(serial_fd, TIOCSETD, (void*)&int_N_SLIP)) | ||
199 | goto bad; | ||
200 | /* Set encapsulation (SLIP, CSLIP, etc) */ | ||
201 | if (ioctl_or_warn(serial_fd, SIOCSIFENCAP, &encap)) | ||
202 | goto bad; | ||
244 | 203 | ||
245 | /* Exit now if option -e was passed */ | 204 | /* Exit now if option -e was passed */ |
246 | if (opt & OPT_e_quit) | 205 | if (opt & OPT_e_quit) |
247 | return 0; | 206 | return EXIT_SUCCESS; |
248 | 207 | ||
249 | /* If we're not requested to watch, just keep descriptor open | 208 | /* If we're not requested to watch, just keep descriptor open |
250 | * until we are killed */ | 209 | * until we are killed */ |
@@ -254,17 +213,20 @@ int slattach_main(int argc UNUSED_PARAM, char **argv) | |||
254 | 213 | ||
255 | /* Watch line for hangup */ | 214 | /* Watch line for hangup */ |
256 | while (1) { | 215 | while (1) { |
257 | if (ioctl(handle, TIOCMGET, &i) < 0 || !(i & TIOCM_CAR)) | 216 | int modem_stat; |
258 | goto no_carrier; | 217 | if (ioctl(serial_fd, TIOCMGET, &modem_stat)) |
218 | break; | ||
219 | if (!(modem_stat & TIOCM_CAR)) | ||
220 | break; | ||
259 | sleep(15); | 221 | sleep(15); |
260 | } | 222 | } |
261 | 223 | ||
262 | no_carrier: | ||
263 | |||
264 | /* Execute command on hangup */ | 224 | /* Execute command on hangup */ |
265 | if (opt & OPT_c_extcmd) | 225 | if (opt & OPT_c_extcmd) |
266 | system(extcmd); | 226 | system(extcmd); |
267 | 227 | ||
268 | /* Restore states and exit */ | 228 | /* Restore states and exit */ |
269 | restore_state_and_exit(EXIT_SUCCESS); | 229 | restore_state_and_exit(EXIT_SUCCESS); |
230 | bad: | ||
231 | restore_state_and_exit(EXIT_FAILURE); | ||
270 | } | 232 | } |
diff --git a/networking/tcpudp.c b/networking/tcpudp.c index 270325164..d4c69e0f7 100644 --- a/networking/tcpudp.c +++ b/networking/tcpudp.c | |||
@@ -269,10 +269,11 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv) | |||
269 | 269 | ||
270 | tcp = (applet_name[0] == 't'); | 270 | tcp = (applet_name[0] == 't'); |
271 | 271 | ||
272 | /* 3+ args, -i at most once, -p implies -h, -v is counter, -b N, -c N */ | ||
273 | opt_complementary = "-3:i--i:ph:vv"; | ||
274 | #ifdef SSLSVD | 272 | #ifdef SSLSVD |
275 | opts = getopt32(argv, "+c:+C:i:x:u:l:Eb:+hpt:vU:/:Z:K:", | 273 | opts = getopt32(argv, "^+" |
274 | "c:+C:i:x:u:l:Eb:+hpt:vU:/:Z:K:" /* -c NUM, -b NUM */ | ||
275 | /* 3+ args, -i at most once, -p implies -h, -v is a counter */ | ||
276 | "\0" "-3:i--i:ph:vv", | ||
276 | &cmax, &str_C, &instructs, &instructs, &user, &preset_local_hostname, | 277 | &cmax, &str_C, &instructs, &instructs, &user, &preset_local_hostname, |
277 | &backlog, &str_t, &ssluser, &root, &cert, &key, &verbose | 278 | &backlog, &str_t, &ssluser, &root, &cert, &key, &verbose |
278 | ); | 279 | ); |
diff --git a/networking/telnet.c b/networking/telnet.c index 9f191f7ad..1f8a44466 100644 --- a/networking/telnet.c +++ b/networking/telnet.c | |||
@@ -44,7 +44,7 @@ | |||
44 | //config: Setting this option will forward the USER environment variable to the | 44 | //config: Setting this option will forward the USER environment variable to the |
45 | //config: remote host you are connecting to. This is useful when you need to | 45 | //config: remote host you are connecting to. This is useful when you need to |
46 | //config: log into a machine without telling the username (autologin). This | 46 | //config: log into a machine without telling the username (autologin). This |
47 | //config: option enables `-a' and `-l USER' arguments. | 47 | //config: option enables '-a' and '-l USER' options. |
48 | //config: | 48 | //config: |
49 | //config:config FEATURE_TELNET_WIDTH | 49 | //config:config FEATURE_TELNET_WIDTH |
50 | //config: bool "Enable window size autodetection" | 50 | //config: bool "Enable window size autodetection" |
@@ -643,8 +643,10 @@ int telnet_main(int argc UNUSED_PARAM, char **argv) | |||
643 | } | 643 | } |
644 | 644 | ||
645 | #if ENABLE_FEATURE_TELNET_AUTOLOGIN | 645 | #if ENABLE_FEATURE_TELNET_AUTOLOGIN |
646 | if (1 & getopt32(argv, "al:", &G.autologin)) | 646 | if (1 == getopt32(argv, "al:", &G.autologin)) { |
647 | /* Only -a without -l USER picks $USER from envvar */ | ||
647 | G.autologin = getenv("USER"); | 648 | G.autologin = getenv("USER"); |
649 | } | ||
648 | argv += optind; | 650 | argv += optind; |
649 | #else | 651 | #else |
650 | argv++; | 652 | argv++; |
diff --git a/networking/telnetd.c b/networking/telnetd.c index 16c572e8d..a6bafa21d 100644 --- a/networking/telnetd.c +++ b/networking/telnetd.c | |||
@@ -659,13 +659,15 @@ int telnetd_main(int argc UNUSED_PARAM, char **argv) | |||
659 | #endif | 659 | #endif |
660 | INIT_G(); | 660 | INIT_G(); |
661 | 661 | ||
662 | /* -w NUM, and implies -F. -w and -i don't mix */ | ||
663 | IF_FEATURE_TELNETD_INETD_WAIT(opt_complementary = "wF:i--w:w--i";) | ||
664 | /* Even if !STANDALONE, we accept (and ignore) -i, thus people | 662 | /* Even if !STANDALONE, we accept (and ignore) -i, thus people |
665 | * don't need to guess whether it's ok to pass -i to us */ | 663 | * don't need to guess whether it's ok to pass -i to us */ |
666 | opt = getopt32(argv, "f:l:Ki" | 664 | opt = getopt32(argv, "^" |
665 | "f:l:Ki" | ||
667 | IF_FEATURE_TELNETD_STANDALONE("p:b:F") | 666 | IF_FEATURE_TELNETD_STANDALONE("p:b:F") |
668 | IF_FEATURE_TELNETD_INETD_WAIT("Sw:+"), | 667 | IF_FEATURE_TELNETD_INETD_WAIT("Sw:+") /* -w NUM */ |
668 | "\0" | ||
669 | /* -w implies -F. -w and -i don't mix */ | ||
670 | IF_FEATURE_TELNETD_INETD_WAIT("wF:i--w:w--i"), | ||
669 | &G.issuefile, &G.loginpath | 671 | &G.issuefile, &G.loginpath |
670 | IF_FEATURE_TELNETD_STANDALONE(, &opt_portnbr, &opt_bindaddr) | 672 | IF_FEATURE_TELNETD_STANDALONE(, &opt_portnbr, &opt_bindaddr) |
671 | IF_FEATURE_TELNETD_INETD_WAIT(, &sec_linger) | 673 | IF_FEATURE_TELNETD_INETD_WAIT(, &sec_linger) |
diff --git a/networking/tftp.c b/networking/tftp.c index 5baa80448..73a9829aa 100644 --- a/networking/tftp.c +++ b/networking/tftp.c | |||
@@ -761,15 +761,16 @@ int tftp_main(int argc UNUSED_PARAM, char **argv) | |||
761 | 761 | ||
762 | INIT_G(); | 762 | INIT_G(); |
763 | 763 | ||
764 | /* -p or -g is mandatory, and they are mutually exclusive */ | 764 | IF_GETPUT(opt =) getopt32(argv, "^" |
765 | opt_complementary = "" IF_FEATURE_TFTP_GET("g:") IF_FEATURE_TFTP_PUT("p:") | ||
766 | IF_GETPUT("g--p:p--g:"); | ||
767 | |||
768 | IF_GETPUT(opt =) getopt32(argv, | ||
769 | IF_FEATURE_TFTP_GET("g") IF_FEATURE_TFTP_PUT("p") | 765 | IF_FEATURE_TFTP_GET("g") IF_FEATURE_TFTP_PUT("p") |
770 | "l:r:" IF_FEATURE_TFTP_BLOCKSIZE("b:"), | 766 | "l:r:" IF_FEATURE_TFTP_BLOCKSIZE("b:") |
767 | "\0" | ||
768 | /* -p or -g is mandatory, and they are mutually exclusive */ | ||
769 | IF_FEATURE_TFTP_GET("g:") IF_FEATURE_TFTP_PUT("p:") | ||
770 | IF_GETPUT("g--p:p--g:"), | ||
771 | &local_file, &remote_file | 771 | &local_file, &remote_file |
772 | IF_FEATURE_TFTP_BLOCKSIZE(, &blksize_str)); | 772 | IF_FEATURE_TFTP_BLOCKSIZE(, &blksize_str) |
773 | ); | ||
773 | argv += optind; | 774 | argv += optind; |
774 | 775 | ||
775 | # if ENABLE_FEATURE_TFTP_BLOCKSIZE | 776 | # if ENABLE_FEATURE_TFTP_BLOCKSIZE |
diff --git a/networking/traceroute.c b/networking/traceroute.c index a958a2c6c..8b6247482 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -12,12 +12,12 @@ | |||
12 | * this paragraph in its entirety in the documentation or other materials | 12 | * this paragraph in its entirety in the documentation or other materials |
13 | * provided with the distribution, and (3) all advertising materials mentioning | 13 | * provided with the distribution, and (3) all advertising materials mentioning |
14 | * features or use of this software display the following acknowledgement: | 14 | * features or use of this software display the following acknowledgement: |
15 | * ``This product includes software developed by the University of California, | 15 | * ''This product includes software developed by the University of California, |
16 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of | 16 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of |
17 | * the University nor the names of its contributors may be used to endorse | 17 | * the University nor the names of its contributors may be used to endorse |
18 | * or promote products derived from this software without specific prior | 18 | * or promote products derived from this software without specific prior |
19 | * written permission. | 19 | * written permission. |
20 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED | 20 | * THIS SOFTWARE IS PROVIDED ''AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED |
21 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | 21 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
23 | */ | 23 | */ |
@@ -833,9 +833,9 @@ common_traceroute_main(int op, char **argv) | |||
833 | 833 | ||
834 | INIT_G(); | 834 | INIT_G(); |
835 | 835 | ||
836 | /* minimum 1 arg */ | 836 | op |= getopt32(argv, "^" |
837 | opt_complementary = "-1:x-x"; | 837 | OPT_STRING |
838 | op |= getopt32(argv, OPT_STRING | 838 | "\0" "-1:x-x" /* minimum 1 arg */ |
839 | , &tos_str, &device, &max_ttl_str, &port_str, &nprobes_str | 839 | , &tos_str, &device, &max_ttl_str, &port_str, &nprobes_str |
840 | , &source, &waittime_str, &pausemsecs_str, &first_ttl_str | 840 | , &source, &waittime_str, &pausemsecs_str, &first_ttl_str |
841 | ); | 841 | ); |
diff --git a/networking/tunctl.c b/networking/tunctl.c index 0a26ff7fb..f2dc645a1 100644 --- a/networking/tunctl.c +++ b/networking/tunctl.c | |||
@@ -24,7 +24,7 @@ | |||
24 | //config: Allow to specify owner and group of newly created interface. | 24 | //config: Allow to specify owner and group of newly created interface. |
25 | //config: 340 bytes of pure bloat. Say no here. | 25 | //config: 340 bytes of pure bloat. Say no here. |
26 | 26 | ||
27 | //applet:IF_TUNCTL(APPLET(tunctl, BB_DIR_SBIN, BB_SUID_DROP)) | 27 | //applet:IF_TUNCTL(APPLET_NOEXEC(tunctl, tunctl, BB_DIR_SBIN, BB_SUID_DROP, tunctl)) |
28 | 28 | ||
29 | //kbuild:lib-$(CONFIG_TUNCTL) += tunctl.o | 29 | //kbuild:lib-$(CONFIG_TUNCTL) += tunctl.o |
30 | 30 | ||
@@ -83,10 +83,13 @@ int tunctl_main(int argc UNUSED_PARAM, char **argv) | |||
83 | #endif | 83 | #endif |
84 | }; | 84 | }; |
85 | 85 | ||
86 | opt_complementary = "=0:t--d:d--t"; // no arguments; t ^ d | 86 | opts = getopt32(argv, "^" |
87 | opts = getopt32(argv, "f:t:d:" IF_FEATURE_TUNCTL_UG("u:g:b"), | 87 | "f:t:d:" IF_FEATURE_TUNCTL_UG("u:g:b") |
88 | "\0" | ||
89 | "=0:t--d:d--t", // no arguments; t ^ d | ||
88 | &opt_device, &opt_name, &opt_name | 90 | &opt_device, &opt_name, &opt_name |
89 | IF_FEATURE_TUNCTL_UG(, &opt_user, &opt_group)); | 91 | IF_FEATURE_TUNCTL_UG(, &opt_user, &opt_group) |
92 | ); | ||
90 | 93 | ||
91 | // select device | 94 | // select device |
92 | memset(&ifr, 0, sizeof(ifr)); | 95 | memset(&ifr, 0, sizeof(ifr)); |
@@ -153,9 +156,12 @@ int tunctl_main(int argc UNUSED_PARAM, char **argv) | |||
153 | OPT_d = 1 << 2, // delete named interface | 156 | OPT_d = 1 << 2, // delete named interface |
154 | }; | 157 | }; |
155 | 158 | ||
156 | opt_complementary = "=0:t--d:d--t"; // no arguments; t ^ d | 159 | opts = getopt32(argv, "^" |
157 | opts = getopt32(argv, "f:t:d:u:g:b", // u, g, b accepted and ignored | 160 | "f:t:d:u:g:b" // u, g, b accepted and ignored |
158 | &opt_device, &opt_name, &opt_name, NULL, NULL); | 161 | "\0" |
162 | "=0:t--d:d--t", // no arguments; t ^ d | ||
163 | &opt_device, &opt_name, &opt_name, NULL, NULL | ||
164 | ); | ||
159 | 165 | ||
160 | // set interface name | 166 | // set interface name |
161 | memset(&ifr, 0, sizeof(ifr)); | 167 | memset(&ifr, 0, sizeof(ifr)); |
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index 43081efca..849ca1388 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c | |||
@@ -1101,14 +1101,15 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1101 | client_config.script = CONFIG_UDHCPC_DEFAULT_SCRIPT; | 1101 | client_config.script = CONFIG_UDHCPC_DEFAULT_SCRIPT; |
1102 | 1102 | ||
1103 | /* Parse command line */ | 1103 | /* Parse command line */ |
1104 | /* O,x: list; -T,-t,-A take numeric param */ | 1104 | opt = getopt32long(argv, "^" |
1105 | IF_UDHCP_VERBOSE(opt_complementary = "vv";) | 1105 | /* O,x: list; -T,-t,-A take numeric param */ |
1106 | IF_LONG_OPTS(applet_long_options = udhcpc6_longopts;) | 1106 | "i:np:qRr:s:T:+t:+SA:+O:*ox:*f" |
1107 | opt = getopt32(argv, "i:np:qRr:s:T:+t:+SA:+O:*ox:*f" | ||
1108 | USE_FOR_MMU("b") | 1107 | USE_FOR_MMU("b") |
1109 | ///IF_FEATURE_UDHCPC_ARPING("a") | 1108 | ///IF_FEATURE_UDHCPC_ARPING("a") |
1110 | IF_FEATURE_UDHCP_PORT("P:") | 1109 | IF_FEATURE_UDHCP_PORT("P:") |
1111 | "v" | 1110 | "v" |
1111 | "\0" IF_UDHCP_VERBOSE("vv") /* -v is a counter */ | ||
1112 | , udhcpc6_longopts | ||
1112 | , &client_config.interface, &client_config.pidfile, &str_r /* i,p */ | 1113 | , &client_config.interface, &client_config.pidfile, &str_r /* i,p */ |
1113 | , &client_config.script /* s */ | 1114 | , &client_config.script /* s */ |
1114 | , &discover_timeout, &discover_retries, &tryagain_timeout /* T,t,A */ | 1115 | , &discover_timeout, &discover_retries, &tryagain_timeout /* T,t,A */ |
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index ccf04993d..55e0400b9 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -1295,16 +1295,18 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1295 | str_V = "udhcp "BB_VER; | 1295 | str_V = "udhcp "BB_VER; |
1296 | 1296 | ||
1297 | /* Parse command line */ | 1297 | /* Parse command line */ |
1298 | /* O,x: list; -T,-t,-A take numeric param */ | 1298 | opt = getopt32long(argv, "^" |
1299 | IF_UDHCP_VERBOSE(opt_complementary = "vv";) | 1299 | /* O,x: list; -T,-t,-A take numeric param */ |
1300 | IF_LONG_OPTS(applet_long_options = udhcpc_longopts;) | 1300 | "CV:H:h:F:i:np:qRr:s:T:+t:+SA:+O:*ox:*fB" |
1301 | opt = getopt32(argv, "CV:H:h:F:i:np:qRr:s:T:+t:+SA:+O:*ox:*fB" | ||
1302 | USE_FOR_MMU("b") | 1301 | USE_FOR_MMU("b") |
1303 | IF_FEATURE_UDHCPC_ARPING("a::") | 1302 | IF_FEATURE_UDHCPC_ARPING("a::") |
1304 | IF_FEATURE_UDHCP_PORT("P:") | 1303 | IF_FEATURE_UDHCP_PORT("P:") |
1305 | "v" | 1304 | "v" |
1305 | "\0" IF_UDHCP_VERBOSE("vv") /* -v is a counter */ | ||
1306 | , udhcpc_longopts | ||
1306 | , &str_V, &str_h, &str_h, &str_F | 1307 | , &str_V, &str_h, &str_h, &str_F |
1307 | , &client_config.interface, &client_config.pidfile, &str_r /* i,p */ | 1308 | , &client_config.interface, &client_config.pidfile /* i,p */ |
1309 | , &str_r /* r */ | ||
1308 | , &client_config.script /* s */ | 1310 | , &client_config.script /* s */ |
1309 | , &discover_timeout, &discover_retries, &tryagain_timeout /* T,t,A */ | 1311 | , &discover_timeout, &discover_retries, &tryagain_timeout /* T,t,A */ |
1310 | , &list_O | 1312 | , &list_O |
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c index 3a5fc2db7..05ddc8649 100644 --- a/networking/udhcp/dhcpd.c +++ b/networking/udhcp/dhcpd.c | |||
@@ -814,11 +814,12 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) | |||
814 | IF_FEATURE_UDHCP_PORT(SERVER_PORT = 67;) | 814 | IF_FEATURE_UDHCP_PORT(SERVER_PORT = 67;) |
815 | IF_FEATURE_UDHCP_PORT(CLIENT_PORT = 68;) | 815 | IF_FEATURE_UDHCP_PORT(CLIENT_PORT = 68;) |
816 | 816 | ||
817 | opt = getopt32(argv, "^" | ||
818 | "fSI:va:"IF_FEATURE_UDHCP_PORT("P:") | ||
819 | "\0" | ||
817 | #if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1 | 820 | #if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1 |
818 | opt_complementary = "vv"; | 821 | "vv" |
819 | #endif | 822 | #endif |
820 | opt = getopt32(argv, "fSI:va:" | ||
821 | IF_FEATURE_UDHCP_PORT("P:") | ||
822 | , &str_I | 823 | , &str_I |
823 | , &str_a | 824 | , &str_a |
824 | IF_FEATURE_UDHCP_PORT(, &str_P) | 825 | IF_FEATURE_UDHCP_PORT(, &str_P) |
diff --git a/networking/udhcp/dumpleases.c b/networking/udhcp/dumpleases.c index dce9084b3..70d2d1434 100644 --- a/networking/udhcp/dumpleases.c +++ b/networking/udhcp/dumpleases.c | |||
@@ -2,7 +2,7 @@ | |||
2 | /* | 2 | /* |
3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
4 | */ | 4 | */ |
5 | //applet:IF_DUMPLEASES(APPLET(dumpleases, BB_DIR_USR_BIN, BB_SUID_DROP)) | 5 | //applet:IF_DUMPLEASES(APPLET_NOEXEC(dumpleases, dumpleases, BB_DIR_USR_BIN, BB_SUID_DROP, dumpleases)) |
6 | 6 | ||
7 | //kbuild:lib-$(CONFIG_DUMPLEASES) += dumpleases.o | 7 | //kbuild:lib-$(CONFIG_DUMPLEASES) += dumpleases.o |
8 | 8 | ||
@@ -51,12 +51,15 @@ int dumpleases_main(int argc UNUSED_PARAM, char **argv) | |||
51 | "decimal\0" No_argument "d" | 51 | "decimal\0" No_argument "d" |
52 | ; | 52 | ; |
53 | 53 | ||
54 | applet_long_options = dumpleases_longopts; | ||
55 | #endif | 54 | #endif |
56 | init_unicode(); | 55 | init_unicode(); |
57 | 56 | ||
58 | opt_complementary = "=0:a--r:r--a"; | 57 | opt = getopt32long(argv, "^" |
59 | opt = getopt32(argv, "arf:d", &file); | 58 | "arf:d" |
59 | "\0" "=0:a--r:r--a", | ||
60 | dumpleases_longopts, | ||
61 | &file | ||
62 | ); | ||
60 | 63 | ||
61 | fd = xopen(file, O_RDONLY); | 64 | fd = xopen(file, O_RDONLY); |
62 | 65 | ||
diff --git a/networking/vconfig.c b/networking/vconfig.c index e6e2872bf..62a483865 100644 --- a/networking/vconfig.c +++ b/networking/vconfig.c | |||
@@ -16,7 +16,7 @@ | |||
16 | //config: help | 16 | //config: help |
17 | //config: Creates, removes, and configures VLAN interfaces | 17 | //config: Creates, removes, and configures VLAN interfaces |
18 | 18 | ||
19 | //applet:IF_VCONFIG(APPLET(vconfig, BB_DIR_SBIN, BB_SUID_DROP)) | 19 | //applet:IF_VCONFIG(APPLET_NOEXEC(vconfig, vconfig, BB_DIR_SBIN, BB_SUID_DROP, vconfig)) |
20 | 20 | ||
21 | //kbuild:lib-$(CONFIG_VCONFIG) += vconfig.o | 21 | //kbuild:lib-$(CONFIG_VCONFIG) += vconfig.o |
22 | 22 | ||
diff --git a/networking/wget.c b/networking/wget.c index ab9bc1836..0001ddcba 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -1371,6 +1371,11 @@ IF_DESKTOP( "no-clobber\0" No_argument "\xf0") | |||
1371 | IF_DESKTOP( "no-host-directories\0" No_argument "\xf0") | 1371 | IF_DESKTOP( "no-host-directories\0" No_argument "\xf0") |
1372 | IF_DESKTOP( "no-parent\0" No_argument "\xf0") | 1372 | IF_DESKTOP( "no-parent\0" No_argument "\xf0") |
1373 | ; | 1373 | ; |
1374 | # define GETOPT32 getopt32long | ||
1375 | # define LONGOPTS ,wget_longopts | ||
1376 | #else | ||
1377 | # define GETOPT32 getopt32 | ||
1378 | # define LONGOPTS | ||
1374 | #endif | 1379 | #endif |
1375 | 1380 | ||
1376 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS | 1381 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS |
@@ -1387,11 +1392,9 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") | |||
1387 | G.user_agent = "Wget"; /* "User-Agent" header field */ | 1392 | G.user_agent = "Wget"; /* "User-Agent" header field */ |
1388 | 1393 | ||
1389 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS | 1394 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS |
1390 | applet_long_options = wget_longopts; | ||
1391 | #endif | 1395 | #endif |
1392 | opt_complementary = "-1" /* at least one URL */ | 1396 | GETOPT32(argv, "^" |
1393 | IF_FEATURE_WGET_LONG_OPTIONS(":\xff::"); /* --header is a list */ | 1397 | "cqSO:P:Y:U:T:+" |
1394 | getopt32(argv, "cqSO:P:Y:U:T:+" | ||
1395 | /*ignored:*/ "t:" | 1398 | /*ignored:*/ "t:" |
1396 | /*ignored:*/ "n::" | 1399 | /*ignored:*/ "n::" |
1397 | /* wget has exactly four -n<letter> opts, all of which we can ignore: | 1400 | /* wget has exactly four -n<letter> opts, all of which we can ignore: |
@@ -1402,6 +1405,10 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") | |||
1402 | * "n::" above says that we accept -n[ARG]. | 1405 | * "n::" above says that we accept -n[ARG]. |
1403 | * Specifying "n:" would be a bug: "-n ARG" would eat ARG! | 1406 | * Specifying "n:" would be a bug: "-n ARG" would eat ARG! |
1404 | */ | 1407 | */ |
1408 | "\0" | ||
1409 | "-1" /* at least one URL */ | ||
1410 | IF_FEATURE_WGET_LONG_OPTIONS(":\xff::") /* --header is a list */ | ||
1411 | LONGOPTS | ||
1405 | , &G.fname_out, &G.dir_prefix, | 1412 | , &G.fname_out, &G.dir_prefix, |
1406 | &G.proxy_flag, &G.user_agent, | 1413 | &G.proxy_flag, &G.user_agent, |
1407 | IF_FEATURE_WGET_TIMEOUT(&G.timeout_seconds) IF_NOT_FEATURE_WGET_TIMEOUT(NULL), | 1414 | IF_FEATURE_WGET_TIMEOUT(&G.timeout_seconds) IF_NOT_FEATURE_WGET_TIMEOUT(NULL), |
diff --git a/networking/whois.c b/networking/whois.c index 0cb7e5411..fd1cdf43e 100644 --- a/networking/whois.c +++ b/networking/whois.c | |||
@@ -167,8 +167,7 @@ int whois_main(int argc UNUSED_PARAM, char **argv) | |||
167 | int port = 43; | 167 | int port = 43; |
168 | const char *host = "whois.iana.org"; | 168 | const char *host = "whois.iana.org"; |
169 | 169 | ||
170 | opt_complementary = "-1"; | 170 | getopt32(argv, "^" "ih:p:+" "\0" "-1", &host, &port); |
171 | getopt32(argv, "ih:p:+", &host, &port); | ||
172 | argv += optind; | 171 | argv += optind; |
173 | 172 | ||
174 | do { | 173 | do { |
diff --git a/networking/zcip.c b/networking/zcip.c index 94174a165..55440285f 100644 --- a/networking/zcip.c +++ b/networking/zcip.c | |||
@@ -253,8 +253,9 @@ int zcip_main(int argc UNUSED_PARAM, char **argv) | |||
253 | #define QUIT (opts & 2) | 253 | #define QUIT (opts & 2) |
254 | // Parse commandline: prog [options] ifname script | 254 | // Parse commandline: prog [options] ifname script |
255 | // exactly 2 args; -v accumulates and implies -f | 255 | // exactly 2 args; -v accumulates and implies -f |
256 | opt_complementary = "=2:vv:vf"; | 256 | opts = getopt32(argv, "^" "fqr:l:v" "\0" "=2:vv:vf", |
257 | opts = getopt32(argv, "fqr:l:v", &r_opt, &l_opt, &verbose); | 257 | &r_opt, &l_opt, &verbose |
258 | ); | ||
258 | #if !BB_MMU | 259 | #if !BB_MMU |
259 | // on NOMMU reexec early (or else we will rerun things twice) | 260 | // on NOMMU reexec early (or else we will rerun things twice) |
260 | if (!FOREGROUND) | 261 | if (!FOREGROUND) |