diff options
author | Ron Yorston <rmy@pobox.com> | 2012-03-21 20:53:50 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2012-03-21 20:53:50 +0000 |
commit | f6bad5ef766b0447158e3de2f55c35f1f6cecb58 (patch) | |
tree | f5ec7ac45234c25794c97f87e9a6daa8a551e57c | |
parent | 72394258b6509b40e0fa08594ac86215a558dfd8 (diff) | |
parent | 8d0e0cdadf726beab28ccdc7d69738c1534e1f74 (diff) | |
download | busybox-w32-f6bad5ef766b0447158e3de2f55c35f1f6cecb58.tar.gz busybox-w32-f6bad5ef766b0447158e3de2f55c35f1f6cecb58.tar.bz2 busybox-w32-f6bad5ef766b0447158e3de2f55c35f1f6cecb58.zip |
Merge commit '8d0e0cdadf726beab28ccdc7d69738c1534e1f74' into merge
Conflicts:
include/platform.h
libbb/Kbuild.src
libbb/messages.c
91 files changed, 1203 insertions, 1148 deletions
@@ -307,10 +307,19 @@ config FEATURE_CLEAN_UP | |||
307 | Don't enable this unless you have a really good reason to clean | 307 | Don't enable this unless you have a really good reason to clean |
308 | things up manually. | 308 | things up manually. |
309 | 309 | ||
310 | config FEATURE_UTMP | ||
311 | bool "Support utmp file" | ||
312 | default y | ||
313 | help | ||
314 | The file /var/run/utmp is used to track who is currently logged in. | ||
315 | With this option on, certain applets (getty, login, telnetd etc) | ||
316 | will create and delete entries there. | ||
317 | "who" applet requires this option. | ||
318 | |||
310 | config FEATURE_WTMP | 319 | config FEATURE_WTMP |
311 | bool "Support wtmp file" | 320 | bool "Support wtmp file" |
312 | default y | 321 | default y |
313 | select FEATURE_UTMP | 322 | depends on FEATURE_UTMP |
314 | help | 323 | help |
315 | The file /var/run/wtmp is used to track when users have logged into | 324 | The file /var/run/wtmp is used to track when users have logged into |
316 | and logged out of the system. | 325 | and logged out of the system. |
@@ -318,15 +327,6 @@ config FEATURE_WTMP | |||
318 | will append new entries there. | 327 | will append new entries there. |
319 | "last" applet requires this option. | 328 | "last" applet requires this option. |
320 | 329 | ||
321 | config FEATURE_UTMP | ||
322 | bool "Support utmp file" | ||
323 | default y | ||
324 | help | ||
325 | The file /var/run/utmp is used to track who is currently logged in. | ||
326 | With this option on, certain applets (getty, login, telnetd etc) | ||
327 | will create and delete entries there. | ||
328 | "who" applet requires this option. | ||
329 | |||
330 | config FEATURE_PIDFILE | 330 | config FEATURE_PIDFILE |
331 | bool "Support writing pidfiles" | 331 | bool "Support writing pidfiles" |
332 | default y | 332 | default y |
@@ -351,10 +351,18 @@ config FEATURE_SUID | |||
351 | symlinks pointing to each binary), and only set the suid bit on the | 351 | symlinks pointing to each binary), and only set the suid bit on the |
352 | one that needs it. | 352 | one that needs it. |
353 | 353 | ||
354 | The applets currently marked to need the suid bit are: | 354 | The applets which require root rights (need suid bit or |
355 | to be run by root) and will refuse to execute otherwise: | ||
356 | crontab, login, passwd, su, vlock, wall. | ||
357 | |||
358 | The applets which will use root rights if they have them | ||
359 | (via suid bit, or because run by root), but would try to work | ||
360 | without root right nevertheless: | ||
361 | findfs, ping[6], traceroute[6], mount. | ||
355 | 362 | ||
356 | crontab, dnsd, findfs, ipcrm, ipcs, login, passwd, ping, su, | 363 | Note that if you DONT select this option, but DO make busybox |
357 | traceroute, vlock. | 364 | suid root, ALL applets will run under root, which is a huge |
365 | security hole (think "cp /some/file /etc/passwd"). | ||
358 | 366 | ||
359 | config FEATURE_SUID_CONFIG | 367 | config FEATURE_SUID_CONFIG |
360 | bool "Runtime SUID/SGID configuration via /etc/busybox.conf" | 368 | bool "Runtime SUID/SGID configuration via /etc/busybox.conf" |
diff --git a/archival/bbunzip.c b/archival/bbunzip.c index 0f89443e0..85447cbfe 100644 --- a/archival/bbunzip.c +++ b/archival/bbunzip.c | |||
@@ -317,8 +317,8 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv) | |||
317 | //usage: "FILE" | 317 | //usage: "FILE" |
318 | //usage:#define bzcat_full_usage "\n\n" | 318 | //usage:#define bzcat_full_usage "\n\n" |
319 | //usage: "Decompress to stdout" | 319 | //usage: "Decompress to stdout" |
320 | //applet:IF_BUNZIP2(APPLET(bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 320 | //applet:IF_BUNZIP2(APPLET(bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP)) |
321 | //applet:IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP, bzcat)) | 321 | //applet:IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP, bzcat)) |
322 | #if ENABLE_BUNZIP2 | 322 | #if ENABLE_BUNZIP2 |
323 | static | 323 | static |
324 | IF_DESKTOP(long long) int FAST_FUNC unpack_bunzip2(unpack_info_t *info UNUSED_PARAM) | 324 | IF_DESKTOP(long long) int FAST_FUNC unpack_bunzip2(unpack_info_t *info UNUSED_PARAM) |
diff --git a/archival/libarchive/get_header_tar.c b/archival/libarchive/get_header_tar.c index 78b0ae25f..2e0332792 100644 --- a/archival/libarchive/get_header_tar.c +++ b/archival/libarchive/get_header_tar.c | |||
@@ -199,7 +199,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle) | |||
199 | uint16_t magic2; | 199 | uint16_t magic2; |
200 | 200 | ||
201 | autodetect: | 201 | autodetect: |
202 | magic2 = *(uint16_t*)tar.name; | 202 | magic2 = *(bb__aliased_uint16_t*)tar.name; |
203 | /* tar gz/bz autodetect: check for gz/bz2 magic. | 203 | /* tar gz/bz autodetect: check for gz/bz2 magic. |
204 | * If we see the magic, and it is the very first block, | 204 | * If we see the magic, and it is the very first block, |
205 | * we can switch to get_header_tar_gz/bz2/lzma(). | 205 | * we can switch to get_header_tar_gz/bz2/lzma(). |
diff --git a/coreutils/cal.c b/coreutils/cal.c index ef5dbeadb..f18c16120 100644 --- a/coreutils/cal.c +++ b/coreutils/cal.c | |||
@@ -138,7 +138,7 @@ int cal_main(int argc UNUSED_PARAM, char **argv) | |||
138 | if (julian) | 138 | if (julian) |
139 | *hp++ = ' '; | 139 | *hp++ = ' '; |
140 | { | 140 | { |
141 | char *two_wchars = unicode_conv_to_printable_fixedwidth(NULL, buf, 2); | 141 | char *two_wchars = unicode_conv_to_printable_fixedwidth(/*NULL,*/ buf, 2); |
142 | strcpy(hp, two_wchars); | 142 | strcpy(hp, two_wchars); |
143 | free(two_wchars); | 143 | free(two_wchars); |
144 | } | 144 | } |
diff --git a/coreutils/date.c b/coreutils/date.c index 22d0a5327..d36ed83fd 100644 --- a/coreutils/date.c +++ b/coreutils/date.c | |||
@@ -19,7 +19,7 @@ | |||
19 | /* Input parsing code is always bulky - used heavy duty libc stuff as | 19 | /* Input parsing code is always bulky - used heavy duty libc stuff as |
20 | much as possible, missed out a lot of bounds checking */ | 20 | much as possible, missed out a lot of bounds checking */ |
21 | 21 | ||
22 | //applet:IF_DATE(APPLET(date, _BB_DIR_BIN, _BB_SUID_DROP)) | 22 | //applet:IF_DATE(APPLET(date, BB_DIR_BIN, BB_SUID_DROP)) |
23 | 23 | ||
24 | //kbuild:lib-$(CONFIG_DATE) += date.o | 24 | //kbuild:lib-$(CONFIG_DATE) += date.o |
25 | 25 | ||
diff --git a/coreutils/stty.c b/coreutils/stty.c index e28e15c97..1dd01c4dd 100644 --- a/coreutils/stty.c +++ b/coreutils/stty.c | |||
@@ -59,6 +59,10 @@ | |||
59 | #if defined(VEOL2) && !defined(CEOL2) | 59 | #if defined(VEOL2) && !defined(CEOL2) |
60 | # define CEOL2 _POSIX_VDISABLE | 60 | # define CEOL2 _POSIX_VDISABLE |
61 | #endif | 61 | #endif |
62 | /* glibc-2.12.1 uses only VSWTC name */ | ||
63 | #if defined(VSWTC) && !defined(VSWTCH) | ||
64 | # define VSWTCH VSWTC | ||
65 | #endif | ||
62 | /* ISC renamed swtch to susp for termios, but we'll accept either name */ | 66 | /* ISC renamed swtch to susp for termios, but we'll accept either name */ |
63 | #if defined(VSUSP) && !defined(VSWTCH) | 67 | #if defined(VSUSP) && !defined(VSWTCH) |
64 | # define VSWTCH VSUSP | 68 | # define VSWTCH VSUSP |
@@ -221,6 +225,9 @@ | |||
221 | #ifndef XCASE | 225 | #ifndef XCASE |
222 | # define XCASE 0 | 226 | # define XCASE 0 |
223 | #endif | 227 | #endif |
228 | #ifndef IUTF8 | ||
229 | # define IUTF8 0 | ||
230 | #endif | ||
224 | 231 | ||
225 | /* Which speeds to set */ | 232 | /* Which speeds to set */ |
226 | enum speed_setting { | 233 | enum speed_setting { |
@@ -348,6 +355,9 @@ static const char mode_name[] = | |||
348 | #if IMAXBEL | 355 | #if IMAXBEL |
349 | MI_ENTRY("imaxbel", input, SANE_SET | REV, IMAXBEL, 0 ) | 356 | MI_ENTRY("imaxbel", input, SANE_SET | REV, IMAXBEL, 0 ) |
350 | #endif | 357 | #endif |
358 | #if IUTF8 | ||
359 | MI_ENTRY("iutf8", input, SANE_UNSET | REV, IUTF8, 0 ) | ||
360 | #endif | ||
351 | MI_ENTRY("opost", output, SANE_SET | REV, OPOST, 0 ) | 361 | MI_ENTRY("opost", output, SANE_SET | REV, OPOST, 0 ) |
352 | #if OLCUC | 362 | #if OLCUC |
353 | MI_ENTRY("olcuc", output, SANE_UNSET | REV, OLCUC, 0 ) | 363 | MI_ENTRY("olcuc", output, SANE_UNSET | REV, OLCUC, 0 ) |
@@ -502,6 +512,9 @@ static const struct mode_info mode_info[] = { | |||
502 | #if IMAXBEL | 512 | #if IMAXBEL |
503 | MI_ENTRY("imaxbel", input, SANE_SET | REV, IMAXBEL, 0 ) | 513 | MI_ENTRY("imaxbel", input, SANE_SET | REV, IMAXBEL, 0 ) |
504 | #endif | 514 | #endif |
515 | #if IUTF8 | ||
516 | MI_ENTRY("iutf8", input, SANE_UNSET | REV, IUTF8, 0 ) | ||
517 | #endif | ||
505 | MI_ENTRY("opost", output, SANE_SET | REV, OPOST, 0 ) | 518 | MI_ENTRY("opost", output, SANE_SET | REV, OPOST, 0 ) |
506 | #if OLCUC | 519 | #if OLCUC |
507 | MI_ENTRY("olcuc", output, SANE_UNSET | REV, OLCUC, 0 ) | 520 | MI_ENTRY("olcuc", output, SANE_UNSET | REV, OLCUC, 0 ) |
@@ -991,8 +1004,9 @@ static void display_speed(const struct termios *mode, int fancy) | |||
991 | const char *fmt_str = "%lu %lu\n\0ispeed %lu baud; ospeed %lu baud;"; | 1004 | const char *fmt_str = "%lu %lu\n\0ispeed %lu baud; ospeed %lu baud;"; |
992 | unsigned long ispeed, ospeed; | 1005 | unsigned long ispeed, ospeed; |
993 | 1006 | ||
994 | ospeed = ispeed = cfgetispeed(mode); | 1007 | ispeed = cfgetispeed(mode); |
995 | if (ispeed == 0 || ispeed == (ospeed = cfgetospeed(mode))) { | 1008 | ospeed = cfgetospeed(mode); |
1009 | if (ispeed == 0 || ispeed == ospeed) { | ||
996 | ispeed = ospeed; /* in case ispeed was 0 */ | 1010 | ispeed = ospeed; /* in case ispeed was 0 */ |
997 | //________ 0123 4 5 6 7 8 9 | 1011 | //________ 0123 4 5 6 7 8 9 |
998 | fmt_str = "%lu\n\0\0\0\0\0speed %lu baud;"; | 1012 | fmt_str = "%lu\n\0\0\0\0\0speed %lu baud;"; |
@@ -1011,7 +1025,7 @@ static void do_display(const struct termios *mode, int all) | |||
1011 | display_speed(mode, 1); | 1025 | display_speed(mode, 1); |
1012 | if (all) | 1026 | if (all) |
1013 | display_window_size(1); | 1027 | display_window_size(1); |
1014 | #ifdef HAVE_C_LINE | 1028 | #ifdef __linux__ |
1015 | wrapf("line = %u;\n", mode->c_line); | 1029 | wrapf("line = %u;\n", mode->c_line); |
1016 | #else | 1030 | #else |
1017 | newline(); | 1031 | newline(); |
@@ -1344,7 +1358,7 @@ int stty_main(int argc UNUSED_PARAM, char **argv) | |||
1344 | } | 1358 | } |
1345 | 1359 | ||
1346 | switch (param) { | 1360 | switch (param) { |
1347 | #ifdef HAVE_C_LINE | 1361 | #ifdef __linux__ |
1348 | case param_line: | 1362 | case param_line: |
1349 | # ifndef TIOCGWINSZ | 1363 | # ifndef TIOCGWINSZ |
1350 | xatoul_range_sfx(argnext, 1, INT_MAX, stty_suffixes); | 1364 | xatoul_range_sfx(argnext, 1, INT_MAX, stty_suffixes); |
@@ -1448,7 +1462,7 @@ int stty_main(int argc UNUSED_PARAM, char **argv) | |||
1448 | } | 1462 | } |
1449 | 1463 | ||
1450 | switch (param) { | 1464 | switch (param) { |
1451 | #ifdef HAVE_C_LINE | 1465 | #ifdef __linux__ |
1452 | case param_line: | 1466 | case param_line: |
1453 | mode.c_line = xatoul_sfx(argnext, stty_suffixes); | 1467 | mode.c_line = xatoul_sfx(argnext, stty_suffixes); |
1454 | stty_state |= STTY_require_set_attr; | 1468 | stty_state |= STTY_require_set_attr; |
diff --git a/coreutils/touch.c b/coreutils/touch.c index 6c2b948e6..c51fb70ca 100644 --- a/coreutils/touch.c +++ b/coreutils/touch.c | |||
@@ -26,7 +26,7 @@ | |||
26 | //config: touch is used to create or change the access and/or | 26 | //config: touch is used to create or change the access and/or |
27 | //config: modification timestamp of specified files. | 27 | //config: modification timestamp of specified files. |
28 | 28 | ||
29 | //applet:IF_TOUCH(APPLET_NOFORK(touch, touch, _BB_DIR_BIN, _BB_SUID_DROP, touch)) | 29 | //applet:IF_TOUCH(APPLET_NOFORK(touch, touch, BB_DIR_BIN, BB_SUID_DROP, touch)) |
30 | 30 | ||
31 | //kbuild:lib-$(CONFIG_TOUCH) += touch.o | 31 | //kbuild:lib-$(CONFIG_TOUCH) += touch.o |
32 | 32 | ||
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c index 0c4311f24..56ed254e5 100644 --- a/coreutils/uudecode.c +++ b/coreutils/uudecode.c | |||
@@ -132,7 +132,7 @@ int uudecode_main(int argc UNUSED_PARAM, char **argv) | |||
132 | } | 132 | } |
133 | #endif | 133 | #endif |
134 | 134 | ||
135 | //applet:IF_BASE64(APPLET(base64, _BB_DIR_BIN, _BB_SUID_DROP)) | 135 | //applet:IF_BASE64(APPLET(base64, BB_DIR_BIN, BB_SUID_DROP)) |
136 | 136 | ||
137 | //kbuild:lib-$(CONFIG_BASE64) += uudecode.o | 137 | //kbuild:lib-$(CONFIG_BASE64) += uudecode.o |
138 | 138 | ||
diff --git a/coreutils/wc.c b/coreutils/wc.c index fe3f274f8..6e22c66c8 100644 --- a/coreutils/wc.c +++ b/coreutils/wc.c | |||
@@ -81,11 +81,11 @@ | |||
81 | * column order in "wc -cmlwL" output: | 81 | * column order in "wc -cmlwL" output: |
82 | */ | 82 | */ |
83 | enum { | 83 | enum { |
84 | WC_LINES = 0, | 84 | WC_LINES = 0, /* -l */ |
85 | WC_WORDS = 1, | 85 | WC_WORDS = 1, /* -w */ |
86 | WC_UNICHARS = 2, | 86 | WC_UNICHARS = 2, /* -m */ |
87 | WC_CHARS = 3, | 87 | WC_BYTES = 3, /* -c */ |
88 | WC_LENGTH = 4, | 88 | WC_LENGTH = 4, /* -L */ |
89 | NUM_WCS = 5, | 89 | NUM_WCS = 5, |
90 | }; | 90 | }; |
91 | 91 | ||
@@ -104,10 +104,10 @@ int wc_main(int argc UNUSED_PARAM, char **argv) | |||
104 | 104 | ||
105 | init_unicode(); | 105 | init_unicode(); |
106 | 106 | ||
107 | print_type = getopt32(argv, "lwcmL"); | 107 | print_type = getopt32(argv, "lwmcL"); |
108 | 108 | ||
109 | if (print_type == 0) { | 109 | if (print_type == 0) { |
110 | print_type = (1 << WC_LINES) | (1 << WC_WORDS) | (1 << WC_CHARS); | 110 | print_type = (1 << WC_LINES) | (1 << WC_WORDS) | (1 << WC_BYTES); |
111 | } | 111 | } |
112 | 112 | ||
113 | argv += optind; | 113 | argv += optind; |
@@ -157,7 +157,7 @@ int wc_main(int argc UNUSED_PARAM, char **argv) | |||
157 | } | 157 | } |
158 | 158 | ||
159 | /* Cater for -c and -m */ | 159 | /* Cater for -c and -m */ |
160 | ++counts[WC_CHARS]; | 160 | ++counts[WC_BYTES]; |
161 | if (unicode_status != UNICODE_ON /* every byte is a new char */ | 161 | if (unicode_status != UNICODE_ON /* every byte is a new char */ |
162 | || (c & 0xc0) != 0x80 /* it isn't a 2nd+ byte of a Unicode char */ | 162 | || (c & 0xc0) != 0x80 /* it isn't a 2nd+ byte of a Unicode char */ |
163 | ) { | 163 | ) { |
diff --git a/coreutils/who.c b/coreutils/who.c index 8384d9534..ab1e30fc8 100644 --- a/coreutils/who.c +++ b/coreutils/who.c | |||
@@ -19,7 +19,6 @@ | |||
19 | /* BB_AUDIT SUSv3 _NOT_ compliant -- missing options -b, -d, -l, -m, -p, -q, -r, -s, -t, -T, -u; Missing argument 'file'. */ | 19 | /* BB_AUDIT SUSv3 _NOT_ compliant -- missing options -b, -d, -l, -m, -p, -q, -r, -s, -t, -T, -u; Missing argument 'file'. */ |
20 | 20 | ||
21 | #include "libbb.h" | 21 | #include "libbb.h" |
22 | #include <utmp.h> | ||
23 | 22 | ||
24 | static void idle_string(char *str6, time_t t) | 23 | static void idle_string(char *str6, time_t t) |
25 | { | 24 | { |
diff --git a/docs/new-applet-HOWTO.txt b/docs/new-applet-HOWTO.txt index bb29999cf..6a8054d0e 100644 --- a/docs/new-applet-HOWTO.txt +++ b/docs/new-applet-HOWTO.txt | |||
@@ -161,7 +161,7 @@ algorithm in busybox.c and the Gods of BusyBox smite you. Yea, verily: | |||
161 | Be sure to read the top of applets.src.h before adding your applet. | 161 | Be sure to read the top of applets.src.h before adding your applet. |
162 | 162 | ||
163 | /* all programs above here are alphabetically "less than" 'mu' */ | 163 | /* all programs above here are alphabetically "less than" 'mu' */ |
164 | IF_MU(APPLET(mu, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 164 | IF_MU(APPLET(mu, BB_DIR_USR_BIN, BB_SUID_DROP)) |
165 | /* all programs below here are alphabetically "greater than" 'mu' */ | 165 | /* all programs below here are alphabetically "greater than" 'mu' */ |
166 | 166 | ||
167 | 167 | ||
diff --git a/editors/patch.c b/editors/patch.c index 9c6d967b9..a90252a03 100644 --- a/editors/patch.c +++ b/editors/patch.c | |||
@@ -21,7 +21,7 @@ | |||
21 | * [file] which file to patch | 21 | * [file] which file to patch |
22 | */ | 22 | */ |
23 | 23 | ||
24 | //applet:IF_PATCH(APPLET(patch, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 24 | //applet:IF_PATCH(APPLET(patch, BB_DIR_USR_BIN, BB_SUID_DROP)) |
25 | 25 | ||
26 | //kbuild:lib-$(CONFIG_PATCH) += patch.o | 26 | //kbuild:lib-$(CONFIG_PATCH) += patch.o |
27 | 27 | ||
diff --git a/findutils/find.c b/findutils/find.c index dd00f37ea..f85381b47 100644 --- a/findutils/find.c +++ b/findutils/find.c | |||
@@ -53,7 +53,7 @@ | |||
53 | * diff -u /tmp/std_find /tmp/bb_find && echo Identical | 53 | * diff -u /tmp/std_find /tmp/bb_find && echo Identical |
54 | */ | 54 | */ |
55 | 55 | ||
56 | //applet:IF_FIND(APPLET_NOEXEC(find, find, _BB_DIR_USR_BIN, _BB_SUID_DROP, find)) | 56 | //applet:IF_FIND(APPLET_NOEXEC(find, find, BB_DIR_USR_BIN, BB_SUID_DROP, find)) |
57 | 57 | ||
58 | //kbuild:lib-$(CONFIG_FIND) += find.o | 58 | //kbuild:lib-$(CONFIG_FIND) += find.o |
59 | 59 | ||
diff --git a/findutils/grep.c b/findutils/grep.c index f166aa48a..f746210d2 100644 --- a/findutils/grep.c +++ b/findutils/grep.c | |||
@@ -18,9 +18,9 @@ | |||
18 | * (C) 2006 Jac Goudsmit added -o option | 18 | * (C) 2006 Jac Goudsmit added -o option |
19 | */ | 19 | */ |
20 | 20 | ||
21 | //applet:IF_GREP(APPLET(grep, _BB_DIR_BIN, _BB_SUID_DROP)) | 21 | //applet:IF_GREP(APPLET(grep, BB_DIR_BIN, BB_SUID_DROP)) |
22 | //applet:IF_FEATURE_GREP_EGREP_ALIAS(APPLET_ODDNAME(egrep, grep, _BB_DIR_BIN, _BB_SUID_DROP, egrep)) | 22 | //applet:IF_FEATURE_GREP_EGREP_ALIAS(APPLET_ODDNAME(egrep, grep, BB_DIR_BIN, BB_SUID_DROP, egrep)) |
23 | //applet:IF_FEATURE_GREP_FGREP_ALIAS(APPLET_ODDNAME(fgrep, grep, _BB_DIR_BIN, _BB_SUID_DROP, fgrep)) | 23 | //applet:IF_FEATURE_GREP_FGREP_ALIAS(APPLET_ODDNAME(fgrep, grep, BB_DIR_BIN, BB_SUID_DROP, fgrep)) |
24 | 24 | ||
25 | //kbuild:lib-$(CONFIG_GREP) += grep.o | 25 | //kbuild:lib-$(CONFIG_GREP) += grep.o |
26 | 26 | ||
diff --git a/findutils/xargs.c b/findutils/xargs.c index d73fad9de..0ec80f809 100644 --- a/findutils/xargs.c +++ b/findutils/xargs.c | |||
@@ -15,7 +15,7 @@ | |||
15 | * http://www.opengroup.org/onlinepubs/007904975/utilities/xargs.html | 15 | * http://www.opengroup.org/onlinepubs/007904975/utilities/xargs.html |
16 | */ | 16 | */ |
17 | 17 | ||
18 | //applet:IF_XARGS(APPLET_NOEXEC(xargs, xargs, _BB_DIR_USR_BIN, _BB_SUID_DROP, xargs)) | 18 | //applet:IF_XARGS(APPLET_NOEXEC(xargs, xargs, BB_DIR_USR_BIN, BB_SUID_DROP, xargs)) |
19 | 19 | ||
20 | //kbuild:lib-$(CONFIG_XARGS) += xargs.o | 20 | //kbuild:lib-$(CONFIG_XARGS) += xargs.o |
21 | 21 | ||
diff --git a/include/applets.src.h b/include/applets.src.h index 261ef2333..fa7d0cc55 100644 --- a/include/applets.src.h +++ b/include/applets.src.h | |||
@@ -12,12 +12,14 @@ name2 - applet name, converted to C (ether-wake: name2 = ether_wake) | |||
12 | main - corresponding <applet>_main to call (bzcat: main = bunzip2) | 12 | main - corresponding <applet>_main to call (bzcat: main = bunzip2) |
13 | l - location to install link to: [/usr]/[s]bin | 13 | l - location to install link to: [/usr]/[s]bin |
14 | s - suid type: | 14 | s - suid type: |
15 | _BB_SUID_REQUIRE: will complain if busybox isn't suid | 15 | BB_SUID_REQUIRE: will complain if busybox isn't suid |
16 | and is run by non-root (applet_main() will not be called at all) | 16 | and is run by non-root (applet_main() will not be called at all) |
17 | _BB_SUID_DROP: will drop suid prior to applet_main() | 17 | BB_SUID_DROP: will drop suid prior to applet_main() |
18 | _BB_SUID_MAYBE: neither of the above | 18 | BB_SUID_MAYBE: neither of the above |
19 | (every instance of _BB_SUID_REQUIRE and _BB_SUID_MAYBE | 19 | (every instance of BB_SUID_REQUIRE and BB_SUID_MAYBE |
20 | needs to be justified in comment) | 20 | needs to be justified in comment) |
21 | NB: please update FEATURE_SUID help text whenever you add/remove | ||
22 | BB_SUID_REQUIRE or BB_SUID_MAYBE applet. | ||
21 | */ | 23 | */ |
22 | 24 | ||
23 | #if defined(PROTOTYPES) | 25 | #if defined(PROTOTYPES) |
@@ -59,366 +61,363 @@ s - suid type: | |||
59 | #endif | 61 | #endif |
60 | 62 | ||
61 | #if ENABLE_INSTALL_NO_USR | 63 | #if ENABLE_INSTALL_NO_USR |
62 | # define _BB_DIR_USR_BIN _BB_DIR_BIN | 64 | # define BB_DIR_USR_BIN BB_DIR_BIN |
63 | # define _BB_DIR_USR_SBIN _BB_DIR_SBIN | 65 | # define BB_DIR_USR_SBIN BB_DIR_SBIN |
64 | #endif | 66 | #endif |
65 | 67 | ||
66 | 68 | ||
67 | INSERT | 69 | INSERT |
68 | IF_TEST(APPLET_NOFORK([, test, _BB_DIR_USR_BIN, _BB_SUID_DROP, test)) | 70 | IF_TEST(APPLET_NOFORK([, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) |
69 | IF_TEST(APPLET_NOFORK([[, test, _BB_DIR_USR_BIN, _BB_SUID_DROP, test)) | 71 | IF_TEST(APPLET_NOFORK([[, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) |
70 | IF_ACPID(APPLET(acpid, _BB_DIR_SBIN, _BB_SUID_DROP)) | 72 | IF_ACPID(APPLET(acpid, BB_DIR_SBIN, BB_SUID_DROP)) |
71 | IF_ADDGROUP(APPLET(addgroup, _BB_DIR_BIN, _BB_SUID_DROP)) | 73 | IF_ADDGROUP(APPLET(addgroup, BB_DIR_BIN, BB_SUID_DROP)) |
72 | IF_ADDUSER(APPLET(adduser, _BB_DIR_BIN, _BB_SUID_DROP)) | 74 | IF_ADDUSER(APPLET(adduser, BB_DIR_BIN, BB_SUID_DROP)) |
73 | IF_ADJTIMEX(APPLET(adjtimex, _BB_DIR_SBIN, _BB_SUID_DROP)) | 75 | IF_ADJTIMEX(APPLET(adjtimex, BB_DIR_SBIN, BB_SUID_DROP)) |
74 | IF_AR(APPLET(ar, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 76 | IF_AR(APPLET(ar, BB_DIR_USR_BIN, BB_SUID_DROP)) |
75 | IF_ARP(APPLET(arp, _BB_DIR_SBIN, _BB_SUID_DROP)) | 77 | IF_ARP(APPLET(arp, BB_DIR_SBIN, BB_SUID_DROP)) |
76 | IF_ARPING(APPLET(arping, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 78 | IF_ARPING(APPLET(arping, BB_DIR_USR_BIN, BB_SUID_DROP)) |
77 | IF_AWK(APPLET_NOEXEC(awk, awk, _BB_DIR_USR_BIN, _BB_SUID_DROP, awk)) | 79 | IF_AWK(APPLET_NOEXEC(awk, awk, BB_DIR_USR_BIN, BB_SUID_DROP, awk)) |
78 | IF_BASENAME(APPLET_NOFORK(basename, basename, _BB_DIR_USR_BIN, _BB_SUID_DROP, basename)) | 80 | IF_BASENAME(APPLET_NOFORK(basename, basename, BB_DIR_USR_BIN, BB_SUID_DROP, basename)) |
79 | IF_BBCONFIG(APPLET(bbconfig, _BB_DIR_BIN, _BB_SUID_DROP)) | 81 | IF_BBCONFIG(APPLET(bbconfig, BB_DIR_BIN, BB_SUID_DROP)) |
80 | IF_BEEP(APPLET(beep, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 82 | IF_BEEP(APPLET(beep, BB_DIR_USR_BIN, BB_SUID_DROP)) |
81 | IF_BLKID(APPLET(blkid, _BB_DIR_SBIN, _BB_SUID_DROP)) | 83 | IF_BLKID(APPLET(blkid, BB_DIR_SBIN, BB_SUID_DROP)) |
82 | IF_BRCTL(APPLET(brctl, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 84 | IF_BRCTL(APPLET(brctl, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
83 | IF_BZIP2(APPLET(bzip2, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 85 | IF_BZIP2(APPLET(bzip2, BB_DIR_USR_BIN, BB_SUID_DROP)) |
84 | IF_CAL(APPLET(cal, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 86 | IF_CAL(APPLET(cal, BB_DIR_USR_BIN, BB_SUID_DROP)) |
85 | IF_CAT(APPLET_NOFORK(cat, cat, _BB_DIR_BIN, _BB_SUID_DROP, cat)) | 87 | IF_CAT(APPLET_NOFORK(cat, cat, BB_DIR_BIN, BB_SUID_DROP, cat)) |
86 | IF_CATV(APPLET(catv, _BB_DIR_BIN, _BB_SUID_DROP)) | 88 | IF_CATV(APPLET(catv, BB_DIR_BIN, BB_SUID_DROP)) |
87 | IF_CHAT(APPLET(chat, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 89 | IF_CHAT(APPLET(chat, BB_DIR_USR_BIN, BB_SUID_DROP)) |
88 | IF_CHATTR(APPLET(chattr, _BB_DIR_BIN, _BB_SUID_DROP)) | 90 | IF_CHATTR(APPLET(chattr, BB_DIR_BIN, BB_SUID_DROP)) |
89 | IF_CHCON(APPLET(chcon, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 91 | IF_CHCON(APPLET(chcon, BB_DIR_USR_BIN, BB_SUID_DROP)) |
90 | IF_CHGRP(APPLET_NOEXEC(chgrp, chgrp, _BB_DIR_BIN, _BB_SUID_DROP, chgrp)) | 92 | IF_CHGRP(APPLET_NOEXEC(chgrp, chgrp, BB_DIR_BIN, BB_SUID_DROP, chgrp)) |
91 | IF_CHMOD(APPLET_NOEXEC(chmod, chmod, _BB_DIR_BIN, _BB_SUID_DROP, chmod)) | 93 | IF_CHMOD(APPLET_NOEXEC(chmod, chmod, BB_DIR_BIN, BB_SUID_DROP, chmod)) |
92 | IF_CHOWN(APPLET_NOEXEC(chown, chown, _BB_DIR_BIN, _BB_SUID_DROP, chown)) | 94 | IF_CHOWN(APPLET_NOEXEC(chown, chown, BB_DIR_BIN, BB_SUID_DROP, chown)) |
93 | IF_CHPASSWD(APPLET(chpasswd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 95 | IF_CHPASSWD(APPLET(chpasswd, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
94 | IF_CHPST(APPLET(chpst, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 96 | IF_CHPST(APPLET(chpst, BB_DIR_USR_BIN, BB_SUID_DROP)) |
95 | IF_CHROOT(APPLET(chroot, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 97 | IF_CHROOT(APPLET(chroot, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
96 | IF_CHRT(APPLET(chrt, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 98 | IF_CHRT(APPLET(chrt, BB_DIR_USR_BIN, BB_SUID_DROP)) |
97 | IF_CHVT(APPLET(chvt, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 99 | IF_CHVT(APPLET(chvt, BB_DIR_USR_BIN, BB_SUID_DROP)) |
98 | IF_CKSUM(APPLET_NOEXEC(cksum, cksum, _BB_DIR_USR_BIN, _BB_SUID_DROP, cksum)) | 100 | IF_CKSUM(APPLET_NOEXEC(cksum, cksum, BB_DIR_USR_BIN, BB_SUID_DROP, cksum)) |
99 | IF_CLEAR(APPLET(clear, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 101 | IF_CLEAR(APPLET(clear, BB_DIR_USR_BIN, BB_SUID_DROP)) |
100 | IF_CMP(APPLET(cmp, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 102 | IF_CMP(APPLET(cmp, BB_DIR_USR_BIN, BB_SUID_DROP)) |
101 | IF_COMM(APPLET(comm, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 103 | IF_COMM(APPLET(comm, BB_DIR_USR_BIN, BB_SUID_DROP)) |
102 | IF_CP(APPLET_NOEXEC(cp, cp, _BB_DIR_BIN, _BB_SUID_DROP, cp)) | 104 | IF_CP(APPLET_NOEXEC(cp, cp, BB_DIR_BIN, BB_SUID_DROP, cp)) |
103 | IF_CPIO(APPLET(cpio, _BB_DIR_BIN, _BB_SUID_DROP)) | 105 | IF_CPIO(APPLET(cpio, BB_DIR_BIN, BB_SUID_DROP)) |
104 | IF_CROND(APPLET(crond, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 106 | IF_CROND(APPLET(crond, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
105 | /* Needs to be run by root or be suid root - needs to change /var/spool/cron* files: */ | 107 | /* Needs to be run by root or be suid root - needs to change /var/spool/cron* files: */ |
106 | IF_CRONTAB(APPLET(crontab, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE)) | 108 | IF_CRONTAB(APPLET(crontab, BB_DIR_USR_BIN, BB_SUID_REQUIRE)) |
107 | IF_CRYPTPW(APPLET(cryptpw, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 109 | IF_CRYPTPW(APPLET(cryptpw, BB_DIR_USR_BIN, BB_SUID_DROP)) |
108 | IF_CUT(APPLET_NOEXEC(cut, cut, _BB_DIR_USR_BIN, _BB_SUID_DROP, cut)) | 110 | IF_CUT(APPLET_NOEXEC(cut, cut, BB_DIR_USR_BIN, BB_SUID_DROP, cut)) |
109 | IF_DC(APPLET(dc, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 111 | IF_DC(APPLET(dc, BB_DIR_USR_BIN, BB_SUID_DROP)) |
110 | IF_DD(APPLET_NOEXEC(dd, dd, _BB_DIR_BIN, _BB_SUID_DROP, dd)) | 112 | IF_DD(APPLET_NOEXEC(dd, dd, BB_DIR_BIN, BB_SUID_DROP, dd)) |
111 | IF_DEALLOCVT(APPLET(deallocvt, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 113 | IF_DEALLOCVT(APPLET(deallocvt, BB_DIR_USR_BIN, BB_SUID_DROP)) |
112 | IF_DELGROUP(APPLET_ODDNAME(delgroup, deluser, _BB_DIR_BIN, _BB_SUID_DROP, delgroup)) | 114 | IF_DELGROUP(APPLET_ODDNAME(delgroup, deluser, BB_DIR_BIN, BB_SUID_DROP, delgroup)) |
113 | IF_DELUSER(APPLET(deluser, _BB_DIR_BIN, _BB_SUID_DROP)) | 115 | IF_DELUSER(APPLET(deluser, BB_DIR_BIN, BB_SUID_DROP)) |
114 | IF_DEVFSD(APPLET(devfsd, _BB_DIR_SBIN, _BB_SUID_DROP)) | 116 | IF_DEVFSD(APPLET(devfsd, BB_DIR_SBIN, BB_SUID_DROP)) |
115 | IF_DEVMEM(APPLET(devmem, _BB_DIR_SBIN, _BB_SUID_DROP)) | 117 | IF_DEVMEM(APPLET(devmem, BB_DIR_SBIN, BB_SUID_DROP)) |
116 | IF_DF(APPLET(df, _BB_DIR_BIN, _BB_SUID_DROP)) | 118 | IF_DF(APPLET(df, BB_DIR_BIN, BB_SUID_DROP)) |
117 | IF_DHCPRELAY(APPLET(dhcprelay, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 119 | IF_DHCPRELAY(APPLET(dhcprelay, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
118 | IF_DIFF(APPLET(diff, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 120 | IF_DIFF(APPLET(diff, BB_DIR_USR_BIN, BB_SUID_DROP)) |
119 | IF_DIRNAME(APPLET_NOFORK(dirname, dirname, _BB_DIR_USR_BIN, _BB_SUID_DROP, dirname)) | 121 | IF_DIRNAME(APPLET_NOFORK(dirname, dirname, BB_DIR_USR_BIN, BB_SUID_DROP, dirname)) |
120 | IF_DMESG(APPLET(dmesg, _BB_DIR_BIN, _BB_SUID_DROP)) | 122 | IF_DMESG(APPLET(dmesg, BB_DIR_BIN, BB_SUID_DROP)) |
121 | /* Why _BB_SUID_REQUIRE? */ | 123 | IF_DNSD(APPLET(dnsd, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
122 | IF_DNSD(APPLET(dnsd, _BB_DIR_USR_SBIN, _BB_SUID_REQUIRE)) | 124 | IF_HOSTNAME(APPLET_ODDNAME(dnsdomainname, hostname, BB_DIR_BIN, BB_SUID_DROP, dnsdomainname)) |
123 | IF_HOSTNAME(APPLET_ODDNAME(dnsdomainname, hostname, _BB_DIR_BIN, _BB_SUID_DROP, dnsdomainname)) | 125 | IF_DOS2UNIX(APPLET_NOEXEC(dos2unix, dos2unix, BB_DIR_USR_BIN, BB_SUID_DROP, dos2unix)) |
124 | IF_DOS2UNIX(APPLET_NOEXEC(dos2unix, dos2unix, _BB_DIR_USR_BIN, _BB_SUID_DROP, dos2unix)) | 126 | IF_DPKG(APPLET(dpkg, BB_DIR_USR_BIN, BB_SUID_DROP)) |
125 | IF_DPKG(APPLET(dpkg, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 127 | IF_DPKG_DEB(APPLET_ODDNAME(dpkg-deb, dpkg_deb, BB_DIR_USR_BIN, BB_SUID_DROP, dpkg_deb)) |
126 | IF_DPKG_DEB(APPLET_ODDNAME(dpkg-deb, dpkg_deb, _BB_DIR_USR_BIN, _BB_SUID_DROP, dpkg_deb)) | 128 | IF_DU(APPLET(du, BB_DIR_USR_BIN, BB_SUID_DROP)) |
127 | IF_DU(APPLET(du, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 129 | IF_DUMPKMAP(APPLET(dumpkmap, BB_DIR_BIN, BB_SUID_DROP)) |
128 | IF_DUMPKMAP(APPLET(dumpkmap, _BB_DIR_BIN, _BB_SUID_DROP)) | 130 | IF_DUMPLEASES(APPLET(dumpleases, BB_DIR_USR_BIN, BB_SUID_DROP)) |
129 | IF_DUMPLEASES(APPLET(dumpleases, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 131 | //IF_E2FSCK(APPLET(e2fsck, BB_DIR_SBIN, BB_SUID_DROP)) |
130 | //IF_E2FSCK(APPLET(e2fsck, _BB_DIR_SBIN, _BB_SUID_DROP)) | 132 | //IF_E2LABEL(APPLET_ODDNAME(e2label, tune2fs, BB_DIR_SBIN, BB_SUID_DROP, e2label)) |
131 | //IF_E2LABEL(APPLET_ODDNAME(e2label, tune2fs, _BB_DIR_SBIN, _BB_SUID_DROP, e2label)) | 133 | IF_ECHO(APPLET_NOFORK(echo, echo, BB_DIR_BIN, BB_SUID_DROP, echo)) |
132 | IF_ECHO(APPLET_NOFORK(echo, echo, _BB_DIR_BIN, _BB_SUID_DROP, echo)) | 134 | IF_ED(APPLET(ed, BB_DIR_BIN, BB_SUID_DROP)) |
133 | IF_ED(APPLET(ed, _BB_DIR_BIN, _BB_SUID_DROP)) | 135 | IF_EJECT(APPLET(eject, BB_DIR_USR_BIN, BB_SUID_DROP)) |
134 | IF_EJECT(APPLET(eject, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 136 | IF_ENV(APPLET_NOEXEC(env, env, BB_DIR_USR_BIN, BB_SUID_DROP, env)) |
135 | IF_ENV(APPLET_NOEXEC(env, env, _BB_DIR_USR_BIN, _BB_SUID_DROP, env)) | 137 | IF_ENVDIR(APPLET_ODDNAME(envdir, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, envdir)) |
136 | IF_ENVDIR(APPLET_ODDNAME(envdir, chpst, _BB_DIR_USR_BIN, _BB_SUID_DROP, envdir)) | 138 | IF_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, envuidgid)) |
137 | IF_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, _BB_DIR_USR_BIN, _BB_SUID_DROP, envuidgid)) | 139 | IF_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, BB_DIR_USR_BIN, BB_SUID_DROP, ether_wake)) |
138 | IF_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, _BB_DIR_USR_BIN, _BB_SUID_DROP, ether_wake)) | 140 | IF_EXPAND(APPLET(expand, BB_DIR_USR_BIN, BB_SUID_DROP)) |
139 | IF_EXPAND(APPLET(expand, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 141 | IF_EXPR(APPLET(expr, BB_DIR_USR_BIN, BB_SUID_DROP)) |
140 | IF_EXPR(APPLET(expr, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 142 | IF_FAKEIDENTD(APPLET(fakeidentd, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
141 | IF_FAKEIDENTD(APPLET(fakeidentd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 143 | IF_FALSE(APPLET_NOFORK(false, false, BB_DIR_BIN, BB_SUID_DROP, false)) |
142 | IF_FALSE(APPLET_NOFORK(false, false, _BB_DIR_BIN, _BB_SUID_DROP, false)) | 144 | IF_FBSET(APPLET(fbset, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
143 | IF_FBSET(APPLET(fbset, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 145 | IF_FBSPLASH(APPLET(fbsplash, BB_DIR_SBIN, BB_SUID_DROP)) |
144 | IF_FBSPLASH(APPLET(fbsplash, _BB_DIR_SBIN, _BB_SUID_DROP)) | 146 | IF_FDFLUSH(APPLET_ODDNAME(fdflush, freeramdisk, BB_DIR_BIN, BB_SUID_DROP, fdflush)) |
145 | IF_FDFLUSH(APPLET_ODDNAME(fdflush, freeramdisk, _BB_DIR_BIN, _BB_SUID_DROP, fdflush)) | 147 | IF_FDFORMAT(APPLET(fdformat, BB_DIR_USR_BIN, BB_SUID_DROP)) |
146 | IF_FDFORMAT(APPLET(fdformat, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 148 | IF_FDISK(APPLET(fdisk, BB_DIR_SBIN, BB_SUID_DROP)) |
147 | IF_FDISK(APPLET(fdisk, _BB_DIR_SBIN, _BB_SUID_DROP)) | 149 | IF_FGCONSOLE(APPLET(fgconsole, BB_DIR_USR_BIN, BB_SUID_DROP)) |
148 | IF_FGCONSOLE(APPLET(fgconsole, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | ||
149 | /* Benefits from suid root: better access to /dev/BLOCKDEVs: */ | 150 | /* Benefits from suid root: better access to /dev/BLOCKDEVs: */ |
150 | IF_FINDFS(APPLET(findfs, _BB_DIR_SBIN, _BB_SUID_MAYBE)) | 151 | IF_FINDFS(APPLET(findfs, BB_DIR_SBIN, BB_SUID_MAYBE)) |
151 | IF_FLASH_ERASEALL(APPLET(flash_eraseall, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 152 | IF_FLASH_ERASEALL(APPLET(flash_eraseall, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
152 | IF_FLASH_LOCK(APPLET_ODDNAME(flash_lock, flash_lock_unlock, _BB_DIR_USR_SBIN, _BB_SUID_DROP, flash_lock)) | 153 | IF_FLASH_LOCK(APPLET_ODDNAME(flash_lock, flash_lock_unlock, BB_DIR_USR_SBIN, BB_SUID_DROP, flash_lock)) |
153 | IF_FLASH_UNLOCK(APPLET_ODDNAME(flash_unlock, flash_lock_unlock, _BB_DIR_USR_SBIN, _BB_SUID_DROP, flash_unlock)) | 154 | IF_FLASH_UNLOCK(APPLET_ODDNAME(flash_unlock, flash_lock_unlock, BB_DIR_USR_SBIN, BB_SUID_DROP, flash_unlock)) |
154 | IF_FLASHCP(APPLET(flashcp, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 155 | IF_FLASHCP(APPLET(flashcp, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
155 | IF_FLOCK(APPLET(flock, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 156 | IF_FLOCK(APPLET(flock, BB_DIR_USR_BIN, BB_SUID_DROP)) |
156 | IF_FOLD(APPLET_NOEXEC(fold, fold, _BB_DIR_USR_BIN, _BB_SUID_DROP, fold)) | 157 | IF_FOLD(APPLET_NOEXEC(fold, fold, BB_DIR_USR_BIN, BB_SUID_DROP, fold)) |
157 | IF_FREE(APPLET(free, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 158 | IF_FREE(APPLET(free, BB_DIR_USR_BIN, BB_SUID_DROP)) |
158 | IF_FREERAMDISK(APPLET(freeramdisk, _BB_DIR_SBIN, _BB_SUID_DROP)) | 159 | IF_FREERAMDISK(APPLET(freeramdisk, BB_DIR_SBIN, BB_SUID_DROP)) |
159 | IF_FSCK(APPLET(fsck, _BB_DIR_SBIN, _BB_SUID_DROP)) | 160 | IF_FSCK(APPLET(fsck, BB_DIR_SBIN, BB_SUID_DROP)) |
160 | //IF_E2FSCK(APPLET_ODDNAME(fsck.ext2, e2fsck, _BB_DIR_SBIN, _BB_SUID_DROP, fsck_ext2)) | 161 | //IF_E2FSCK(APPLET_ODDNAME(fsck.ext2, e2fsck, BB_DIR_SBIN, BB_SUID_DROP, fsck_ext2)) |
161 | //IF_E2FSCK(APPLET_ODDNAME(fsck.ext3, e2fsck, _BB_DIR_SBIN, _BB_SUID_DROP, fsck_ext3)) | 162 | //IF_E2FSCK(APPLET_ODDNAME(fsck.ext3, e2fsck, BB_DIR_SBIN, BB_SUID_DROP, fsck_ext3)) |
162 | IF_FSCK_MINIX(APPLET_ODDNAME(fsck.minix, fsck_minix, _BB_DIR_SBIN, _BB_SUID_DROP, fsck_minix)) | 163 | IF_FSCK_MINIX(APPLET_ODDNAME(fsck.minix, fsck_minix, BB_DIR_SBIN, BB_SUID_DROP, fsck_minix)) |
163 | IF_FSYNC(APPLET_NOFORK(fsync, fsync, _BB_DIR_BIN, _BB_SUID_DROP, fsync)) | 164 | IF_FSYNC(APPLET_NOFORK(fsync, fsync, BB_DIR_BIN, BB_SUID_DROP, fsync)) |
164 | IF_FTPD(APPLET(ftpd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 165 | IF_FTPD(APPLET(ftpd, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
165 | IF_FTPGET(APPLET_ODDNAME(ftpget, ftpgetput, _BB_DIR_USR_BIN, _BB_SUID_DROP, ftpget)) | 166 | IF_FTPGET(APPLET_ODDNAME(ftpget, ftpgetput, BB_DIR_USR_BIN, BB_SUID_DROP, ftpget)) |
166 | IF_FTPPUT(APPLET_ODDNAME(ftpput, ftpgetput, _BB_DIR_USR_BIN, _BB_SUID_DROP, ftpput)) | 167 | IF_FTPPUT(APPLET_ODDNAME(ftpput, ftpgetput, BB_DIR_USR_BIN, BB_SUID_DROP, ftpput)) |
167 | IF_FUSER(APPLET(fuser, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 168 | IF_FUSER(APPLET(fuser, BB_DIR_USR_BIN, BB_SUID_DROP)) |
168 | IF_GETENFORCE(APPLET(getenforce, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 169 | IF_GETENFORCE(APPLET(getenforce, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
169 | IF_GETOPT(APPLET(getopt, _BB_DIR_BIN, _BB_SUID_DROP)) | 170 | IF_GETOPT(APPLET(getopt, BB_DIR_BIN, BB_SUID_DROP)) |
170 | IF_GETSEBOOL(APPLET(getsebool, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 171 | IF_GETSEBOOL(APPLET(getsebool, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
171 | IF_GETTY(APPLET(getty, _BB_DIR_SBIN, _BB_SUID_DROP)) | 172 | IF_GETTY(APPLET(getty, BB_DIR_SBIN, BB_SUID_DROP)) |
172 | IF_GUNZIP(APPLET(gunzip, _BB_DIR_BIN, _BB_SUID_DROP)) | 173 | IF_GUNZIP(APPLET(gunzip, BB_DIR_BIN, BB_SUID_DROP)) |
173 | IF_GZIP(APPLET(gzip, _BB_DIR_BIN, _BB_SUID_DROP)) | 174 | IF_GZIP(APPLET(gzip, BB_DIR_BIN, BB_SUID_DROP)) |
174 | IF_HD(APPLET_NOEXEC(hd, hexdump, _BB_DIR_USR_BIN, _BB_SUID_DROP, hd)) | 175 | IF_HD(APPLET_NOEXEC(hd, hexdump, BB_DIR_USR_BIN, BB_SUID_DROP, hd)) |
175 | IF_HDPARM(APPLET(hdparm, _BB_DIR_SBIN, _BB_SUID_DROP)) | 176 | IF_HDPARM(APPLET(hdparm, BB_DIR_SBIN, BB_SUID_DROP)) |
176 | IF_HEAD(APPLET_NOEXEC(head, head, _BB_DIR_USR_BIN, _BB_SUID_DROP, head)) | 177 | IF_HEAD(APPLET_NOEXEC(head, head, BB_DIR_USR_BIN, BB_SUID_DROP, head)) |
177 | IF_HEXDUMP(APPLET_NOEXEC(hexdump, hexdump, _BB_DIR_USR_BIN, _BB_SUID_DROP, hexdump)) | 178 | IF_HEXDUMP(APPLET_NOEXEC(hexdump, hexdump, BB_DIR_USR_BIN, BB_SUID_DROP, hexdump)) |
178 | IF_HOSTID(APPLET_NOFORK(hostid, hostid, _BB_DIR_USR_BIN, _BB_SUID_DROP, hostid)) | 179 | IF_HOSTID(APPLET_NOFORK(hostid, hostid, BB_DIR_USR_BIN, BB_SUID_DROP, hostid)) |
179 | IF_HOSTNAME(APPLET(hostname, _BB_DIR_BIN, _BB_SUID_DROP)) | 180 | IF_HOSTNAME(APPLET(hostname, BB_DIR_BIN, BB_SUID_DROP)) |
180 | IF_HTTPD(APPLET(httpd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 181 | IF_HTTPD(APPLET(httpd, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
181 | IF_HWCLOCK(APPLET(hwclock, _BB_DIR_SBIN, _BB_SUID_DROP)) | 182 | IF_HWCLOCK(APPLET(hwclock, BB_DIR_SBIN, BB_SUID_DROP)) |
182 | IF_ID(APPLET_NOEXEC(id, id, _BB_DIR_USR_BIN, _BB_SUID_DROP, id)) | 183 | IF_ID(APPLET_NOEXEC(id, id, BB_DIR_USR_BIN, BB_SUID_DROP, id)) |
183 | IF_IFCONFIG(APPLET(ifconfig, _BB_DIR_SBIN, _BB_SUID_DROP)) | 184 | IF_IFCONFIG(APPLET(ifconfig, BB_DIR_SBIN, BB_SUID_DROP)) |
184 | IF_IFUPDOWN(APPLET_ODDNAME(ifdown, ifupdown, _BB_DIR_SBIN, _BB_SUID_DROP, ifdown)) | 185 | IF_IFUPDOWN(APPLET_ODDNAME(ifdown, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifdown)) |
185 | IF_IFENSLAVE(APPLET(ifenslave, _BB_DIR_SBIN, _BB_SUID_DROP)) | 186 | IF_IFENSLAVE(APPLET(ifenslave, BB_DIR_SBIN, BB_SUID_DROP)) |
186 | IF_IFPLUGD(APPLET(ifplugd, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 187 | IF_IFPLUGD(APPLET(ifplugd, BB_DIR_USR_BIN, BB_SUID_DROP)) |
187 | IF_IFUPDOWN(APPLET_ODDNAME(ifup, ifupdown, _BB_DIR_SBIN, _BB_SUID_DROP, ifup)) | 188 | IF_IFUPDOWN(APPLET_ODDNAME(ifup, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifup)) |
188 | IF_INETD(APPLET(inetd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 189 | IF_INETD(APPLET(inetd, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
189 | IF_INOTIFYD(APPLET(inotifyd, _BB_DIR_SBIN, _BB_SUID_DROP)) | 190 | IF_INOTIFYD(APPLET(inotifyd, BB_DIR_SBIN, BB_SUID_DROP)) |
190 | IF_INSTALL(APPLET(install, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 191 | IF_INSTALL(APPLET(install, BB_DIR_USR_BIN, BB_SUID_DROP)) |
191 | IF_IONICE(APPLET(ionice, _BB_DIR_BIN, _BB_SUID_DROP)) | 192 | IF_IONICE(APPLET(ionice, BB_DIR_BIN, BB_SUID_DROP)) |
192 | #if ENABLE_FEATURE_IP_ADDRESS \ | 193 | #if ENABLE_FEATURE_IP_ADDRESS \ |
193 | || ENABLE_FEATURE_IP_ROUTE \ | 194 | || ENABLE_FEATURE_IP_ROUTE \ |
194 | || ENABLE_FEATURE_IP_LINK \ | 195 | || ENABLE_FEATURE_IP_LINK \ |
195 | || ENABLE_FEATURE_IP_TUNNEL \ | 196 | || ENABLE_FEATURE_IP_TUNNEL \ |
196 | || ENABLE_FEATURE_IP_RULE | 197 | || ENABLE_FEATURE_IP_RULE |
197 | IF_IP(APPLET(ip, _BB_DIR_BIN, _BB_SUID_DROP)) | 198 | IF_IP(APPLET(ip, BB_DIR_BIN, BB_SUID_DROP)) |
198 | #endif | 199 | #endif |
199 | IF_IPADDR(APPLET(ipaddr, _BB_DIR_BIN, _BB_SUID_DROP)) | 200 | IF_IPADDR(APPLET(ipaddr, BB_DIR_BIN, BB_SUID_DROP)) |
200 | IF_IPCALC(APPLET(ipcalc, _BB_DIR_BIN, _BB_SUID_DROP)) | 201 | IF_IPCALC(APPLET(ipcalc, BB_DIR_BIN, BB_SUID_DROP)) |
201 | /* Why _BB_SUID_REQUIRE? On Fedora, it isn't suid root */ | 202 | IF_IPCRM(APPLET(ipcrm, BB_DIR_USR_BIN, BB_SUID_DROP)) |
202 | IF_IPCRM(APPLET(ipcrm, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE)) | 203 | IF_IPCS(APPLET(ipcs, BB_DIR_USR_BIN, BB_SUID_DROP)) |
203 | /* Why _BB_SUID_REQUIRE? On Fedora, it isn't suid root */ | 204 | IF_IPLINK(APPLET(iplink, BB_DIR_BIN, BB_SUID_DROP)) |
204 | IF_IPCS(APPLET(ipcs, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE)) | 205 | IF_IPROUTE(APPLET(iproute, BB_DIR_BIN, BB_SUID_DROP)) |
205 | IF_IPLINK(APPLET(iplink, _BB_DIR_BIN, _BB_SUID_DROP)) | 206 | IF_IPRULE(APPLET(iprule, BB_DIR_BIN, BB_SUID_DROP)) |
206 | IF_IPROUTE(APPLET(iproute, _BB_DIR_BIN, _BB_SUID_DROP)) | 207 | IF_IPTUNNEL(APPLET(iptunnel, BB_DIR_BIN, BB_SUID_DROP)) |
207 | IF_IPRULE(APPLET(iprule, _BB_DIR_BIN, _BB_SUID_DROP)) | 208 | IF_KBD_MODE(APPLET(kbd_mode, BB_DIR_USR_BIN, BB_SUID_DROP)) |
208 | IF_IPTUNNEL(APPLET(iptunnel, _BB_DIR_BIN, _BB_SUID_DROP)) | 209 | IF_KILL(APPLET(kill, BB_DIR_BIN, BB_SUID_DROP)) |
209 | IF_KBD_MODE(APPLET(kbd_mode, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 210 | IF_KILLALL(APPLET_ODDNAME(killall, kill, BB_DIR_USR_BIN, BB_SUID_DROP, killall)) |
210 | IF_KILL(APPLET(kill, _BB_DIR_BIN, _BB_SUID_DROP)) | 211 | IF_KILLALL5(APPLET_ODDNAME(killall5, kill, BB_DIR_USR_BIN, BB_SUID_DROP, killall5)) |
211 | IF_KILLALL(APPLET_ODDNAME(killall, kill, _BB_DIR_USR_BIN, _BB_SUID_DROP, killall)) | 212 | IF_KLOGD(APPLET(klogd, BB_DIR_SBIN, BB_SUID_DROP)) |
212 | IF_KILLALL5(APPLET_ODDNAME(killall5, kill, _BB_DIR_USR_BIN, _BB_SUID_DROP, killall5)) | 213 | IF_LAST(APPLET(last, BB_DIR_USR_BIN, BB_SUID_DROP)) |
213 | IF_KLOGD(APPLET(klogd, _BB_DIR_SBIN, _BB_SUID_DROP)) | 214 | IF_LENGTH(APPLET_NOFORK(length, length, BB_DIR_USR_BIN, BB_SUID_DROP, length)) |
214 | IF_LAST(APPLET(last, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 215 | IF_LESS(APPLET(less, BB_DIR_USR_BIN, BB_SUID_DROP)) |
215 | IF_LENGTH(APPLET_NOFORK(length, length, _BB_DIR_USR_BIN, _BB_SUID_DROP, length)) | 216 | IF_SETARCH(APPLET_ODDNAME(linux32, setarch, BB_DIR_BIN, BB_SUID_DROP, linux32)) |
216 | IF_LESS(APPLET(less, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 217 | IF_SETARCH(APPLET_ODDNAME(linux64, setarch, BB_DIR_BIN, BB_SUID_DROP, linux64)) |
217 | IF_SETARCH(APPLET_ODDNAME(linux32, setarch, _BB_DIR_BIN, _BB_SUID_DROP, linux32)) | 218 | IF_LN(APPLET_NOEXEC(ln, ln, BB_DIR_BIN, BB_SUID_DROP, ln)) |
218 | IF_SETARCH(APPLET_ODDNAME(linux64, setarch, _BB_DIR_BIN, _BB_SUID_DROP, linux64)) | 219 | IF_LOAD_POLICY(APPLET(load_policy, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
219 | IF_LN(APPLET_NOEXEC(ln, ln, _BB_DIR_BIN, _BB_SUID_DROP, ln)) | 220 | IF_LOADFONT(APPLET(loadfont, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
220 | IF_LOAD_POLICY(APPLET(load_policy, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 221 | IF_LOADKMAP(APPLET(loadkmap, BB_DIR_SBIN, BB_SUID_DROP)) |
221 | IF_LOADFONT(APPLET(loadfont, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 222 | IF_LOGGER(APPLET(logger, BB_DIR_USR_BIN, BB_SUID_DROP)) |
222 | IF_LOADKMAP(APPLET(loadkmap, _BB_DIR_SBIN, _BB_SUID_DROP)) | ||
223 | IF_LOGGER(APPLET(logger, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | ||
224 | /* Needs to be run by root or be suid root - needs to change uid and gid: */ | 223 | /* Needs to be run by root or be suid root - needs to change uid and gid: */ |
225 | IF_LOGIN(APPLET(login, _BB_DIR_BIN, _BB_SUID_REQUIRE)) | 224 | IF_LOGIN(APPLET(login, BB_DIR_BIN, BB_SUID_REQUIRE)) |
226 | IF_LOGNAME(APPLET_NOFORK(logname, logname, _BB_DIR_USR_BIN, _BB_SUID_DROP, logname)) | 225 | IF_LOGNAME(APPLET_NOFORK(logname, logname, BB_DIR_USR_BIN, BB_SUID_DROP, logname)) |
227 | IF_LOGREAD(APPLET(logread, _BB_DIR_SBIN, _BB_SUID_DROP)) | 226 | IF_LOGREAD(APPLET(logread, BB_DIR_SBIN, BB_SUID_DROP)) |
228 | IF_LOSETUP(APPLET(losetup, _BB_DIR_SBIN, _BB_SUID_DROP)) | 227 | IF_LOSETUP(APPLET(losetup, BB_DIR_SBIN, BB_SUID_DROP)) |
229 | IF_LPD(APPLET(lpd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 228 | IF_LPD(APPLET(lpd, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
230 | IF_LPQ(APPLET_ODDNAME(lpq, lpqr, _BB_DIR_USR_BIN, _BB_SUID_DROP, lpq)) | 229 | IF_LPQ(APPLET_ODDNAME(lpq, lpqr, BB_DIR_USR_BIN, BB_SUID_DROP, lpq)) |
231 | IF_LPR(APPLET_ODDNAME(lpr, lpqr, _BB_DIR_USR_BIN, _BB_SUID_DROP, lpr)) | 230 | IF_LPR(APPLET_ODDNAME(lpr, lpqr, BB_DIR_USR_BIN, BB_SUID_DROP, lpr)) |
232 | IF_LS(APPLET_NOEXEC(ls, ls, _BB_DIR_BIN, _BB_SUID_DROP, ls)) | 231 | IF_LS(APPLET_NOEXEC(ls, ls, BB_DIR_BIN, BB_SUID_DROP, ls)) |
233 | IF_LSATTR(APPLET(lsattr, _BB_DIR_BIN, _BB_SUID_DROP)) | 232 | IF_LSATTR(APPLET(lsattr, BB_DIR_BIN, BB_SUID_DROP)) |
234 | IF_LSPCI(APPLET(lspci, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 233 | IF_LSPCI(APPLET(lspci, BB_DIR_USR_BIN, BB_SUID_DROP)) |
235 | IF_LSUSB(APPLET(lsusb, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 234 | IF_LSUSB(APPLET(lsusb, BB_DIR_USR_BIN, BB_SUID_DROP)) |
236 | IF_UNLZMA(APPLET_ODDNAME(lzcat, unlzma, _BB_DIR_USR_BIN, _BB_SUID_DROP, lzcat)) | 235 | IF_UNLZMA(APPLET_ODDNAME(lzcat, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzcat)) |
237 | IF_LZMA(APPLET_ODDNAME(lzma, unlzma, _BB_DIR_USR_BIN, _BB_SUID_DROP, lzma)) | 236 | IF_LZMA(APPLET_ODDNAME(lzma, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzma)) |
238 | IF_LZOP(APPLET(lzop, _BB_DIR_BIN, _BB_SUID_DROP)) | 237 | IF_LZOP(APPLET(lzop, BB_DIR_BIN, BB_SUID_DROP)) |
239 | IF_LZOP(APPLET_ODDNAME(lzopcat, lzop, _BB_DIR_USR_BIN, _BB_SUID_DROP, lzopcat)) | 238 | IF_LZOP(APPLET_ODDNAME(lzopcat, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, lzopcat)) |
240 | IF_MAKEDEVS(APPLET(makedevs, _BB_DIR_SBIN, _BB_SUID_DROP)) | 239 | IF_MAKEDEVS(APPLET(makedevs, BB_DIR_SBIN, BB_SUID_DROP)) |
241 | IF_MAKEMIME(APPLET(makemime, _BB_DIR_BIN, _BB_SUID_DROP)) | 240 | IF_MAKEMIME(APPLET(makemime, BB_DIR_BIN, BB_SUID_DROP)) |
242 | IF_MAN(APPLET(man, _BB_DIR_SBIN, _BB_SUID_DROP)) | 241 | IF_MAN(APPLET(man, BB_DIR_SBIN, BB_SUID_DROP)) |
243 | IF_MATCHPATHCON(APPLET(matchpathcon, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 242 | IF_MATCHPATHCON(APPLET(matchpathcon, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
244 | IF_MD5SUM(APPLET_NOEXEC(md5sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_DROP, md5sum)) | 243 | IF_MD5SUM(APPLET_NOEXEC(md5sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, md5sum)) |
245 | IF_MDEV(APPLET(mdev, _BB_DIR_SBIN, _BB_SUID_DROP)) | 244 | IF_MDEV(APPLET(mdev, BB_DIR_SBIN, BB_SUID_DROP)) |
246 | IF_MICROCOM(APPLET(microcom, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 245 | IF_MICROCOM(APPLET(microcom, BB_DIR_USR_BIN, BB_SUID_DROP)) |
247 | IF_MKDIR(APPLET_NOFORK(mkdir, mkdir, _BB_DIR_BIN, _BB_SUID_DROP, mkdir)) | 246 | IF_MKDIR(APPLET_NOFORK(mkdir, mkdir, BB_DIR_BIN, BB_SUID_DROP, mkdir)) |
248 | IF_MKFS_VFAT(APPLET_ODDNAME(mkdosfs, mkfs_vfat, _BB_DIR_SBIN, _BB_SUID_DROP, mkfs_vfat)) | 247 | IF_MKFS_VFAT(APPLET_ODDNAME(mkdosfs, mkfs_vfat, BB_DIR_SBIN, BB_SUID_DROP, mkfs_vfat)) |
249 | IF_MKFS_EXT2(APPLET_ODDNAME(mke2fs, mkfs_ext2, _BB_DIR_SBIN, _BB_SUID_DROP, mkfs_ext2)) | 248 | IF_MKFS_EXT2(APPLET_ODDNAME(mke2fs, mkfs_ext2, BB_DIR_SBIN, BB_SUID_DROP, mkfs_ext2)) |
250 | IF_MKFIFO(APPLET_NOEXEC(mkfifo, mkfifo, _BB_DIR_USR_BIN, _BB_SUID_DROP, mkfifo)) | 249 | IF_MKFIFO(APPLET_NOEXEC(mkfifo, mkfifo, BB_DIR_USR_BIN, BB_SUID_DROP, mkfifo)) |
251 | IF_MKFS_EXT2(APPLET_ODDNAME(mkfs.ext2, mkfs_ext2, _BB_DIR_SBIN, _BB_SUID_DROP, mkfs_ext2)) | 250 | IF_MKFS_EXT2(APPLET_ODDNAME(mkfs.ext2, mkfs_ext2, BB_DIR_SBIN, BB_SUID_DROP, mkfs_ext2)) |
252 | //IF_MKE2FS(APPLET_ODDNAME(mkfs.ext3, mke2fs, _BB_DIR_SBIN, _BB_SUID_DROP, mkfs_ext3)) | 251 | //IF_MKE2FS(APPLET_ODDNAME(mkfs.ext3, mke2fs, BB_DIR_SBIN, BB_SUID_DROP, mkfs_ext3)) |
253 | IF_MKFS_MINIX(APPLET_ODDNAME(mkfs.minix, mkfs_minix, _BB_DIR_SBIN, _BB_SUID_DROP, mkfs_minix)) | 252 | IF_MKFS_MINIX(APPLET_ODDNAME(mkfs.minix, mkfs_minix, BB_DIR_SBIN, BB_SUID_DROP, mkfs_minix)) |
254 | IF_MKFS_REISER(APPLET_ODDNAME(mkfs.reiser, mkfs_reiser, _BB_DIR_SBIN, _BB_SUID_DROP, mkfs_reiser)) | 253 | IF_MKFS_REISER(APPLET_ODDNAME(mkfs.reiser, mkfs_reiser, BB_DIR_SBIN, BB_SUID_DROP, mkfs_reiser)) |
255 | IF_MKFS_VFAT(APPLET_ODDNAME(mkfs.vfat, mkfs_vfat, _BB_DIR_SBIN, _BB_SUID_DROP, mkfs_vfat)) | 254 | IF_MKFS_VFAT(APPLET_ODDNAME(mkfs.vfat, mkfs_vfat, BB_DIR_SBIN, BB_SUID_DROP, mkfs_vfat)) |
256 | IF_MKNOD(APPLET_NOEXEC(mknod, mknod, _BB_DIR_BIN, _BB_SUID_DROP, mknod)) | 255 | IF_MKNOD(APPLET_NOEXEC(mknod, mknod, BB_DIR_BIN, BB_SUID_DROP, mknod)) |
257 | IF_CRYPTPW(APPLET_ODDNAME(mkpasswd, cryptpw, _BB_DIR_USR_BIN, _BB_SUID_DROP, mkpasswd)) | 256 | IF_CRYPTPW(APPLET_ODDNAME(mkpasswd, cryptpw, BB_DIR_USR_BIN, BB_SUID_DROP, mkpasswd)) |
258 | IF_MKSWAP(APPLET(mkswap, _BB_DIR_SBIN, _BB_SUID_DROP)) | 257 | IF_MKSWAP(APPLET(mkswap, BB_DIR_SBIN, BB_SUID_DROP)) |
259 | IF_MKTEMP(APPLET(mktemp, _BB_DIR_BIN, _BB_SUID_DROP)) | 258 | IF_MKTEMP(APPLET(mktemp, BB_DIR_BIN, BB_SUID_DROP)) |
260 | IF_MORE(APPLET(more, _BB_DIR_BIN, _BB_SUID_DROP)) | 259 | IF_MORE(APPLET(more, BB_DIR_BIN, BB_SUID_DROP)) |
261 | /* On full-blown systems, requires suid for user mounts. | 260 | /* On full-blown systems, requires suid for user mounts. |
262 | * But it's not unthinkable to have it available in non-suid flavor on some systems, | 261 | * But it's not unthinkable to have it available in non-suid flavor on some systems, |
263 | * for viewing mount table. | 262 | * for viewing mount table. |
264 | * Therefore we use _BB_SUID_MAYBE instead of _BB_SUID_REQUIRE: */ | 263 | * Therefore we use BB_SUID_MAYBE instead of BB_SUID_REQUIRE: */ |
265 | IF_MOUNT(APPLET(mount, _BB_DIR_BIN, IF_DESKTOP(_BB_SUID_MAYBE) IF_NOT_DESKTOP(_BB_SUID_DROP))) | 264 | IF_MOUNT(APPLET(mount, BB_DIR_BIN, IF_DESKTOP(BB_SUID_MAYBE) IF_NOT_DESKTOP(BB_SUID_DROP))) |
266 | IF_MOUNTPOINT(APPLET(mountpoint, _BB_DIR_BIN, _BB_SUID_DROP)) | 265 | IF_MOUNTPOINT(APPLET(mountpoint, BB_DIR_BIN, BB_SUID_DROP)) |
267 | IF_MT(APPLET(mt, _BB_DIR_BIN, _BB_SUID_DROP)) | 266 | IF_MT(APPLET(mt, BB_DIR_BIN, BB_SUID_DROP)) |
268 | IF_MV(APPLET(mv, _BB_DIR_BIN, _BB_SUID_DROP)) | 267 | IF_MV(APPLET(mv, BB_DIR_BIN, BB_SUID_DROP)) |
269 | IF_NAMEIF(APPLET(nameif, _BB_DIR_SBIN, _BB_SUID_DROP)) | 268 | IF_NAMEIF(APPLET(nameif, BB_DIR_SBIN, BB_SUID_DROP)) |
270 | IF_NC(APPLET(nc, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 269 | IF_NC(APPLET(nc, BB_DIR_USR_BIN, BB_SUID_DROP)) |
271 | IF_NETSTAT(APPLET(netstat, _BB_DIR_BIN, _BB_SUID_DROP)) | 270 | IF_NETSTAT(APPLET(netstat, BB_DIR_BIN, BB_SUID_DROP)) |
272 | IF_NICE(APPLET(nice, _BB_DIR_BIN, _BB_SUID_DROP)) | 271 | IF_NICE(APPLET(nice, BB_DIR_BIN, BB_SUID_DROP)) |
273 | IF_NOHUP(APPLET(nohup, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 272 | IF_NOHUP(APPLET(nohup, BB_DIR_USR_BIN, BB_SUID_DROP)) |
274 | IF_NSLOOKUP(APPLET(nslookup, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 273 | IF_NSLOOKUP(APPLET(nslookup, BB_DIR_USR_BIN, BB_SUID_DROP)) |
275 | IF_NTPD(APPLET(ntpd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 274 | IF_NTPD(APPLET(ntpd, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
276 | IF_OD(APPLET(od, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 275 | IF_OD(APPLET(od, BB_DIR_USR_BIN, BB_SUID_DROP)) |
277 | IF_OPENVT(APPLET(openvt, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 276 | IF_OPENVT(APPLET(openvt, BB_DIR_USR_BIN, BB_SUID_DROP)) |
278 | //IF_PARSE(APPLET(parse, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 277 | //IF_PARSE(APPLET(parse, BB_DIR_USR_BIN, BB_SUID_DROP)) |
279 | /* Needs to be run by root or be suid root - needs to change /etc/{passwd,shadow}: */ | 278 | /* Needs to be run by root or be suid root - needs to change /etc/{passwd,shadow}: */ |
280 | IF_PASSWD(APPLET(passwd, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE)) | 279 | IF_PASSWD(APPLET(passwd, BB_DIR_USR_BIN, BB_SUID_REQUIRE)) |
281 | IF_PGREP(APPLET(pgrep, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 280 | IF_PGREP(APPLET(pgrep, BB_DIR_USR_BIN, BB_SUID_DROP)) |
282 | IF_PIDOF(APPLET(pidof, _BB_DIR_BIN, _BB_SUID_DROP)) | 281 | IF_PIDOF(APPLET(pidof, BB_DIR_BIN, BB_SUID_DROP)) |
283 | IF_PIPE_PROGRESS(APPLET(pipe_progress, _BB_DIR_BIN, _BB_SUID_DROP)) | 282 | IF_PIPE_PROGRESS(APPLET(pipe_progress, BB_DIR_BIN, BB_SUID_DROP)) |
284 | IF_PIVOT_ROOT(APPLET(pivot_root, _BB_DIR_SBIN, _BB_SUID_DROP)) | 283 | IF_PIVOT_ROOT(APPLET(pivot_root, BB_DIR_SBIN, BB_SUID_DROP)) |
285 | IF_PKILL(APPLET_ODDNAME(pkill, pgrep, _BB_DIR_USR_BIN, _BB_SUID_DROP, pkill)) | 284 | IF_PKILL(APPLET_ODDNAME(pkill, pgrep, BB_DIR_USR_BIN, BB_SUID_DROP, pkill)) |
286 | IF_POPMAILDIR(APPLET(popmaildir, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 285 | IF_POPMAILDIR(APPLET(popmaildir, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
287 | IF_PRINTENV(APPLET_NOFORK(printenv, printenv, _BB_DIR_BIN, _BB_SUID_DROP, printenv)) | 286 | IF_PRINTENV(APPLET_NOFORK(printenv, printenv, BB_DIR_BIN, BB_SUID_DROP, printenv)) |
288 | IF_PRINTF(APPLET_NOFORK(printf, printf, _BB_DIR_USR_BIN, _BB_SUID_DROP, printf)) | 287 | IF_PRINTF(APPLET_NOFORK(printf, printf, BB_DIR_USR_BIN, BB_SUID_DROP, printf)) |
289 | IF_PS(APPLET(ps, _BB_DIR_BIN, _BB_SUID_DROP)) | 288 | IF_PS(APPLET(ps, BB_DIR_BIN, BB_SUID_DROP)) |
290 | IF_PSCAN(APPLET(pscan, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 289 | IF_PSCAN(APPLET(pscan, BB_DIR_USR_BIN, BB_SUID_DROP)) |
291 | IF_PWD(APPLET_NOFORK(pwd, pwd, _BB_DIR_BIN, _BB_SUID_DROP, pwd)) | 290 | IF_PWD(APPLET_NOFORK(pwd, pwd, BB_DIR_BIN, BB_SUID_DROP, pwd)) |
292 | IF_RAIDAUTORUN(APPLET(raidautorun, _BB_DIR_SBIN, _BB_SUID_DROP)) | 291 | IF_RAIDAUTORUN(APPLET(raidautorun, BB_DIR_SBIN, BB_SUID_DROP)) |
293 | IF_RDATE(APPLET(rdate, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 292 | IF_RDATE(APPLET(rdate, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
294 | IF_RDEV(APPLET(rdev, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 293 | IF_RDEV(APPLET(rdev, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
295 | IF_READAHEAD(APPLET(readahead, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 294 | IF_READAHEAD(APPLET(readahead, BB_DIR_USR_BIN, BB_SUID_DROP)) |
296 | IF_READLINK(APPLET(readlink, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 295 | IF_READLINK(APPLET(readlink, BB_DIR_USR_BIN, BB_SUID_DROP)) |
297 | IF_READPROFILE(APPLET(readprofile, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 296 | IF_READPROFILE(APPLET(readprofile, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
298 | IF_REALPATH(APPLET(realpath, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 297 | IF_REALPATH(APPLET(realpath, BB_DIR_USR_BIN, BB_SUID_DROP)) |
299 | IF_REFORMIME(APPLET(reformime, _BB_DIR_BIN, _BB_SUID_DROP)) | 298 | IF_REFORMIME(APPLET(reformime, BB_DIR_BIN, BB_SUID_DROP)) |
300 | IF_RENICE(APPLET(renice, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 299 | IF_RENICE(APPLET(renice, BB_DIR_USR_BIN, BB_SUID_DROP)) |
301 | IF_RESET(APPLET(reset, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 300 | IF_RESET(APPLET(reset, BB_DIR_USR_BIN, BB_SUID_DROP)) |
302 | IF_RESIZE(APPLET(resize, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 301 | IF_RESIZE(APPLET(resize, BB_DIR_USR_BIN, BB_SUID_DROP)) |
303 | IF_RESTORECON(APPLET_ODDNAME(restorecon, setfiles, _BB_DIR_SBIN, _BB_SUID_DROP, restorecon)) | 302 | IF_RESTORECON(APPLET_ODDNAME(restorecon, setfiles, BB_DIR_SBIN, BB_SUID_DROP, restorecon)) |
304 | IF_RFKILL(APPLET(rfkill, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 303 | IF_RFKILL(APPLET(rfkill, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
305 | IF_RM(APPLET_NOFORK(rm, rm, _BB_DIR_BIN, _BB_SUID_DROP, rm)) | 304 | IF_RM(APPLET_NOFORK(rm, rm, BB_DIR_BIN, BB_SUID_DROP, rm)) |
306 | IF_RMDIR(APPLET_NOFORK(rmdir, rmdir, _BB_DIR_BIN, _BB_SUID_DROP, rmdir)) | 305 | IF_RMDIR(APPLET_NOFORK(rmdir, rmdir, BB_DIR_BIN, BB_SUID_DROP, rmdir)) |
307 | IF_ROUTE(APPLET(route, _BB_DIR_SBIN, _BB_SUID_DROP)) | 306 | IF_ROUTE(APPLET(route, BB_DIR_SBIN, BB_SUID_DROP)) |
308 | IF_RPM(APPLET(rpm, _BB_DIR_BIN, _BB_SUID_DROP)) | 307 | IF_RPM(APPLET(rpm, BB_DIR_BIN, BB_SUID_DROP)) |
309 | IF_RPM2CPIO(APPLET(rpm2cpio, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 308 | IF_RPM2CPIO(APPLET(rpm2cpio, BB_DIR_USR_BIN, BB_SUID_DROP)) |
310 | IF_RTCWAKE(APPLET(rtcwake, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 309 | IF_RTCWAKE(APPLET(rtcwake, BB_DIR_USR_BIN, BB_SUID_DROP)) |
311 | IF_RUN_PARTS(APPLET_ODDNAME(run-parts, run_parts, _BB_DIR_BIN, _BB_SUID_DROP, run_parts)) | 310 | IF_RUN_PARTS(APPLET_ODDNAME(run-parts, run_parts, BB_DIR_BIN, BB_SUID_DROP, run_parts)) |
312 | IF_RUNCON(APPLET(runcon, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 311 | IF_RUNCON(APPLET(runcon, BB_DIR_USR_BIN, BB_SUID_DROP)) |
313 | IF_RUNLEVEL(APPLET(runlevel, _BB_DIR_SBIN, _BB_SUID_DROP)) | 312 | IF_RUNLEVEL(APPLET(runlevel, BB_DIR_SBIN, BB_SUID_DROP)) |
314 | IF_RUNSV(APPLET(runsv, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 313 | IF_RUNSV(APPLET(runsv, BB_DIR_USR_BIN, BB_SUID_DROP)) |
315 | IF_RUNSVDIR(APPLET(runsvdir, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 314 | IF_RUNSVDIR(APPLET(runsvdir, BB_DIR_USR_BIN, BB_SUID_DROP)) |
316 | IF_RX(APPLET(rx, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 315 | IF_RX(APPLET(rx, BB_DIR_USR_BIN, BB_SUID_DROP)) |
317 | IF_SCRIPT(APPLET(script, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 316 | IF_SCRIPT(APPLET(script, BB_DIR_USR_BIN, BB_SUID_DROP)) |
318 | IF_SCRIPTREPLAY(APPLET(scriptreplay, _BB_DIR_BIN, _BB_SUID_DROP)) | 317 | IF_SCRIPTREPLAY(APPLET(scriptreplay, BB_DIR_BIN, BB_SUID_DROP)) |
319 | IF_SED(APPLET(sed, _BB_DIR_BIN, _BB_SUID_DROP)) | 318 | IF_SED(APPLET(sed, BB_DIR_BIN, BB_SUID_DROP)) |
320 | IF_SELINUXENABLED(APPLET(selinuxenabled, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 319 | IF_SELINUXENABLED(APPLET(selinuxenabled, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
321 | IF_SENDMAIL(APPLET(sendmail, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 320 | IF_SENDMAIL(APPLET(sendmail, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
322 | IF_SEQ(APPLET_NOFORK(seq, seq, _BB_DIR_USR_BIN, _BB_SUID_DROP, seq)) | 321 | IF_SEQ(APPLET_NOFORK(seq, seq, BB_DIR_USR_BIN, BB_SUID_DROP, seq)) |
323 | IF_SESTATUS(APPLET(sestatus, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 322 | IF_SESTATUS(APPLET(sestatus, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
324 | IF_SETARCH(APPLET(setarch, _BB_DIR_BIN, _BB_SUID_DROP)) | 323 | IF_SETARCH(APPLET(setarch, BB_DIR_BIN, BB_SUID_DROP)) |
325 | IF_SETCONSOLE(APPLET(setconsole, _BB_DIR_SBIN, _BB_SUID_DROP)) | 324 | IF_SETCONSOLE(APPLET(setconsole, BB_DIR_SBIN, BB_SUID_DROP)) |
326 | IF_SETENFORCE(APPLET(setenforce, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 325 | IF_SETENFORCE(APPLET(setenforce, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
327 | IF_SETFILES(APPLET(setfiles, _BB_DIR_SBIN, _BB_SUID_DROP)) | 326 | IF_SETFILES(APPLET(setfiles, BB_DIR_SBIN, BB_SUID_DROP)) |
328 | IF_SETFONT(APPLET(setfont, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 327 | IF_SETFONT(APPLET(setfont, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
329 | IF_SETKEYCODES(APPLET(setkeycodes, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 328 | IF_SETKEYCODES(APPLET(setkeycodes, BB_DIR_USR_BIN, BB_SUID_DROP)) |
330 | IF_SETLOGCONS(APPLET(setlogcons, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 329 | IF_SETLOGCONS(APPLET(setlogcons, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
331 | IF_SETSEBOOL(APPLET(setsebool, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 330 | IF_SETSEBOOL(APPLET(setsebool, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
332 | IF_SETSID(APPLET(setsid, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 331 | IF_SETSID(APPLET(setsid, BB_DIR_USR_BIN, BB_SUID_DROP)) |
333 | IF_SETUIDGID(APPLET_ODDNAME(setuidgid, chpst, _BB_DIR_USR_BIN, _BB_SUID_DROP, setuidgid)) | 332 | IF_SETUIDGID(APPLET_ODDNAME(setuidgid, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, setuidgid)) |
334 | IF_SHA1SUM(APPLET_NOEXEC(sha1sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_DROP, sha1sum)) | 333 | IF_SHA1SUM(APPLET_NOEXEC(sha1sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha1sum)) |
335 | IF_SHA256SUM(APPLET_NOEXEC(sha256sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_DROP, sha256sum)) | 334 | IF_SHA256SUM(APPLET_NOEXEC(sha256sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha256sum)) |
336 | IF_SHA512SUM(APPLET_NOEXEC(sha512sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_DROP, sha512sum)) | 335 | IF_SHA512SUM(APPLET_NOEXEC(sha512sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha512sum)) |
337 | IF_SHOWKEY(APPLET(showkey, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 336 | IF_SHOWKEY(APPLET(showkey, BB_DIR_USR_BIN, BB_SUID_DROP)) |
338 | IF_SLATTACH(APPLET(slattach, _BB_DIR_SBIN, _BB_SUID_DROP)) | 337 | IF_SLATTACH(APPLET(slattach, BB_DIR_SBIN, BB_SUID_DROP)) |
339 | /* Do not make this applet NOFORK. It breaks ^C-ing of pauses in shells: */ | 338 | /* Do not make this applet NOFORK. It breaks ^C-ing of pauses in shells: */ |
340 | IF_SLEEP(APPLET(sleep, _BB_DIR_BIN, _BB_SUID_DROP)) | 339 | IF_SLEEP(APPLET(sleep, BB_DIR_BIN, BB_SUID_DROP)) |
341 | IF_SOFTLIMIT(APPLET_ODDNAME(softlimit, chpst, _BB_DIR_USR_BIN, _BB_SUID_DROP, softlimit)) | 340 | IF_SOFTLIMIT(APPLET_ODDNAME(softlimit, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, softlimit)) |
342 | IF_SORT(APPLET_NOEXEC(sort, sort, _BB_DIR_USR_BIN, _BB_SUID_DROP, sort)) | 341 | IF_SORT(APPLET_NOEXEC(sort, sort, BB_DIR_USR_BIN, BB_SUID_DROP, sort)) |
343 | IF_SPLIT(APPLET(split, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 342 | IF_SPLIT(APPLET(split, BB_DIR_USR_BIN, BB_SUID_DROP)) |
344 | IF_START_STOP_DAEMON(APPLET_ODDNAME(start-stop-daemon, start_stop_daemon, _BB_DIR_SBIN, _BB_SUID_DROP, start_stop_daemon)) | 343 | IF_START_STOP_DAEMON(APPLET_ODDNAME(start-stop-daemon, start_stop_daemon, BB_DIR_SBIN, BB_SUID_DROP, start_stop_daemon)) |
345 | IF_STAT(APPLET(stat, _BB_DIR_BIN, _BB_SUID_DROP)) | 344 | IF_STAT(APPLET(stat, BB_DIR_BIN, BB_SUID_DROP)) |
346 | IF_STRINGS(APPLET(strings, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 345 | IF_STRINGS(APPLET(strings, BB_DIR_USR_BIN, BB_SUID_DROP)) |
347 | IF_STTY(APPLET(stty, _BB_DIR_BIN, _BB_SUID_DROP)) | 346 | IF_STTY(APPLET(stty, BB_DIR_BIN, BB_SUID_DROP)) |
348 | /* Needs to be run by root or be suid root - needs to change uid and gid: */ | 347 | /* Needs to be run by root or be suid root - needs to change uid and gid: */ |
349 | IF_SU(APPLET(su, _BB_DIR_BIN, _BB_SUID_REQUIRE)) | 348 | IF_SU(APPLET(su, BB_DIR_BIN, BB_SUID_REQUIRE)) |
350 | IF_SULOGIN(APPLET(sulogin, _BB_DIR_SBIN, _BB_SUID_DROP)) | 349 | IF_SULOGIN(APPLET(sulogin, BB_DIR_SBIN, BB_SUID_DROP)) |
351 | IF_SUM(APPLET(sum, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 350 | IF_SUM(APPLET(sum, BB_DIR_USR_BIN, BB_SUID_DROP)) |
352 | IF_SV(APPLET(sv, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 351 | IF_SV(APPLET(sv, BB_DIR_USR_BIN, BB_SUID_DROP)) |
353 | IF_SVLOGD(APPLET(svlogd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 352 | IF_SVLOGD(APPLET(svlogd, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
354 | IF_SWAPONOFF(APPLET_ODDNAME(swapoff, swap_on_off, _BB_DIR_SBIN, _BB_SUID_DROP, swapoff)) | 353 | IF_SWAPONOFF(APPLET_ODDNAME(swapoff, swap_on_off, BB_DIR_SBIN, BB_SUID_DROP, swapoff)) |
355 | IF_SWAPONOFF(APPLET_ODDNAME(swapon, swap_on_off, _BB_DIR_SBIN, _BB_SUID_DROP, swapon)) | 354 | IF_SWAPONOFF(APPLET_ODDNAME(swapon, swap_on_off, BB_DIR_SBIN, BB_SUID_DROP, swapon)) |
356 | IF_SWITCH_ROOT(APPLET(switch_root, _BB_DIR_SBIN, _BB_SUID_DROP)) | 355 | IF_SWITCH_ROOT(APPLET(switch_root, BB_DIR_SBIN, BB_SUID_DROP)) |
357 | IF_SYNC(APPLET_NOFORK(sync, sync, _BB_DIR_BIN, _BB_SUID_DROP, sync)) | 356 | IF_SYNC(APPLET_NOFORK(sync, sync, BB_DIR_BIN, BB_SUID_DROP, sync)) |
358 | IF_BB_SYSCTL(APPLET(sysctl, _BB_DIR_SBIN, _BB_SUID_DROP)) | 357 | IF_BB_SYSCTL(APPLET(sysctl, BB_DIR_SBIN, BB_SUID_DROP)) |
359 | IF_SYSLOGD(APPLET(syslogd, _BB_DIR_SBIN, _BB_SUID_DROP)) | 358 | IF_SYSLOGD(APPLET(syslogd, BB_DIR_SBIN, BB_SUID_DROP)) |
360 | IF_TAC(APPLET_NOEXEC(tac, tac, _BB_DIR_USR_BIN, _BB_SUID_DROP, tac)) | 359 | IF_TAC(APPLET_NOEXEC(tac, tac, BB_DIR_USR_BIN, BB_SUID_DROP, tac)) |
361 | IF_TAIL(APPLET(tail, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 360 | IF_TAIL(APPLET(tail, BB_DIR_USR_BIN, BB_SUID_DROP)) |
362 | IF_TAR(APPLET(tar, _BB_DIR_BIN, _BB_SUID_DROP)) | 361 | IF_TAR(APPLET(tar, BB_DIR_BIN, BB_SUID_DROP)) |
363 | IF_TASKSET(APPLET(taskset, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 362 | IF_TASKSET(APPLET(taskset, BB_DIR_USR_BIN, BB_SUID_DROP)) |
364 | /* IF_TC(APPLET(tc, _BB_DIR_SBIN, _BB_SUID_DROP)) */ | 363 | /* IF_TC(APPLET(tc, BB_DIR_SBIN, BB_SUID_DROP)) */ |
365 | IF_TCPSVD(APPLET_ODDNAME(tcpsvd, tcpudpsvd, _BB_DIR_USR_BIN, _BB_SUID_DROP, tcpsvd)) | 364 | IF_TCPSVD(APPLET_ODDNAME(tcpsvd, tcpudpsvd, BB_DIR_USR_BIN, BB_SUID_DROP, tcpsvd)) |
366 | IF_TEE(APPLET(tee, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 365 | IF_TEE(APPLET(tee, BB_DIR_USR_BIN, BB_SUID_DROP)) |
367 | IF_TELNET(APPLET(telnet, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 366 | IF_TELNET(APPLET(telnet, BB_DIR_USR_BIN, BB_SUID_DROP)) |
368 | IF_TELNETD(APPLET(telnetd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 367 | IF_TELNETD(APPLET(telnetd, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
369 | IF_TEST(APPLET_NOFORK(test, test, _BB_DIR_USR_BIN, _BB_SUID_DROP, test)) | 368 | IF_TEST(APPLET_NOFORK(test, test, BB_DIR_USR_BIN, BB_SUID_DROP, test)) |
370 | #if ENABLE_FEATURE_TFTP_GET || ENABLE_FEATURE_TFTP_PUT | 369 | #if ENABLE_FEATURE_TFTP_GET || ENABLE_FEATURE_TFTP_PUT |
371 | IF_TFTP(APPLET(tftp, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 370 | IF_TFTP(APPLET(tftp, BB_DIR_USR_BIN, BB_SUID_DROP)) |
372 | IF_TFTPD(APPLET(tftpd, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 371 | IF_TFTPD(APPLET(tftpd, BB_DIR_USR_BIN, BB_SUID_DROP)) |
373 | #endif | 372 | #endif |
374 | IF_TIME(APPLET(time, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 373 | IF_TIME(APPLET(time, BB_DIR_USR_BIN, BB_SUID_DROP)) |
375 | IF_TIMEOUT(APPLET(timeout, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 374 | IF_TIMEOUT(APPLET(timeout, BB_DIR_USR_BIN, BB_SUID_DROP)) |
376 | IF_TOP(APPLET(top, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 375 | IF_TOP(APPLET(top, BB_DIR_USR_BIN, BB_SUID_DROP)) |
377 | IF_TR(APPLET(tr, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 376 | IF_TR(APPLET(tr, BB_DIR_USR_BIN, BB_SUID_DROP)) |
378 | /* Needs socket(AF_INET, SOCK_RAW, IPPROTO_ICMP), therefore _BB_SUID_MAYBE: */ | 377 | /* Needs socket(AF_INET, SOCK_RAW, IPPROTO_ICMP), therefore BB_SUID_MAYBE: */ |
379 | IF_TRACEROUTE(APPLET(traceroute, _BB_DIR_USR_BIN, _BB_SUID_MAYBE)) | 378 | IF_TRACEROUTE(APPLET(traceroute, BB_DIR_USR_BIN, BB_SUID_MAYBE)) |
380 | IF_TRACEROUTE6(APPLET(traceroute6, _BB_DIR_USR_BIN, _BB_SUID_MAYBE)) | 379 | IF_TRACEROUTE6(APPLET(traceroute6, BB_DIR_USR_BIN, BB_SUID_MAYBE)) |
381 | IF_TRUE(APPLET_NOFORK(true, true, _BB_DIR_BIN, _BB_SUID_DROP, true)) | 380 | IF_TRUE(APPLET_NOFORK(true, true, BB_DIR_BIN, BB_SUID_DROP, true)) |
382 | IF_TTY(APPLET(tty, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 381 | IF_TTY(APPLET(tty, BB_DIR_USR_BIN, BB_SUID_DROP)) |
383 | IF_TTYSIZE(APPLET(ttysize, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 382 | IF_TTYSIZE(APPLET(ttysize, BB_DIR_USR_BIN, BB_SUID_DROP)) |
384 | IF_TUNCTL(APPLET(tunctl, _BB_DIR_SBIN, _BB_SUID_DROP)) | 383 | IF_TUNCTL(APPLET(tunctl, BB_DIR_SBIN, BB_SUID_DROP)) |
385 | IF_TUNE2FS(APPLET(tune2fs, _BB_DIR_SBIN, _BB_SUID_DROP)) | 384 | IF_TUNE2FS(APPLET(tune2fs, BB_DIR_SBIN, BB_SUID_DROP)) |
386 | IF_UDHCPC(APPLET(udhcpc, _BB_DIR_SBIN, _BB_SUID_DROP)) | 385 | IF_UDHCPC(APPLET(udhcpc, BB_DIR_SBIN, BB_SUID_DROP)) |
387 | IF_UDHCPD(APPLET(udhcpd, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 386 | IF_UDHCPD(APPLET(udhcpd, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
388 | IF_UDPSVD(APPLET_ODDNAME(udpsvd, tcpudpsvd, _BB_DIR_USR_BIN, _BB_SUID_DROP, udpsvd)) | 387 | IF_UDPSVD(APPLET_ODDNAME(udpsvd, tcpudpsvd, BB_DIR_USR_BIN, BB_SUID_DROP, udpsvd)) |
389 | IF_UMOUNT(APPLET(umount, _BB_DIR_BIN, _BB_SUID_DROP)) | 388 | IF_UMOUNT(APPLET(umount, BB_DIR_BIN, BB_SUID_DROP)) |
390 | IF_UNAME(APPLET(uname, _BB_DIR_BIN, _BB_SUID_DROP)) | 389 | IF_UNAME(APPLET(uname, BB_DIR_BIN, BB_SUID_DROP)) |
391 | IF_UNCOMPRESS(APPLET(uncompress, _BB_DIR_BIN, _BB_SUID_DROP)) | 390 | IF_UNCOMPRESS(APPLET(uncompress, BB_DIR_BIN, BB_SUID_DROP)) |
392 | IF_UNEXPAND(APPLET_ODDNAME(unexpand, expand, _BB_DIR_USR_BIN, _BB_SUID_DROP, unexpand)) | 391 | IF_UNEXPAND(APPLET_ODDNAME(unexpand, expand, BB_DIR_USR_BIN, BB_SUID_DROP, unexpand)) |
393 | IF_UNIQ(APPLET(uniq, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 392 | IF_UNIQ(APPLET(uniq, BB_DIR_USR_BIN, BB_SUID_DROP)) |
394 | IF_UNIX2DOS(APPLET_NOEXEC(unix2dos, dos2unix, _BB_DIR_USR_BIN, _BB_SUID_DROP, unix2dos)) | 393 | IF_UNIX2DOS(APPLET_NOEXEC(unix2dos, dos2unix, BB_DIR_USR_BIN, BB_SUID_DROP, unix2dos)) |
395 | IF_UNXZ(APPLET(unxz, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 394 | IF_UNXZ(APPLET(unxz, BB_DIR_USR_BIN, BB_SUID_DROP)) |
396 | IF_UNLZMA(APPLET(unlzma, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 395 | IF_UNLZMA(APPLET(unlzma, BB_DIR_USR_BIN, BB_SUID_DROP)) |
397 | IF_LZOP(APPLET_ODDNAME(unlzop, lzop, _BB_DIR_USR_BIN, _BB_SUID_DROP, unlzop)) | 396 | IF_LZOP(APPLET_ODDNAME(unlzop, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, unlzop)) |
398 | IF_UNZIP(APPLET(unzip, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 397 | IF_UNZIP(APPLET(unzip, BB_DIR_USR_BIN, BB_SUID_DROP)) |
399 | IF_UPTIME(APPLET(uptime, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 398 | IF_UPTIME(APPLET(uptime, BB_DIR_USR_BIN, BB_SUID_DROP)) |
400 | IF_USLEEP(APPLET_NOFORK(usleep, usleep, _BB_DIR_BIN, _BB_SUID_DROP, usleep)) | 399 | IF_USLEEP(APPLET_NOFORK(usleep, usleep, BB_DIR_BIN, BB_SUID_DROP, usleep)) |
401 | IF_UUDECODE(APPLET(uudecode, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 400 | IF_UUDECODE(APPLET(uudecode, BB_DIR_USR_BIN, BB_SUID_DROP)) |
402 | IF_UUENCODE(APPLET(uuencode, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 401 | IF_UUENCODE(APPLET(uuencode, BB_DIR_USR_BIN, BB_SUID_DROP)) |
403 | IF_VCONFIG(APPLET(vconfig, _BB_DIR_SBIN, _BB_SUID_DROP)) | 402 | IF_VCONFIG(APPLET(vconfig, BB_DIR_SBIN, BB_SUID_DROP)) |
404 | IF_VI(APPLET(vi, _BB_DIR_BIN, _BB_SUID_DROP)) | 403 | IF_VI(APPLET(vi, BB_DIR_BIN, BB_SUID_DROP)) |
405 | /* Needs to be run by root or be suid root - needs to change uid and gid: */ | 404 | /* Needs to be run by root or be suid root - needs to change uid and gid: */ |
406 | IF_VLOCK(APPLET(vlock, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE)) | 405 | IF_VLOCK(APPLET(vlock, BB_DIR_USR_BIN, BB_SUID_REQUIRE)) |
407 | IF_VOLNAME(APPLET(volname, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 406 | IF_VOLNAME(APPLET(volname, BB_DIR_USR_BIN, BB_SUID_DROP)) |
408 | /* Needs to be run by root or be suid root - needs to write to /dev/TTY: */ | 407 | /* Needs to be run by root or be suid root - needs to write to /dev/TTY: */ |
409 | IF_WALL(APPLET(wall, _BB_DIR_USR_BIN, _BB_SUID_REQUIRE)) | 408 | IF_WALL(APPLET(wall, BB_DIR_USR_BIN, BB_SUID_REQUIRE)) |
410 | IF_WATCH(APPLET(watch, _BB_DIR_BIN, _BB_SUID_DROP)) | 409 | IF_WATCH(APPLET(watch, BB_DIR_BIN, BB_SUID_DROP)) |
411 | IF_WATCHDOG(APPLET(watchdog, _BB_DIR_SBIN, _BB_SUID_DROP)) | 410 | IF_WATCHDOG(APPLET(watchdog, BB_DIR_SBIN, BB_SUID_DROP)) |
412 | IF_WC(APPLET(wc, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 411 | IF_WC(APPLET(wc, BB_DIR_USR_BIN, BB_SUID_DROP)) |
413 | IF_WGET(APPLET(wget, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 412 | IF_WGET(APPLET(wget, BB_DIR_USR_BIN, BB_SUID_DROP)) |
414 | IF_WHICH(APPLET(which, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 413 | IF_WHICH(APPLET(which, BB_DIR_USR_BIN, BB_SUID_DROP)) |
415 | IF_WHO(APPLET(who, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 414 | IF_WHO(APPLET(who, BB_DIR_USR_BIN, BB_SUID_DROP)) |
416 | IF_WHOAMI(APPLET_NOFORK(whoami, whoami, _BB_DIR_USR_BIN, _BB_SUID_DROP, whoami)) | 415 | IF_WHOAMI(APPLET_NOFORK(whoami, whoami, BB_DIR_USR_BIN, BB_SUID_DROP, whoami)) |
417 | IF_UNXZ(APPLET_ODDNAME(xzcat, unxz, _BB_DIR_USR_BIN, _BB_SUID_DROP, xzcat)) | 416 | IF_UNXZ(APPLET_ODDNAME(xzcat, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xzcat)) |
418 | IF_XZ(APPLET_ODDNAME(xz, unxz, _BB_DIR_USR_BIN, _BB_SUID_DROP, xz)) | 417 | IF_XZ(APPLET_ODDNAME(xz, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xz)) |
419 | IF_YES(APPLET_NOFORK(yes, yes, _BB_DIR_USR_BIN, _BB_SUID_DROP, yes)) | 418 | IF_YES(APPLET_NOFORK(yes, yes, BB_DIR_USR_BIN, BB_SUID_DROP, yes)) |
420 | IF_GUNZIP(APPLET_ODDNAME(zcat, gunzip, _BB_DIR_BIN, _BB_SUID_DROP, zcat)) | 419 | IF_GUNZIP(APPLET_ODDNAME(zcat, gunzip, BB_DIR_BIN, BB_SUID_DROP, zcat)) |
421 | IF_ZCIP(APPLET(zcip, _BB_DIR_SBIN, _BB_SUID_DROP)) | 420 | IF_ZCIP(APPLET(zcip, BB_DIR_SBIN, BB_SUID_DROP)) |
422 | 421 | ||
423 | #if !defined(PROTOTYPES) && !defined(NAME_MAIN_CNAME) && !defined(MAKE_USAGE) | 422 | #if !defined(PROTOTYPES) && !defined(NAME_MAIN_CNAME) && !defined(MAKE_USAGE) |
424 | }; | 423 | }; |
diff --git a/include/busybox.h b/include/busybox.h index 757317fc7..be06817e3 100644 --- a/include/busybox.h +++ b/include/busybox.h | |||
@@ -13,22 +13,22 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN | |||
13 | 13 | ||
14 | /* order matters: used as index into "install_dir[]" in appletlib.c */ | 14 | /* order matters: used as index into "install_dir[]" in appletlib.c */ |
15 | typedef enum bb_install_loc_t { | 15 | typedef enum bb_install_loc_t { |
16 | _BB_DIR_ROOT = 0, | 16 | BB_DIR_ROOT = 0, |
17 | _BB_DIR_BIN, | 17 | BB_DIR_BIN, |
18 | _BB_DIR_SBIN, | 18 | BB_DIR_SBIN, |
19 | #if ENABLE_INSTALL_NO_USR | 19 | #if ENABLE_INSTALL_NO_USR |
20 | _BB_DIR_USR_BIN = _BB_DIR_BIN, | 20 | BB_DIR_USR_BIN = BB_DIR_BIN, |
21 | _BB_DIR_USR_SBIN = _BB_DIR_SBIN, | 21 | BB_DIR_USR_SBIN = BB_DIR_SBIN, |
22 | #else | 22 | #else |
23 | _BB_DIR_USR_BIN, | 23 | BB_DIR_USR_BIN, |
24 | _BB_DIR_USR_SBIN, | 24 | BB_DIR_USR_SBIN, |
25 | #endif | 25 | #endif |
26 | } bb_install_loc_t; | 26 | } bb_install_loc_t; |
27 | 27 | ||
28 | typedef enum bb_suid_t { | 28 | typedef enum bb_suid_t { |
29 | _BB_SUID_DROP = 0, | 29 | BB_SUID_DROP = 0, |
30 | _BB_SUID_MAYBE, | 30 | BB_SUID_MAYBE, |
31 | _BB_SUID_REQUIRE | 31 | BB_SUID_REQUIRE |
32 | } bb_suid_t; | 32 | } bb_suid_t; |
33 | 33 | ||
34 | 34 | ||
diff --git a/include/libbb.h b/include/libbb.h index 5fa62da3a..7efa32349 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -50,6 +50,9 @@ | |||
50 | # include <selinux/flask.h> | 50 | # include <selinux/flask.h> |
51 | # include <selinux/av_permissions.h> | 51 | # include <selinux/av_permissions.h> |
52 | #endif | 52 | #endif |
53 | #if ENABLE_FEATURE_UTMP | ||
54 | # include <utmp.h> | ||
55 | #endif | ||
53 | #if ENABLE_LOCALE_SUPPORT | 56 | #if ENABLE_LOCALE_SUPPORT |
54 | # include <locale.h> | 57 | # include <locale.h> |
55 | #else | 58 | #else |
@@ -68,6 +71,19 @@ | |||
68 | # include <shadow.h> | 71 | # include <shadow.h> |
69 | # endif | 72 | # endif |
70 | #endif | 73 | #endif |
74 | /* Just in case libc doesn't define some of these... */ | ||
75 | #ifndef _PATH_PASSWD | ||
76 | #define _PATH_PASSWD "/etc/passwd" | ||
77 | #endif | ||
78 | #ifndef _PATH_GROUP | ||
79 | #define _PATH_GROUP "/etc/group" | ||
80 | #endif | ||
81 | #ifndef _PATH_SHADOW | ||
82 | #define _PATH_SHADOW "/etc/shadow" | ||
83 | #endif | ||
84 | #ifndef _PATH_GSHADOW | ||
85 | #define _PATH_GSHADOW "/etc/gshadow" | ||
86 | #endif | ||
71 | #if defined __FreeBSD__ || defined __OpenBSD__ | 87 | #if defined __FreeBSD__ || defined __OpenBSD__ |
72 | # include <netinet/in.h> | 88 | # include <netinet/in.h> |
73 | # include <arpa/inet.h> | 89 | # include <arpa/inet.h> |
@@ -91,6 +107,15 @@ | |||
91 | typedef unsigned socklen_t; | 107 | typedef unsigned socklen_t; |
92 | # endif | 108 | # endif |
93 | #endif | 109 | #endif |
110 | #ifndef HAVE_CLEARENV | ||
111 | # define clearenv() do { if (environ) environ[0] = NULL; } while (0) | ||
112 | #endif | ||
113 | #ifndef HAVE_FDATASYNC | ||
114 | # define fdatasync fsync | ||
115 | #endif | ||
116 | #ifndef HAVE_XTABS | ||
117 | # define XTABS TAB3 | ||
118 | #endif | ||
94 | 119 | ||
95 | 120 | ||
96 | /* Some libc's forget to declare these, do it ourself */ | 121 | /* Some libc's forget to declare these, do it ourself */ |
@@ -348,9 +373,9 @@ extern char *bb_get_last_path_component_strip(char *path) FAST_FUNC; | |||
348 | /* "abc/def/" -> "" and it never modifies 'path' */ | 373 | /* "abc/def/" -> "" and it never modifies 'path' */ |
349 | extern char *bb_get_last_path_component_nostrip(const char *path) FAST_FUNC; | 374 | extern char *bb_get_last_path_component_nostrip(const char *path) FAST_FUNC; |
350 | 375 | ||
351 | int ndelay_on(int fd) FAST_FUNC; | 376 | void ndelay_on(int fd) FAST_FUNC; |
352 | int ndelay_off(int fd) FAST_FUNC; | 377 | void ndelay_off(int fd) FAST_FUNC; |
353 | int close_on_exec_on(int fd) FAST_FUNC; | 378 | void close_on_exec_on(int fd) FAST_FUNC; |
354 | void xdup2(int, int) FAST_FUNC; | 379 | void xdup2(int, int) FAST_FUNC; |
355 | void xmove_fd(int, int) FAST_FUNC; | 380 | void xmove_fd(int, int) FAST_FUNC; |
356 | 381 | ||
@@ -674,6 +699,8 @@ extern char *xmalloc_reads(int fd, char *pfx, size_t *maxsz_p) FAST_FUNC; | |||
674 | extern void *xmalloc_read(int fd, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; | 699 | extern void *xmalloc_read(int fd, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; |
675 | /* Returns NULL if file can't be opened (default max size: INT_MAX - 4095) */ | 700 | /* Returns NULL if file can't be opened (default max size: INT_MAX - 4095) */ |
676 | extern void *xmalloc_open_read_close(const char *filename, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; | 701 | extern void *xmalloc_open_read_close(const char *filename, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; |
702 | /* Never returns NULL */ | ||
703 | extern void *xmalloc_xopen_read_close(const char *filename, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; | ||
677 | /* Autodetects gzip/bzip2 formats. fd may be in the middle of the file! */ | 704 | /* Autodetects gzip/bzip2 formats. fd may be in the middle of the file! */ |
678 | #if ENABLE_FEATURE_SEAMLESS_LZMA \ | 705 | #if ENABLE_FEATURE_SEAMLESS_LZMA \ |
679 | || ENABLE_FEATURE_SEAMLESS_BZ2 \ | 706 | || ENABLE_FEATURE_SEAMLESS_BZ2 \ |
@@ -686,8 +713,6 @@ extern void setup_unzip_on_fd(int fd /*, int fail_if_not_detected*/) FAST_FUNC; | |||
686 | /* Autodetects .gz etc */ | 713 | /* Autodetects .gz etc */ |
687 | extern int open_zipped(const char *fname) FAST_FUNC; | 714 | extern int open_zipped(const char *fname) FAST_FUNC; |
688 | extern void *xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; | 715 | extern void *xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; |
689 | /* Never returns NULL */ | ||
690 | extern void *xmalloc_xopen_read_close(const char *filename, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; | ||
691 | 716 | ||
692 | extern ssize_t safe_write(int fd, const void *buf, size_t count) FAST_FUNC; | 717 | extern ssize_t safe_write(int fd, const void *buf, size_t count) FAST_FUNC; |
693 | // NB: will return short write on error, not -1, | 718 | // NB: will return short write on error, not -1, |
@@ -1211,6 +1236,12 @@ extern void selinux_preserve_fcontext(int fdesc) FAST_FUNC; | |||
1211 | #endif | 1236 | #endif |
1212 | extern void selinux_or_die(void) FAST_FUNC; | 1237 | extern void selinux_or_die(void) FAST_FUNC; |
1213 | 1238 | ||
1239 | |||
1240 | /* systemd support */ | ||
1241 | #define SD_LISTEN_FDS_START 3 | ||
1242 | int sd_listen_fds(void); | ||
1243 | |||
1244 | |||
1214 | /* setup_environment: | 1245 | /* setup_environment: |
1215 | * if chdir pw->pw_dir: ok: else if to_tmp == 1: goto /tmp else: goto / or die | 1246 | * if chdir pw->pw_dir: ok: else if to_tmp == 1: goto /tmp else: goto / or die |
1216 | * if clear_env = 1: cd(pw->pw_dir), clear environment, then set | 1247 | * if clear_env = 1: cd(pw->pw_dir), clear environment, then set |
@@ -1291,7 +1322,7 @@ void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name) FAST | |||
1291 | void reset_ino_dev_hashtable(void) FAST_FUNC; | 1322 | void reset_ino_dev_hashtable(void) FAST_FUNC; |
1292 | #ifdef __GLIBC__ | 1323 | #ifdef __GLIBC__ |
1293 | /* At least glibc has horrendously large inline for this, so wrap it */ | 1324 | /* At least glibc has horrendously large inline for this, so wrap it */ |
1294 | unsigned long long bb_makedev(unsigned int major, unsigned int minor) FAST_FUNC; | 1325 | unsigned long long bb_makedev(unsigned major, unsigned minor) FAST_FUNC; |
1295 | #undef makedev | 1326 | #undef makedev |
1296 | #define makedev(a,b) bb_makedev(a,b) | 1327 | #define makedev(a,b) bb_makedev(a,b) |
1297 | #endif | 1328 | #endif |
@@ -1628,10 +1659,10 @@ extern const char bb_busybox_exec_path[]; | |||
1628 | * get the list of currently mounted filesystems */ | 1659 | * get the list of currently mounted filesystems */ |
1629 | #define bb_path_mtab_file IF_FEATURE_MTAB_SUPPORT("/etc/mtab")IF_NOT_FEATURE_MTAB_SUPPORT("/proc/mounts") | 1660 | #define bb_path_mtab_file IF_FEATURE_MTAB_SUPPORT("/etc/mtab")IF_NOT_FEATURE_MTAB_SUPPORT("/proc/mounts") |
1630 | 1661 | ||
1631 | #define bb_path_passwd_file "/etc/passwd" | 1662 | #define bb_path_passwd_file _PATH_PASSWD |
1632 | #define bb_path_shadow_file "/etc/shadow" | 1663 | #define bb_path_group_file _PATH_GROUP |
1633 | #define bb_path_gshadow_file "/etc/gshadow" | 1664 | #define bb_path_shadow_file _PATH_SHADOW |
1634 | #define bb_path_group_file "/etc/group" | 1665 | #define bb_path_gshadow_file _PATH_GSHADOW |
1635 | 1666 | ||
1636 | #define bb_path_motd_file "/etc/motd" | 1667 | #define bb_path_motd_file "/etc/motd" |
1637 | 1668 | ||
diff --git a/include/platform.h b/include/platform.h index 5f49deb41..c272fbb05 100644 --- a/include/platform.h +++ b/include/platform.h | |||
@@ -20,10 +20,14 @@ | |||
20 | /* Assume all these functions exist by default. Platforms where it is not | 20 | /* Assume all these functions exist by default. Platforms where it is not |
21 | * true will #undef them below. | 21 | * true will #undef them below. |
22 | */ | 22 | */ |
23 | #define HAVE_CLEARENV 1 | ||
24 | #define HAVE_FDATASYNC 1 | ||
23 | #define HAVE_FDPRINTF 1 | 25 | #define HAVE_FDPRINTF 1 |
24 | #define HAVE_MEMRCHR 1 | 26 | #define HAVE_MEMRCHR 1 |
25 | #define HAVE_MKDTEMP 1 | 27 | #define HAVE_MKDTEMP 1 |
28 | #define HAVE_PTSNAME_R 1 | ||
26 | #define HAVE_SETBIT 1 | 29 | #define HAVE_SETBIT 1 |
30 | #define HAVE_SIGHANDLER_T 1 | ||
27 | #define HAVE_STRCASESTR 1 | 31 | #define HAVE_STRCASESTR 1 |
28 | #define HAVE_STRCHRNUL 1 | 32 | #define HAVE_STRCHRNUL 1 |
29 | #define HAVE_STRSEP 1 | 33 | #define HAVE_STRSEP 1 |
@@ -235,14 +239,15 @@ | |||
235 | 239 | ||
236 | /* ---- Unaligned access ------------------------------------ */ | 240 | /* ---- Unaligned access ------------------------------------ */ |
237 | 241 | ||
242 | #include <stdint.h> | ||
243 | typedef int bb__aliased_int FIX_ALIASING; | ||
244 | typedef uint16_t bb__aliased_uint16_t FIX_ALIASING; | ||
245 | typedef uint32_t bb__aliased_uint32_t FIX_ALIASING; | ||
246 | |||
238 | /* NB: unaligned parameter should be a pointer, aligned one - | 247 | /* NB: unaligned parameter should be a pointer, aligned one - |
239 | * a lvalue. This makes it more likely to not swap them by mistake | 248 | * a lvalue. This makes it more likely to not swap them by mistake |
240 | */ | 249 | */ |
241 | #if defined(i386) || defined(__x86_64__) || defined(__powerpc__) | 250 | #if defined(i386) || defined(__x86_64__) || defined(__powerpc__) |
242 | # include <stdint.h> | ||
243 | typedef int bb__aliased_int FIX_ALIASING; | ||
244 | typedef uint16_t bb__aliased_uint16_t FIX_ALIASING; | ||
245 | typedef uint32_t bb__aliased_uint32_t FIX_ALIASING; | ||
246 | # define move_from_unaligned_int(v, intp) ((v) = *(bb__aliased_int*)(intp)) | 251 | # define move_from_unaligned_int(v, intp) ((v) = *(bb__aliased_int*)(intp)) |
247 | # define move_from_unaligned16(v, u16p) ((v) = *(bb__aliased_uint16_t*)(u16p)) | 252 | # define move_from_unaligned16(v, u16p) ((v) = *(bb__aliased_uint16_t*)(u16p)) |
248 | # define move_from_unaligned32(v, u32p) ((v) = *(bb__aliased_uint32_t*)(u32p)) | 253 | # define move_from_unaligned32(v, u32p) ((v) = *(bb__aliased_uint32_t*)(u32p)) |
@@ -268,13 +273,19 @@ typedef uint32_t bb__aliased_uint32_t FIX_ALIASING; | |||
268 | 273 | ||
269 | #if (defined __digital__ && defined __unix__) \ | 274 | #if (defined __digital__ && defined __unix__) \ |
270 | || defined __APPLE__ \ | 275 | || defined __APPLE__ \ |
271 | || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ \ | 276 | || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ |
272 | || ENABLE_PLATFORM_MINGW32 | 277 | # undef HAVE_CLEARENV |
278 | # undef HAVE_FDATASYNC | ||
273 | # undef HAVE_MNTENT_H | 279 | # undef HAVE_MNTENT_H |
280 | # undef HAVE_PTSNAME_R | ||
274 | # undef HAVE_SYS_STATFS_H | 281 | # undef HAVE_SYS_STATFS_H |
282 | # undef HAVE_SIGHANDLER_T | ||
283 | # undef HAVE_XTABS | ||
284 | # undef HAVE_FDPRINTF | ||
275 | #else | 285 | #else |
276 | # define HAVE_MNTENT_H 1 | 286 | # define HAVE_MNTENT_H 1 |
277 | # define HAVE_SYS_STATFS_H 1 | 287 | # define HAVE_SYS_STATFS_H 1 |
288 | # define HAVE_XTABS 1 | ||
278 | #endif | 289 | #endif |
279 | 290 | ||
280 | /*----- Kernel versioning ------------------------------------*/ | 291 | /*----- Kernel versioning ------------------------------------*/ |
@@ -378,14 +389,16 @@ typedef unsigned smalluint; | |||
378 | #endif | 389 | #endif |
379 | 390 | ||
380 | #if ENABLE_PLATFORM_MINGW32 | 391 | #if ENABLE_PLATFORM_MINGW32 |
381 | # undef HAVE_FDPRINTF | 392 | # undef HAVE_FDPRINTF |
382 | # undef HAVE_MEMRCHR | 393 | # undef HAVE_MEMRCHR |
383 | # undef HAVE_MKDTEMP | 394 | # undef HAVE_MKDTEMP |
384 | # undef HAVE_SETBIT | 395 | # undef HAVE_SETBIT |
385 | # undef HAVE_STRCASESTR | 396 | # undef HAVE_STRCASESTR |
386 | # undef HAVE_STRCHRNUL | 397 | # undef HAVE_STRCHRNUL |
387 | # undef HAVE_STRSIGNAL | 398 | # undef HAVE_STRSIGNAL |
388 | # undef HAVE_VASPRINTF | 399 | # undef HAVE_VASPRINTF |
400 | # undef HAVE_MNTENT_H | ||
401 | # undef HAVE_SYS_STATFS_H | ||
389 | #endif | 402 | #endif |
390 | 403 | ||
391 | #if defined(__WATCOMC__) | 404 | #if defined(__WATCOMC__) |
@@ -427,6 +440,10 @@ extern char *mkdtemp(char *template) FAST_FUNC; | |||
427 | # define clrbit(a, b) ((a)[(b) >> 3] &= ~(1 << ((b) & 7))) | 440 | # define clrbit(a, b) ((a)[(b) >> 3] &= ~(1 << ((b) & 7))) |
428 | #endif | 441 | #endif |
429 | 442 | ||
443 | #ifndef HAVE_SIGHANDLER_T | ||
444 | typedef void (*sighandler_t)(int); | ||
445 | #endif | ||
446 | |||
430 | #ifndef HAVE_STRCASESTR | 447 | #ifndef HAVE_STRCASESTR |
431 | extern char *strcasestr(const char *s, const char *pattern) FAST_FUNC; | 448 | extern char *strcasestr(const char *s, const char *pattern) FAST_FUNC; |
432 | #endif | 449 | #endif |
@@ -445,9 +462,7 @@ extern char *strsep(char **stringp, const char *delim) FAST_FUNC; | |||
445 | #endif | 462 | #endif |
446 | 463 | ||
447 | #ifndef HAVE_VASPRINTF | 464 | #ifndef HAVE_VASPRINTF |
448 | # if ENABLE_PLATFORM_MINGW32 | 465 | # include <stdarg.h> |
449 | # include <stdarg.h> | ||
450 | # endif | ||
451 | extern int vasprintf(char **string_ptr, const char *format, va_list p) FAST_FUNC; | 466 | extern int vasprintf(char **string_ptr, const char *format, va_list p) FAST_FUNC; |
452 | #endif | 467 | #endif |
453 | 468 | ||
diff --git a/include/shadow_.h b/include/shadow_.h index de126ddec..648a62ab3 100644 --- a/include/shadow_.h +++ b/include/shadow_.h | |||
@@ -37,11 +37,6 @@ struct spwd { | |||
37 | unsigned long sp_flag; /* Reserved */ | 37 | unsigned long sp_flag; /* Reserved */ |
38 | }; | 38 | }; |
39 | 39 | ||
40 | /* Paths to the user database files */ | ||
41 | #ifndef _PATH_SHADOW | ||
42 | #define _PATH_SHADOW "/etc/shadow" | ||
43 | #endif | ||
44 | |||
45 | #define setspent bb_internal_setspent | 40 | #define setspent bb_internal_setspent |
46 | #define endspent bb_internal_endspent | 41 | #define endspent bb_internal_endspent |
47 | #define getspent bb_internal_getspent | 42 | #define getspent bb_internal_getspent |
diff --git a/include/unicode.h b/include/unicode.h index 1dd55e67d..dee02e777 100644 --- a/include/unicode.h +++ b/include/unicode.h | |||
@@ -60,8 +60,8 @@ enum { | |||
60 | //UNUSED: unsigned FAST_FUNC unicode_padding_to_width(unsigned width, const char *src); | 60 | //UNUSED: unsigned FAST_FUNC unicode_padding_to_width(unsigned width, const char *src); |
61 | //UNUSED: char* FAST_FUNC unicode_conv_to_printable2(uni_stat_t *stats, const char *src, unsigned width, int flags); | 61 | //UNUSED: char* FAST_FUNC unicode_conv_to_printable2(uni_stat_t *stats, const char *src, unsigned width, int flags); |
62 | char* FAST_FUNC unicode_conv_to_printable(uni_stat_t *stats, const char *src); | 62 | char* FAST_FUNC unicode_conv_to_printable(uni_stat_t *stats, const char *src); |
63 | char* FAST_FUNC unicode_conv_to_printable_maxwidth(uni_stat_t *stats, const char *src, unsigned maxwidth); | 63 | //UNUSED: char* FAST_FUNC unicode_conv_to_printable_maxwidth(uni_stat_t *stats, const char *src, unsigned maxwidth); |
64 | char* FAST_FUNC unicode_conv_to_printable_fixedwidth(uni_stat_t *stats, const char *src, unsigned width); | 64 | char* FAST_FUNC unicode_conv_to_printable_fixedwidth(/*uni_stat_t *stats,*/ const char *src, unsigned width); |
65 | 65 | ||
66 | # if ENABLE_UNICODE_USING_LOCALE | 66 | # if ENABLE_UNICODE_USING_LOCALE |
67 | 67 | ||
diff --git a/include/usage.src.h b/include/usage.src.h index ea0e6a452..ebe80f8e1 100644 --- a/include/usage.src.h +++ b/include/usage.src.h | |||
@@ -1394,23 +1394,6 @@ INSERT | |||
1394 | #define getsebool_full_usage "\n\n" \ | 1394 | #define getsebool_full_usage "\n\n" \ |
1395 | " -a Show all selinux booleans" | 1395 | " -a Show all selinux booleans" |
1396 | 1396 | ||
1397 | #define getty_trivial_usage \ | ||
1398 | "[OPTIONS] BAUD_RATE TTY [TERMTYPE]" | ||
1399 | #define getty_full_usage "\n\n" \ | ||
1400 | "Open a tty, prompt for a login name, then invoke /bin/login\n" \ | ||
1401 | "\nOptions:" \ | ||
1402 | "\n -h Enable hardware (RTS/CTS) flow control" \ | ||
1403 | "\n -i Don't display /etc/issue before running login" \ | ||
1404 | "\n -L Local line, don't do carrier detect" \ | ||
1405 | "\n -m Get baud rate from modem's CONNECT status message" \ | ||
1406 | "\n -w Wait for a CR or LF before sending /etc/issue" \ | ||
1407 | "\n -n Don't prompt the user for a login name" \ | ||
1408 | "\n -f ISSUE_FILE Display ISSUE_FILE instead of /etc/issue" \ | ||
1409 | "\n -l LOGIN Invoke LOGIN instead of /bin/login" \ | ||
1410 | "\n -t SEC Terminate after SEC if no username is read" \ | ||
1411 | "\n -I INITSTR Send INITSTR before anything else" \ | ||
1412 | "\n -H HOST Log HOST into the utmp file as the hostname" \ | ||
1413 | |||
1414 | #define gunzip_trivial_usage \ | 1397 | #define gunzip_trivial_usage \ |
1415 | "[-cft] [FILE]..." | 1398 | "[-cft] [FILE]..." |
1416 | #define gunzip_full_usage "\n\n" \ | 1399 | #define gunzip_full_usage "\n\n" \ |
@@ -1612,25 +1595,6 @@ INSERT | |||
1612 | "\n -e STRING HTML encode STRING" \ | 1595 | "\n -e STRING HTML encode STRING" \ |
1613 | "\n -d STRING URL decode STRING" \ | 1596 | "\n -d STRING URL decode STRING" \ |
1614 | 1597 | ||
1615 | #define hwclock_trivial_usage \ | ||
1616 | IF_FEATURE_HWCLOCK_LONG_OPTIONS( \ | ||
1617 | "[-r|--show] [-s|--hctosys] [-w|--systohc]" \ | ||
1618 | " [-l|--localtime] [-u|--utc]" \ | ||
1619 | " [-f FILE]" \ | ||
1620 | ) \ | ||
1621 | IF_NOT_FEATURE_HWCLOCK_LONG_OPTIONS( \ | ||
1622 | "[-r] [-s] [-w] [-l] [-u] [-f FILE]" \ | ||
1623 | ) | ||
1624 | #define hwclock_full_usage "\n\n" \ | ||
1625 | "Query and set hardware clock (RTC)\n" \ | ||
1626 | "\nOptions:" \ | ||
1627 | "\n -r Show hardware clock time" \ | ||
1628 | "\n -s Set system time from hardware clock" \ | ||
1629 | "\n -w Set hardware clock to system time" \ | ||
1630 | "\n -u Hardware clock is in UTC" \ | ||
1631 | "\n -l Hardware clock is in local time" \ | ||
1632 | "\n -f FILE Use specified device (e.g. /dev/rtc2)" \ | ||
1633 | |||
1634 | #define id_trivial_usage \ | 1598 | #define id_trivial_usage \ |
1635 | "[OPTIONS] [USER]" | 1599 | "[OPTIONS] [USER]" |
1636 | #define id_full_usage "\n\n" \ | 1600 | #define id_full_usage "\n\n" \ |
@@ -3555,13 +3519,6 @@ INSERT | |||
3555 | "pause, cont, hup, alarm, interrupt, quit, 1, 2, term, kill: send\n" \ | 3519 | "pause, cont, hup, alarm, interrupt, quit, 1, 2, term, kill: send\n" \ |
3556 | "STOP, CONT, HUP, ALRM, INT, QUIT, USR1, USR2, TERM, KILL signal to service" \ | 3520 | "STOP, CONT, HUP, ALRM, INT, QUIT, USR1, USR2, TERM, KILL signal to service" \ |
3557 | 3521 | ||
3558 | #define svlogd_trivial_usage \ | ||
3559 | "[-ttv] [-r C] [-R CHARS] [-l MATCHLEN] [-b BUFLEN] DIR..." | ||
3560 | #define svlogd_full_usage "\n\n" \ | ||
3561 | "Continuously read log data from stdin, optionally\n" \ | ||
3562 | "filter log messages, and write the data to one or more automatically\n" \ | ||
3563 | "rotated logs" \ | ||
3564 | |||
3565 | #define swapoff_trivial_usage \ | 3522 | #define swapoff_trivial_usage \ |
3566 | "[-a] [DEVICE]" | 3523 | "[-a] [DEVICE]" |
3567 | #define swapoff_full_usage "\n\n" \ | 3524 | #define swapoff_full_usage "\n\n" \ |
@@ -3843,14 +3800,6 @@ INSERT | |||
3843 | "Runs PROG. Sends SIG to it if it is not gone in SECS seconds.\n" \ | 3800 | "Runs PROG. Sends SIG to it if it is not gone in SECS seconds.\n" \ |
3844 | "Defaults: SECS: 10, SIG: TERM." \ | 3801 | "Defaults: SECS: 10, SIG: TERM." \ |
3845 | 3802 | ||
3846 | #define top_trivial_usage \ | ||
3847 | "[-b] [-nCOUNT] [-dSECONDS]" IF_FEATURE_TOPMEM(" [-m]") | ||
3848 | #define top_full_usage "\n\n" \ | ||
3849 | "Provide a view of process activity in real time.\n" \ | ||
3850 | "Read the status of all processes from /proc each SECONDS\n" \ | ||
3851 | "and display a screenful of them." \ | ||
3852 | //TODO: add options and keyboard commands | ||
3853 | |||
3854 | #define tr_trivial_usage \ | 3803 | #define tr_trivial_usage \ |
3855 | "[-cds] STRING1 [STRING2]" | 3804 | "[-cds] STRING1 [STRING2]" |
3856 | #define tr_full_usage "\n\n" \ | 3805 | #define tr_full_usage "\n\n" \ |
diff --git a/init/bootchartd.c b/init/bootchartd.c index ac3f261c8..009e2690c 100644 --- a/init/bootchartd.c +++ b/init/bootchartd.c | |||
@@ -3,7 +3,7 @@ | |||
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 | 5 | ||
6 | //applet:IF_BOOTCHARTD(APPLET(bootchartd, _BB_DIR_SBIN, _BB_SUID_DROP)) | 6 | //applet:IF_BOOTCHARTD(APPLET(bootchartd, BB_DIR_SBIN, BB_SUID_DROP)) |
7 | 7 | ||
8 | //kbuild:lib-$(CONFIG_BOOTCHARTD) += bootchartd.o | 8 | //kbuild:lib-$(CONFIG_BOOTCHARTD) += bootchartd.o |
9 | 9 | ||
diff --git a/init/halt.c b/init/halt.c index 47f1ef7b2..a84a72747 100644 --- a/init/halt.c +++ b/init/halt.c | |||
@@ -7,9 +7,9 @@ | |||
7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | //applet:IF_HALT(APPLET(halt, _BB_DIR_SBIN, _BB_SUID_DROP)) | 10 | //applet:IF_HALT(APPLET(halt, BB_DIR_SBIN, BB_SUID_DROP)) |
11 | //applet:IF_HALT(APPLET_ODDNAME(poweroff, halt, _BB_DIR_SBIN, _BB_SUID_DROP, poweroff)) | 11 | //applet:IF_HALT(APPLET_ODDNAME(poweroff, halt, BB_DIR_SBIN, BB_SUID_DROP, poweroff)) |
12 | //applet:IF_HALT(APPLET_ODDNAME(reboot, halt, _BB_DIR_SBIN, _BB_SUID_DROP, reboot)) | 12 | //applet:IF_HALT(APPLET_ODDNAME(reboot, halt, BB_DIR_SBIN, BB_SUID_DROP, reboot)) |
13 | 13 | ||
14 | //kbuild:lib-$(CONFIG_HALT) += halt.o | 14 | //kbuild:lib-$(CONFIG_HALT) += halt.o |
15 | 15 | ||
@@ -74,7 +74,6 @@ | |||
74 | 74 | ||
75 | #if ENABLE_FEATURE_WTMP | 75 | #if ENABLE_FEATURE_WTMP |
76 | #include <sys/utsname.h> | 76 | #include <sys/utsname.h> |
77 | #include <utmp.h> | ||
78 | 77 | ||
79 | static void write_wtmp(void) | 78 | static void write_wtmp(void) |
80 | { | 79 | { |
diff --git a/init/init.c b/init/init.c index a2cc3b5f5..586e34a18 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -9,8 +9,8 @@ | |||
9 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 9 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | //applet:IF_INIT(APPLET(init, _BB_DIR_SBIN, _BB_SUID_DROP)) | 12 | //applet:IF_INIT(APPLET(init, BB_DIR_SBIN, BB_SUID_DROP)) |
13 | //applet:IF_FEATURE_INITRD(APPLET_ODDNAME(linuxrc, init, _BB_DIR_ROOT, _BB_SUID_DROP, linuxrc)) | 13 | //applet:IF_FEATURE_INITRD(APPLET_ODDNAME(linuxrc, init, BB_DIR_ROOT, BB_SUID_DROP, linuxrc)) |
14 | 14 | ||
15 | //kbuild:lib-$(CONFIG_INIT) += init.o | 15 | //kbuild:lib-$(CONFIG_INIT) += init.o |
16 | 16 | ||
@@ -115,9 +115,6 @@ | |||
115 | #ifdef __linux__ | 115 | #ifdef __linux__ |
116 | #include <linux/vt.h> | 116 | #include <linux/vt.h> |
117 | #endif | 117 | #endif |
118 | #if ENABLE_FEATURE_UTMP | ||
119 | # include <utmp.h> /* DEAD_PROCESS */ | ||
120 | #endif | ||
121 | #include "reboot.h" /* reboot() constants */ | 118 | #include "reboot.h" /* reboot() constants */ |
122 | 119 | ||
123 | /* Used only for sanitizing purposes in set_sane_term() below. On systems where | 120 | /* Used only for sanitizing purposes in set_sane_term() below. On systems where |
diff --git a/init/mesg.c b/init/mesg.c index b6fd070e1..676ca2e24 100644 --- a/init/mesg.c +++ b/init/mesg.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | //applet:IF_MESG(APPLET(mesg, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 10 | //applet:IF_MESG(APPLET(mesg, BB_DIR_USR_BIN, BB_SUID_DROP)) |
11 | 11 | ||
12 | //kbuild:lib-$(CONFIG_MESG) += mesg.o | 12 | //kbuild:lib-$(CONFIG_MESG) += mesg.o |
13 | 13 | ||
diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src index f815c6dbc..3c9493f7e 100644 --- a/libbb/Kbuild.src +++ b/libbb/Kbuild.src | |||
@@ -115,12 +115,13 @@ lib-$(CONFIG_PLATFORM_POSIX) += inet_common.o | |||
115 | lib-$(CONFIG_PLATFORM_POSIX) += kernel_version.o | 115 | lib-$(CONFIG_PLATFORM_POSIX) += kernel_version.o |
116 | lib-$(CONFIG_PLATFORM_POSIX) += login.o | 116 | lib-$(CONFIG_PLATFORM_POSIX) += login.o |
117 | lib-$(CONFIG_PLATFORM_POSIX) += makedev.o | 117 | lib-$(CONFIG_PLATFORM_POSIX) += makedev.o |
118 | lib-$(CONFIG_PLATFORM_POSIX) += match_fstype.o | ||
119 | lib-$(CONFIG_PLATFORM_POSIX) += read_key.o | 118 | lib-$(CONFIG_PLATFORM_POSIX) += read_key.o |
120 | lib-$(CONFIG_PLATFORM_POSIX) += signals.o | 119 | lib-$(CONFIG_PLATFORM_POSIX) += signals.o |
121 | lib-$(CONFIG_PLATFORM_POSIX) += udp_io.o | 120 | lib-$(CONFIG_PLATFORM_POSIX) += udp_io.o |
122 | lib-$(CONFIG_PLATFORM_POSIX) += xgethostbyname.o | 121 | lib-$(CONFIG_PLATFORM_POSIX) += xgethostbyname.o |
123 | 122 | ||
123 | lib-$(CONFIG_PLATFORM_LINUX) += match_fstype.o | ||
124 | |||
124 | lib-$(CONFIG_FEATURE_UTMP) += utmp.o | 125 | lib-$(CONFIG_FEATURE_UTMP) += utmp.o |
125 | 126 | ||
126 | # A mix of optimizations (why build stuff we know won't be used) | 127 | # A mix of optimizations (why build stuff we know won't be used) |
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index b1c772cf3..4e32414b4 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c | |||
@@ -574,12 +574,12 @@ static void check_suid(int applet_no) | |||
574 | # endif | 574 | # endif |
575 | check_need_suid: | 575 | check_need_suid: |
576 | # endif | 576 | # endif |
577 | if (APPLET_SUID(applet_no) == _BB_SUID_REQUIRE) { | 577 | if (APPLET_SUID(applet_no) == BB_SUID_REQUIRE) { |
578 | /* Real uid is not 0. If euid isn't 0 too, suid bit | 578 | /* Real uid is not 0. If euid isn't 0 too, suid bit |
579 | * is most probably not set on our executable */ | 579 | * is most probably not set on our executable */ |
580 | if (geteuid()) | 580 | if (geteuid()) |
581 | bb_error_msg_and_die("must be suid to work properly"); | 581 | bb_error_msg_and_die("must be suid to work properly"); |
582 | } else if (APPLET_SUID(applet_no) == _BB_SUID_DROP) { | 582 | } else if (APPLET_SUID(applet_no) == BB_SUID_DROP) { |
583 | xsetgid(rgid); /* drop all privileges */ | 583 | xsetgid(rgid); /* drop all privileges */ |
584 | xsetuid(ruid); | 584 | xsetuid(ruid); |
585 | } | 585 | } |
diff --git a/libbb/getpty.c b/libbb/getpty.c index ea653b0b6..6a15cff2f 100644 --- a/libbb/getpty.c +++ b/libbb/getpty.c | |||
@@ -19,7 +19,7 @@ int FAST_FUNC xgetpty(char *line) | |||
19 | if (p > 0) { | 19 | if (p > 0) { |
20 | grantpt(p); /* chmod+chown corresponding slave pty */ | 20 | grantpt(p); /* chmod+chown corresponding slave pty */ |
21 | unlockpt(p); /* (what does this do?) */ | 21 | unlockpt(p); /* (what does this do?) */ |
22 | #if 0 /* if ptsname_r is not available... */ | 22 | #ifndef HAVE_PTSNAME_R |
23 | const char *name; | 23 | const char *name; |
24 | name = ptsname(p); /* find out the name of slave pty */ | 24 | name = ptsname(p); /* find out the name of slave pty */ |
25 | if (!name) { | 25 | if (!name) { |
diff --git a/libbb/makedev.c b/libbb/makedev.c index cf59e616b..06c4039a3 100644 --- a/libbb/makedev.c +++ b/libbb/makedev.c | |||
@@ -8,16 +8,23 @@ | |||
8 | 8 | ||
9 | /* We do not include libbb.h - #define makedev() is there! */ | 9 | /* We do not include libbb.h - #define makedev() is there! */ |
10 | #include "platform.h" | 10 | #include "platform.h" |
11 | #include <features.h> | 11 | |
12 | #include <sys/sysmacros.h> | 12 | /* Different Unixes want different headers for makedev */ |
13 | #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) \ | ||
14 | || defined(__APPLE__) | ||
15 | # include <sys/types.h> | ||
16 | #else | ||
17 | # include <features.h> | ||
18 | # include <sys/sysmacros.h> | ||
19 | #endif | ||
13 | 20 | ||
14 | #ifdef __GLIBC__ | 21 | #ifdef __GLIBC__ |
15 | /* At least glibc has horrendously large inline for this, so wrap it */ | 22 | /* At least glibc has horrendously large inline for this, so wrap it. */ |
16 | /* uclibc people please check - do we need "&& !__UCLIBC__" above? */ | 23 | /* uclibc people please check - do we need "&& !__UCLIBC__" above? */ |
17 | 24 | ||
18 | /* suppress gcc "no previous prototype" warning */ | 25 | /* Suppress gcc "no previous prototype" warning */ |
19 | unsigned long long FAST_FUNC bb_makedev(unsigned int major, unsigned int minor); | 26 | unsigned long long FAST_FUNC bb_makedev(unsigned major, unsigned minor); |
20 | unsigned long long FAST_FUNC bb_makedev(unsigned int major, unsigned int minor) | 27 | unsigned long long FAST_FUNC bb_makedev(unsigned major, unsigned minor) |
21 | { | 28 | { |
22 | return makedev(major, minor); | 29 | return makedev(major, minor); |
23 | } | 30 | } |
diff --git a/libbb/messages.c b/libbb/messages.c index 3c3ec3519..9e7bd0fef 100644 --- a/libbb/messages.c +++ b/libbb/messages.c | |||
@@ -50,17 +50,16 @@ const int const_int_1 = 1; | |||
50 | * and it will end up in bss */ | 50 | * and it will end up in bss */ |
51 | const int const_int_0 = 0; | 51 | const int const_int_0 = 0; |
52 | 52 | ||
53 | #if !ENABLE_PLATFORM_MINGW32 /* No wtmp on Windows */ | 53 | #if ENABLE_FEATURE_WTMP |
54 | #include <utmp.h> | ||
55 | /* This is usually something like "/var/adm/wtmp" or "/var/log/wtmp" */ | 54 | /* This is usually something like "/var/adm/wtmp" or "/var/log/wtmp" */ |
56 | const char bb_path_wtmp_file[] ALIGN1 = | 55 | const char bb_path_wtmp_file[] ALIGN1 = |
57 | #if defined _PATH_WTMP | 56 | # if defined _PATH_WTMP |
58 | _PATH_WTMP; | 57 | _PATH_WTMP; |
59 | #elif defined WTMP_FILE | 58 | # elif defined WTMP_FILE |
60 | WTMP_FILE; | 59 | WTMP_FILE; |
61 | #else | 60 | # else |
62 | #error unknown path to wtmp file | 61 | # error unknown path to wtmp file |
63 | #endif | 62 | # endif |
64 | #endif | 63 | #endif |
65 | 64 | ||
66 | /* We use it for "global" data via *(struct global*)&bb_common_bufsiz1. | 65 | /* We use it for "global" data via *(struct global*)&bb_common_bufsiz1. |
diff --git a/libbb/procps.c b/libbb/procps.c index fcf86d9bb..c68d3e655 100644 --- a/libbb/procps.c +++ b/libbb/procps.c | |||
@@ -155,6 +155,7 @@ static unsigned long fast_strtoul_10(char **endptr) | |||
155 | return n; | 155 | return n; |
156 | } | 156 | } |
157 | 157 | ||
158 | # if ENABLE_FEATURE_FAST_TOP | ||
158 | static long fast_strtol_10(char **endptr) | 159 | static long fast_strtol_10(char **endptr) |
159 | { | 160 | { |
160 | if (**endptr != '-') | 161 | if (**endptr != '-') |
@@ -163,6 +164,7 @@ static long fast_strtol_10(char **endptr) | |||
163 | (*endptr)++; | 164 | (*endptr)++; |
164 | return - (long)fast_strtoul_10(endptr); | 165 | return - (long)fast_strtoul_10(endptr); |
165 | } | 166 | } |
167 | # endif | ||
166 | 168 | ||
167 | static char *skip_fields(char *str, int count) | 169 | static char *skip_fields(char *str, int count) |
168 | { | 170 | { |
@@ -451,7 +453,7 @@ procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags) | |||
451 | //FIXME: is it safe to assume this field exists? | 453 | //FIXME: is it safe to assume this field exists? |
452 | sp->last_seen_on_cpu = fast_strtoul_10(&cp); | 454 | sp->last_seen_on_cpu = fast_strtoul_10(&cp); |
453 | # endif | 455 | # endif |
454 | #endif /* end of !ENABLE_FEATURE_TOP_SMP_PROCESS */ | 456 | #endif /* FEATURE_FAST_TOP */ |
455 | 457 | ||
456 | #if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS | 458 | #if ENABLE_FEATURE_PS_ADDITIONAL_COLUMNS |
457 | sp->niceness = tasknice; | 459 | sp->niceness = tasknice; |
diff --git a/libbb/progress.c b/libbb/progress.c index 4c2763c53..40608b047 100644 --- a/libbb/progress.c +++ b/libbb/progress.c | |||
@@ -78,7 +78,7 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p, | |||
78 | /* Do not update on every call | 78 | /* Do not update on every call |
79 | * (we can be called on every network read!) */ | 79 | * (we can be called on every network read!) */ |
80 | if (since_last_update == 0 && !totalsize) | 80 | if (since_last_update == 0 && !totalsize) |
81 | return; | 81 | return; |
82 | 82 | ||
83 | beg_and_transferred = beg_range + transferred; | 83 | beg_and_transferred = beg_range + transferred; |
84 | ratio = 100; | 84 | ratio = 100; |
@@ -93,22 +93,9 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p, | |||
93 | 93 | ||
94 | #if ENABLE_UNICODE_SUPPORT | 94 | #if ENABLE_UNICODE_SUPPORT |
95 | init_unicode(); | 95 | init_unicode(); |
96 | /* libbb candidate? */ | ||
97 | { | 96 | { |
98 | wchar_t wbuf21[21]; | 97 | char *buf = unicode_conv_to_printable_fixedwidth(/*NULL,*/ curfile, 20); |
99 | char *buf = xstrdup(curfile); | 98 | fprintf(stderr, "\r%s%4u%% ", buf, ratio); |
100 | unsigned len; | ||
101 | |||
102 | /* trim to 20 wide chars max (sets wbuf21[20] to 0) | ||
103 | * also, in case mbstowcs fails, we at least | ||
104 | * dont get garbage */ | ||
105 | memset(wbuf21, 0, sizeof(wbuf21)); | ||
106 | /* convert to wide chars, no more than 20 */ | ||
107 | len = mbstowcs(wbuf21, curfile, 20); /* NB: may return -1 */ | ||
108 | /* back to multibyte; cant overflow */ | ||
109 | wcstombs(buf, wbuf21, INT_MAX); | ||
110 | len = (len > 20) ? 0 : 20 - len; | ||
111 | fprintf(stderr, "\r%s%*s%4u%% ", buf, len, "", ratio); | ||
112 | free(buf); | 99 | free(buf); |
113 | } | 100 | } |
114 | #else | 101 | #else |
@@ -158,7 +145,8 @@ void FAST_FUNC bb_progress_update(bb_progress_t *p, | |||
158 | /* (long long helps to have working ETA even if !LFS) */ | 145 | /* (long long helps to have working ETA even if !LFS) */ |
159 | unsigned eta = (unsigned long long)to_download*elapsed/(uoff_t)transferred - elapsed; | 146 | unsigned eta = (unsigned long long)to_download*elapsed/(uoff_t)transferred - elapsed; |
160 | unsigned secs = eta % 3600; | 147 | unsigned secs = eta % 3600; |
161 | fprintf(stderr, "%02u:%02u:%02u ETA", eta / 3600, secs / 60, secs % 60); | 148 | unsigned hours = eta / 3600; |
149 | fprintf(stderr, "%02u:%02u:%02u ETA", hours, secs / 60, secs % 60); | ||
162 | } | 150 | } |
163 | } | 151 | } |
164 | } | 152 | } |
diff --git a/libbb/systemd_support.c b/libbb/systemd_support.c new file mode 100644 index 000000000..981296dbb --- /dev/null +++ b/libbb/systemd_support.c | |||
@@ -0,0 +1,62 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2011 Davide Cavalca <davide@geexbox.org> | ||
3 | * | ||
4 | * Based on http://cgit.freedesktop.org/systemd/tree/src/sd-daemon.c | ||
5 | * Copyright 2010 Lennart Poettering | ||
6 | * | ||
7 | * Permission is hereby granted, free of charge, to any person | ||
8 | * obtaining a copy of this software and associated documentation files | ||
9 | * (the "Software"), to deal in the Software without restriction, | ||
10 | * including without limitation the rights to use, copy, modify, merge, | ||
11 | * publish, distribute, sublicense, and/or sell copies of the Software, | ||
12 | * and to permit persons to whom the Software is furnished to do so, | ||
13 | * subject to the following conditions: | ||
14 | * | ||
15 | * The above copyright notice and this permission notice shall be | ||
16 | * included in all copies or substantial portions of the Software. | ||
17 | * | ||
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
22 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
23 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
25 | * SOFTWARE. | ||
26 | */ | ||
27 | #include "libbb.h" | ||
28 | |||
29 | //config:config FEATURE_SYSTEMD | ||
30 | //config: bool "Enable systemd support" | ||
31 | //config: default y | ||
32 | //config: help | ||
33 | //config: If you plan to use busybox daemons on a system where daemons | ||
34 | //config: are controlled by systemd, enable this option. | ||
35 | //config: If you don't use systemd, it is still safe to enable it, | ||
36 | //config: but yhe downside is increased code size. | ||
37 | |||
38 | //kbuild:lib-$(CONFIG_FEATURE_SYSTEMD) += systemd_support.o | ||
39 | |||
40 | int sd_listen_fds(void) | ||
41 | { | ||
42 | const char *e; | ||
43 | int n; | ||
44 | int fd; | ||
45 | |||
46 | e = getenv("LISTEN_PID"); | ||
47 | if (!e) | ||
48 | return 0; | ||
49 | n = xatoi_positive(e); | ||
50 | /* Is this for us? */ | ||
51 | if (getpid() != (pid_t) n) | ||
52 | return 0; | ||
53 | |||
54 | e = getenv("LISTEN_FDS"); | ||
55 | if (!e) | ||
56 | return 0; | ||
57 | n = xatoi_positive(e); | ||
58 | for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; fd++) | ||
59 | close_on_exec_on(fd); | ||
60 | |||
61 | return n; | ||
62 | } | ||
diff --git a/libbb/time.c b/libbb/time.c index 1eb2d75c2..e2b938471 100644 --- a/libbb/time.c +++ b/libbb/time.c | |||
@@ -91,7 +91,13 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm) | |||
91 | * .SS Seconds, a number from 0 to 61 (with leap seconds) | 91 | * .SS Seconds, a number from 0 to 61 (with leap seconds) |
92 | * Everything but the minutes is optional | 92 | * Everything but the minutes is optional |
93 | * | 93 | * |
94 | * This coincides with the format of "touch -t TIME" | 94 | * "touch -t DATETIME" format: [[[[[YY]YY]MM]DD]hh]mm[.ss] |
95 | * Some, but not all, Unix "date DATETIME" commands | ||
96 | * move [[YY]YY] past minutes mm field (!). | ||
97 | * Coreutils date does it, and SUS mandates it. | ||
98 | * (date -s DATETIME does not support this format. lovely!) | ||
99 | * In bbox, this format is special-cased in date applet | ||
100 | * (IOW: this function assumes "touch -t" format). | ||
95 | */ | 101 | */ |
96 | unsigned cur_year = ptm->tm_year; | 102 | unsigned cur_year = ptm->tm_year; |
97 | int len = strchrnul(date_str, '.') - date_str; | 103 | int len = strchrnul(date_str, '.') - date_str; |
diff --git a/libbb/unicode.c b/libbb/unicode.c index cf0c6bed9..08a4c7427 100644 --- a/libbb/unicode.c +++ b/libbb/unicode.c | |||
@@ -1107,16 +1107,17 @@ char* FAST_FUNC unicode_conv_to_printable(uni_stat_t *stats, const char *src) | |||
1107 | { | 1107 | { |
1108 | return unicode_conv_to_printable2(stats, src, INT_MAX, 0); | 1108 | return unicode_conv_to_printable2(stats, src, INT_MAX, 0); |
1109 | } | 1109 | } |
1110 | char* FAST_FUNC unicode_conv_to_printable_maxwidth(uni_stat_t *stats, const char *src, unsigned maxwidth) | 1110 | char* FAST_FUNC unicode_conv_to_printable_fixedwidth(/*uni_stat_t *stats,*/ const char *src, unsigned width) |
1111 | { | 1111 | { |
1112 | return unicode_conv_to_printable2(stats, src, maxwidth, 0); | 1112 | return unicode_conv_to_printable2(/*stats:*/ NULL, src, width, UNI_FLAG_PAD); |
1113 | } | 1113 | } |
1114 | char* FAST_FUNC unicode_conv_to_printable_fixedwidth(uni_stat_t *stats, const char *src, unsigned width) | 1114 | |
1115 | #ifdef UNUSED | ||
1116 | char* FAST_FUNC unicode_conv_to_printable_maxwidth(uni_stat_t *stats, const char *src, unsigned maxwidth) | ||
1115 | { | 1117 | { |
1116 | return unicode_conv_to_printable2(stats, src, width, UNI_FLAG_PAD); | 1118 | return unicode_conv_to_printable2(stats, src, maxwidth, 0); |
1117 | } | 1119 | } |
1118 | 1120 | ||
1119 | #ifdef UNUSED | ||
1120 | unsigned FAST_FUNC unicode_padding_to_width(unsigned width, const char *src) | 1121 | unsigned FAST_FUNC unicode_padding_to_width(unsigned width, const char *src) |
1121 | { | 1122 | { |
1122 | if (unicode_status != UNICODE_ON) { | 1123 | if (unicode_status != UNICODE_ON) { |
diff --git a/libbb/utmp.c b/libbb/utmp.c index 2bf9c11f2..09443fb6c 100644 --- a/libbb/utmp.c +++ b/libbb/utmp.c | |||
@@ -7,7 +7,6 @@ | |||
7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | #include "libbb.h" | 9 | #include "libbb.h" |
10 | #include <utmp.h> | ||
11 | 10 | ||
12 | static void touch(const char *filename) | 11 | static void touch(const char *filename) |
13 | { | 12 | { |
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 53c48557d..e657820f3 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -25,19 +25,25 @@ | |||
25 | #include "libbb.h" | 25 | #include "libbb.h" |
26 | 26 | ||
27 | /* Turn on nonblocking I/O on a fd */ | 27 | /* Turn on nonblocking I/O on a fd */ |
28 | int FAST_FUNC ndelay_on(int fd) | 28 | void FAST_FUNC ndelay_on(int fd) |
29 | { | 29 | { |
30 | return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK); | 30 | int flags = fcntl(fd, F_GETFL); |
31 | if (flags & O_NONBLOCK) | ||
32 | return; | ||
33 | fcntl(fd, F_SETFL, flags | O_NONBLOCK); | ||
31 | } | 34 | } |
32 | 35 | ||
33 | int FAST_FUNC ndelay_off(int fd) | 36 | void FAST_FUNC ndelay_off(int fd) |
34 | { | 37 | { |
35 | return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NONBLOCK); | 38 | int flags = fcntl(fd, F_GETFL); |
39 | if (!(flags & O_NONBLOCK)) | ||
40 | return; | ||
41 | fcntl(fd, F_SETFL, flags & ~O_NONBLOCK); | ||
36 | } | 42 | } |
37 | 43 | ||
38 | int FAST_FUNC close_on_exec_on(int fd) | 44 | void FAST_FUNC close_on_exec_on(int fd) |
39 | { | 45 | { |
40 | return fcntl(fd, F_SETFD, FD_CLOEXEC); | 46 | fcntl(fd, F_SETFD, FD_CLOEXEC); |
41 | } | 47 | } |
42 | 48 | ||
43 | char* FAST_FUNC strncpy_IFNAMSIZ(char *dst, const char *src) | 49 | char* FAST_FUNC strncpy_IFNAMSIZ(char *dst, const char *src) |
diff --git a/libpwdgrp/pwd_grp.c b/libpwdgrp/pwd_grp.c index abb6f189a..2eb9d9dd1 100644 --- a/libpwdgrp/pwd_grp.c +++ b/libpwdgrp/pwd_grp.c | |||
@@ -20,16 +20,6 @@ | |||
20 | #include "libbb.h" | 20 | #include "libbb.h" |
21 | #include <assert.h> | 21 | #include <assert.h> |
22 | 22 | ||
23 | #ifndef _PATH_SHADOW | ||
24 | #define _PATH_SHADOW "/etc/shadow" | ||
25 | #endif | ||
26 | #ifndef _PATH_PASSWD | ||
27 | #define _PATH_PASSWD "/etc/passwd" | ||
28 | #endif | ||
29 | #ifndef _PATH_GROUP | ||
30 | #define _PATH_GROUP "/etc/group" | ||
31 | #endif | ||
32 | |||
33 | /**********************************************************************/ | 23 | /**********************************************************************/ |
34 | /* Sizes for statically allocated buffers. */ | 24 | /* Sizes for statically allocated buffers. */ |
35 | 25 | ||
diff --git a/loginutils/Config.src b/loginutils/Config.src index 8158bce74..4c771bbc4 100644 --- a/loginutils/Config.src +++ b/loginutils/Config.src | |||
@@ -186,7 +186,6 @@ config GETTY | |||
186 | config LOGIN | 186 | config LOGIN |
187 | bool "login" | 187 | bool "login" |
188 | default y | 188 | default y |
189 | select FEATURE_SUID | ||
190 | select FEATURE_SYSLOG | 189 | select FEATURE_SYSLOG |
191 | help | 190 | help |
192 | login is used when signing onto a system. | 191 | login is used when signing onto a system. |
@@ -229,7 +228,6 @@ config FEATURE_SECURETTY | |||
229 | config PASSWD | 228 | config PASSWD |
230 | bool "passwd" | 229 | bool "passwd" |
231 | default y | 230 | default y |
232 | select FEATURE_SUID | ||
233 | select FEATURE_SYSLOG | 231 | select FEATURE_SYSLOG |
234 | help | 232 | help |
235 | passwd changes passwords for user and group accounts. A normal user | 233 | passwd changes passwords for user and group accounts. A normal user |
@@ -265,7 +263,6 @@ config CHPASSWD | |||
265 | config SU | 263 | config SU |
266 | bool "su" | 264 | bool "su" |
267 | default y | 265 | default y |
268 | select FEATURE_SUID | ||
269 | select FEATURE_SYSLOG | 266 | select FEATURE_SYSLOG |
270 | help | 267 | help |
271 | su is used to become another user during a login session. | 268 | su is used to become another user during a login session. |
@@ -295,7 +292,6 @@ config SULOGIN | |||
295 | config VLOCK | 292 | config VLOCK |
296 | bool "vlock" | 293 | bool "vlock" |
297 | default y | 294 | default y |
298 | select FEATURE_SUID | ||
299 | help | 295 | help |
300 | Build the "vlock" applet which allows you to lock (virtual) terminals. | 296 | Build the "vlock" applet which allows you to lock (virtual) terminals. |
301 | 297 | ||
diff --git a/loginutils/add-remove-shell.c b/loginutils/add-remove-shell.c index 757e50503..9a1454430 100644 --- a/loginutils/add-remove-shell.c +++ b/loginutils/add-remove-shell.c | |||
@@ -8,8 +8,8 @@ | |||
8 | * for details. | 8 | * for details. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | //applet:IF_ADD_SHELL( APPLET_ODDNAME(add-shell , add_remove_shell, _BB_DIR_USR_BIN, _BB_SUID_DROP, add_shell )) | 11 | //applet:IF_ADD_SHELL( APPLET_ODDNAME(add-shell , add_remove_shell, BB_DIR_USR_BIN, BB_SUID_DROP, add_shell )) |
12 | //applet:IF_REMOVE_SHELL(APPLET_ODDNAME(remove-shell, add_remove_shell, _BB_DIR_USR_BIN, _BB_SUID_DROP, remove_shell)) | 12 | //applet:IF_REMOVE_SHELL(APPLET_ODDNAME(remove-shell, add_remove_shell, BB_DIR_USR_BIN, BB_SUID_DROP, remove_shell)) |
13 | 13 | ||
14 | //kbuild:lib-$(CONFIG_ADD_SHELL) += add-remove-shell.o | 14 | //kbuild:lib-$(CONFIG_ADD_SHELL) += add-remove-shell.o |
15 | //kbuild:lib-$(CONFIG_REMOVE_SHELL) += add-remove-shell.o | 15 | //kbuild:lib-$(CONFIG_REMOVE_SHELL) += add-remove-shell.o |
diff --git a/loginutils/adduser.c b/loginutils/adduser.c index 1a9949e97..d938b80f3 100644 --- a/loginutils/adduser.c +++ b/loginutils/adduser.c | |||
@@ -78,11 +78,11 @@ static void addgroup_wrapper(struct passwd *p, const char *group_name) | |||
78 | free(cmd); | 78 | free(cmd); |
79 | } | 79 | } |
80 | 80 | ||
81 | static void passwd_wrapper(const char *login) NORETURN; | 81 | static void passwd_wrapper(const char *login_name) NORETURN; |
82 | 82 | ||
83 | static void passwd_wrapper(const char *login) | 83 | static void passwd_wrapper(const char *login_name) |
84 | { | 84 | { |
85 | BB_EXECLP("passwd", "passwd", login, NULL); | 85 | BB_EXECLP("passwd", "passwd", login_name, NULL); |
86 | bb_error_msg_and_die("can't execute passwd, you must set password manually"); | 86 | bb_error_msg_and_die("can't execute passwd, you must set password manually"); |
87 | } | 87 | } |
88 | 88 | ||
diff --git a/loginutils/getty.c b/loginutils/getty.c index 76b0de449..b71d68a1f 100644 --- a/loginutils/getty.c +++ b/loginutils/getty.c | |||
@@ -1,43 +1,50 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* agetty.c - another getty program for Linux. By W. Z. Venema 1989 | 2 | /* |
3 | * Based on agetty - another getty program for Linux. By W. Z. Venema 1989 | ||
3 | * Ported to Linux by Peter Orbaek <poe@daimi.aau.dk> | 4 | * Ported to Linux by Peter Orbaek <poe@daimi.aau.dk> |
4 | * This program is freely distributable. The entire man-page used to | 5 | * This program is freely distributable. |
5 | * be here. Now read the real man-page agetty.8 instead. | ||
6 | * | 6 | * |
7 | * option added by Eric Rasmussen <ear@usfirst.org> - 12/28/95 | 7 | * option added by Eric Rasmussen <ear@usfirst.org> - 12/28/95 |
8 | * | 8 | * |
9 | * 1999-02-22 Arkadiusz Mickiewicz <misiek@misiek.eu.org> | 9 | * 1999-02-22 Arkadiusz Mickiewicz <misiek@misiek.eu.org> |
10 | * - added Native Language Support | 10 | * - Added Native Language Support |
11 | * | 11 | * |
12 | * 1999-05-05 Thorsten Kranzkowski <dl8bcu@gmx.net> | 12 | * 1999-05-05 Thorsten Kranzkowski <dl8bcu@gmx.net> |
13 | * - enable hardware flow control before displaying /etc/issue | 13 | * - Enabled hardware flow control before displaying /etc/issue |
14 | * | ||
15 | * 2011-01 Venys Vlasenko | ||
16 | * - Removed parity detection code. It can't work reliably: | ||
17 | * if all chars received have bit 7 cleared and odd (or even) parity, | ||
18 | * it is impossible to determine whether other side is 8-bit,no-parity | ||
19 | * or 7-bit,odd(even)-parity. It also interferes with non-ASCII usernames. | ||
20 | * - From now on, we assume that parity is correctly set. | ||
14 | * | 21 | * |
15 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 22 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
16 | */ | 23 | */ |
17 | 24 | ||
18 | #include "libbb.h" | 25 | #include "libbb.h" |
19 | #include <syslog.h> | 26 | #include <syslog.h> |
27 | #ifndef IUCLC | ||
28 | # define IUCLC 0 | ||
29 | #endif | ||
20 | 30 | ||
21 | #if ENABLE_FEATURE_UTMP | 31 | #ifndef LOGIN_PROCESS |
22 | # include <utmp.h> /* LOGIN_PROCESS */ | 32 | # undef ENABLE_FEATURE_UTMP |
33 | # undef ENABLE_FEATURE_WTMP | ||
34 | # define ENABLE_FEATURE_UTMP 0 | ||
35 | # define ENABLE_FEATURE_WTMP 0 | ||
23 | #endif | 36 | #endif |
24 | 37 | ||
25 | #ifndef IUCLC | 38 | |
26 | # define IUCLC 0 | 39 | /* The following is used for understandable diagnostics */ |
40 | #ifdef DEBUGGING | ||
41 | static FILE *dbf; | ||
42 | # define DEBUGTERM "/dev/ttyp0" | ||
43 | # define debug(...) do { fprintf(dbf, __VA_ARGS__); fflush(dbf); } while (0) | ||
44 | #else | ||
45 | # define debug(...) ((void)0) | ||
27 | #endif | 46 | #endif |
28 | 47 | ||
29 | /* | ||
30 | * Some heuristics to find out what environment we are in: if it is not | ||
31 | * System V, assume it is SunOS 4. | ||
32 | */ | ||
33 | #ifdef LOGIN_PROCESS /* defined in System V utmp.h */ | ||
34 | #include <sys/utsname.h> | ||
35 | #else /* if !sysV style, wtmp/utmp code is off */ | ||
36 | #undef ENABLE_FEATURE_UTMP | ||
37 | #undef ENABLE_FEATURE_WTMP | ||
38 | #define ENABLE_FEATURE_UTMP 0 | ||
39 | #define ENABLE_FEATURE_WTMP 0 | ||
40 | #endif /* LOGIN_PROCESS */ | ||
41 | 48 | ||
42 | /* | 49 | /* |
43 | * Things you may want to modify. | 50 | * Things you may want to modify. |
@@ -46,110 +53,88 @@ | |||
46 | * below. Note, however, that DEL cannot be used for interrupt generation | 53 | * below. Note, however, that DEL cannot be used for interrupt generation |
47 | * and for line editing at the same time. | 54 | * and for line editing at the same time. |
48 | */ | 55 | */ |
49 | 56 | #undef _PATH_LOGIN | |
50 | /* I doubt there are systems which still need this */ | ||
51 | #undef HANDLE_ALLCAPS | ||
52 | #undef ANCIENT_BS_KILL_CHARS | ||
53 | |||
54 | #define _PATH_LOGIN "/bin/login" | 57 | #define _PATH_LOGIN "/bin/login" |
55 | 58 | ||
56 | /* If ISSUE is not defined, getty will never display the contents of the | 59 | /* Displayed before the login prompt. |
60 | * If ISSUE is not defined, getty will never display the contents of the | ||
57 | * /etc/issue file. You will not want to spit out large "issue" files at the | 61 | * /etc/issue file. You will not want to spit out large "issue" files at the |
58 | * wrong baud rate. | 62 | * wrong baud rate. |
59 | */ | 63 | */ |
60 | #define ISSUE "/etc/issue" /* displayed before the login prompt */ | 64 | #define ISSUE "/etc/issue" |
61 | 65 | ||
62 | /* Some shorthands for control characters. */ | 66 | /* Some shorthands for control characters */ |
63 | #define CTL(x) ((x) ^ 0100) /* Assumes ASCII dialect */ | 67 | #define CTL(x) ((x) ^ 0100) /* Assumes ASCII dialect */ |
64 | #define CR CTL('M') /* carriage return */ | ||
65 | #define NL CTL('J') /* line feed */ | ||
66 | #define BS CTL('H') /* back space */ | 68 | #define BS CTL('H') /* back space */ |
67 | #define DEL CTL('?') /* delete */ | 69 | #define DEL CTL('?') /* delete */ |
68 | 70 | ||
69 | /* Defaults for line-editing etc. characters; you may want to change this. */ | 71 | /* Defaults for line-editing etc. characters; you may want to change this */ |
70 | #define DEF_ERASE DEL /* default erase character */ | ||
71 | #define DEF_INTR CTL('C') /* default interrupt character */ | 72 | #define DEF_INTR CTL('C') /* default interrupt character */ |
72 | #define DEF_QUIT CTL('\\') /* default quit char */ | 73 | #define DEF_QUIT CTL('\\') /* default quit char */ |
73 | #define DEF_KILL CTL('U') /* default kill char */ | 74 | #define DEF_KILL CTL('U') /* default kill char */ |
74 | #define DEF_EOF CTL('D') /* default EOF char */ | 75 | #define DEF_EOF CTL('D') /* default EOF char */ |
75 | #define DEF_EOL '\n' | 76 | #define DEF_EOL '\n' |
76 | #define DEF_SWITCH 0 /* default switch char */ | 77 | #define DEF_SWITCH 0 /* default switch char (none) */ |
77 | 78 | ||
78 | /* | 79 | /* |
79 | * When multiple baud rates are specified on the command line, the first one | 80 | * When multiple baud rates are specified on the command line, |
80 | * we will try is the first one specified. | 81 | * the first one we will try is the first one specified. |
81 | */ | 82 | */ |
82 | #define MAX_SPEED 10 /* max. nr. of baud rates */ | 83 | #define MAX_SPEED 10 /* max. nr. of baud rates */ |
83 | 84 | ||
84 | /* Storage for command-line options. */ | 85 | struct globals { |
85 | struct options { | ||
86 | int flags; /* toggle switches, see below */ | ||
87 | unsigned timeout; /* time-out period */ | 86 | unsigned timeout; /* time-out period */ |
88 | const char *login; /* login program */ | 87 | const char *login; /* login program */ |
88 | const char *fakehost; | ||
89 | const char *tty; /* name of tty */ | 89 | const char *tty; /* name of tty */ |
90 | const char *initstring; /* modem init string */ | 90 | const char *initstring; /* modem init string */ |
91 | const char *issue; /* alternative issue file */ | 91 | const char *issue; /* alternative issue file */ |
92 | int numspeed; /* number of baud rates to try */ | 92 | int numspeed; /* number of baud rates to try */ |
93 | int speeds[MAX_SPEED]; /* baud rates to be tried */ | 93 | int speeds[MAX_SPEED]; /* baud rates to be tried */ |
94 | unsigned char eol; /* end-of-line char seen (CR or NL) */ | ||
95 | struct termios termios; /* terminal mode bits */ | ||
96 | char line_buf[128]; | ||
94 | }; | 97 | }; |
95 | 98 | ||
96 | /* Storage for things detected while the login name was read. */ | 99 | #define G (*ptr_to_globals) |
97 | struct chardata { | 100 | #define INIT_G() do { \ |
98 | unsigned char erase; /* erase character */ | 101 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
99 | unsigned char kill; /* kill character */ | 102 | } while (0) |
100 | unsigned char eol; /* end-of-line character */ | 103 | |
101 | unsigned char parity; /* what parity did we see */ | 104 | //usage:#define getty_trivial_usage |
102 | /* (parity & 1): saw odd parity char with 7th bit set */ | 105 | //usage: "[OPTIONS] BAUD_RATE[,BAUD_RATE]... TTY [TERMTYPE]" |
103 | /* (parity & 2): saw even parity char with 7th bit set */ | 106 | //usage:#define getty_full_usage "\n\n" |
104 | /* parity == 0: probably 7-bit, space parity? */ | 107 | //usage: "Open a tty, prompt for a login name, then invoke /bin/login\n" |
105 | /* parity == 1: probably 7-bit, odd parity? */ | 108 | //usage: "\nOptions:" |
106 | /* parity == 2: probably 7-bit, even parity? */ | 109 | //usage: "\n -h Enable hardware (RTS/CTS) flow control" |
107 | /* parity == 3: definitely 8 bit, no parity! */ | 110 | //usage: "\n -i Don't display /etc/issue" |
108 | /* Hmm... with any value of "parity" 8 bit, no parity is possible */ | 111 | //usage: "\n -L Local line, set CLOCAL on it" |
109 | #ifdef HANDLE_ALLCAPS | 112 | //usage: "\n -m Get baud rate from modem's CONNECT status message" |
110 | unsigned char capslock; /* upper case without lower case */ | 113 | //usage: "\n -w Wait for CR or LF before sending /etc/issue" |
111 | #endif | 114 | //usage: "\n -n Don't prompt for a login name" |
112 | }; | 115 | //usage: "\n -f ISSUE_FILE Display ISSUE_FILE instead of /etc/issue" |
113 | 116 | //usage: "\n -l LOGIN Invoke LOGIN instead of /bin/login" | |
114 | 117 | //usage: "\n -t SEC Terminate after SEC if no username is read" | |
115 | /* Initial values for the above. */ | 118 | //usage: "\n -I INITSTR Send INITSTR before anything else" |
116 | static const struct chardata init_chardata = { | 119 | //usage: "\n -H HOST Log HOST into the utmp file as the hostname" |
117 | DEF_ERASE, /* default erase character */ | 120 | //usage: "\n" |
118 | DEF_KILL, /* default kill character */ | 121 | //usage: "\nBAUD_RATE of 0 leaves it unchanged" |
119 | 13, /* default eol char */ | ||
120 | 0, /* space parity */ | ||
121 | #ifdef HANDLE_ALLCAPS | ||
122 | 0, /* no capslock */ | ||
123 | #endif | ||
124 | }; | ||
125 | 122 | ||
126 | static const char opt_string[] ALIGN1 = "I:LH:f:hil:mt:wn"; | 123 | static const char opt_string[] ALIGN1 = "I:LH:f:hil:mt:wn"; |
127 | #define F_INITSTRING (1 << 0) /* -I initstring is set */ | 124 | #define F_INITSTRING (1 << 0) /* -I */ |
128 | #define F_LOCAL (1 << 1) /* -L force local */ | 125 | #define F_LOCAL (1 << 1) /* -L */ |
129 | #define F_FAKEHOST (1 << 2) /* -H fake hostname */ | 126 | #define F_FAKEHOST (1 << 2) /* -H */ |
130 | #define F_CUSTISSUE (1 << 3) /* -f give alternative issue file */ | 127 | #define F_CUSTISSUE (1 << 3) /* -f */ |
131 | #define F_RTSCTS (1 << 4) /* -h enable RTS/CTS flow control */ | 128 | #define F_RTSCTS (1 << 4) /* -h */ |
132 | #define F_ISSUE (1 << 5) /* -i display /etc/issue */ | 129 | #define F_NOISSUE (1 << 5) /* -i */ |
133 | #define F_LOGIN (1 << 6) /* -l non-default login program */ | 130 | #define F_LOGIN (1 << 6) /* -l */ |
134 | #define F_PARSE (1 << 7) /* -m process modem status messages */ | 131 | #define F_PARSE (1 << 7) /* -m */ |
135 | #define F_TIMEOUT (1 << 8) /* -t time out */ | 132 | #define F_TIMEOUT (1 << 8) /* -t */ |
136 | #define F_WAITCRLF (1 << 9) /* -w wait for CR or LF */ | 133 | #define F_WAITCRLF (1 << 9) /* -w */ |
137 | #define F_NOPROMPT (1 << 10) /* -n don't ask for login name */ | 134 | #define F_NOPROMPT (1 << 10) /* -n */ |
138 | 135 | ||
139 | 136 | ||
140 | #define line_buf bb_common_bufsiz1 | 137 | /* convert speed string to speed code; return <= 0 on failure */ |
141 | |||
142 | /* The following is used for understandable diagnostics. */ | ||
143 | #ifdef DEBUGGING | ||
144 | static FILE *dbf; | ||
145 | #define DEBUGTERM "/dev/ttyp0" | ||
146 | #define debug(...) do { fprintf(dbf, __VA_ARGS__); fflush(dbf); } while (0) | ||
147 | #else | ||
148 | #define debug(...) ((void)0) | ||
149 | #endif | ||
150 | |||
151 | |||
152 | /* bcode - convert speed string to speed code; return <= 0 on failure */ | ||
153 | static int bcode(const char *s) | 138 | static int bcode(const char *s) |
154 | { | 139 | { |
155 | int value = bb_strtou(s, NULL, 10); /* yes, int is intended! */ | 140 | int value = bb_strtou(s, NULL, 10); /* yes, int is intended! */ |
@@ -158,53 +143,54 @@ static int bcode(const char *s) | |||
158 | return tty_value_to_baud(value); | 143 | return tty_value_to_baud(value); |
159 | } | 144 | } |
160 | 145 | ||
161 | /* parse_speeds - parse alternate baud rates */ | 146 | /* parse alternate baud rates */ |
162 | static void parse_speeds(struct options *op, char *arg) | 147 | static void parse_speeds(char *arg) |
163 | { | 148 | { |
164 | char *cp; | 149 | char *cp; |
165 | 150 | ||
166 | /* NB: at least one iteration is always done */ | 151 | /* NB: at least one iteration is always done */ |
167 | debug("entered parse_speeds\n"); | 152 | debug("entered parse_speeds\n"); |
168 | while ((cp = strsep(&arg, ",")) != NULL) { | 153 | while ((cp = strsep(&arg, ",")) != NULL) { |
169 | op->speeds[op->numspeed] = bcode(cp); | 154 | G.speeds[G.numspeed] = bcode(cp); |
170 | if (op->speeds[op->numspeed] < 0) | 155 | if (G.speeds[G.numspeed] < 0) |
171 | bb_error_msg_and_die("bad speed: %s", cp); | 156 | bb_error_msg_and_die("bad speed: %s", cp); |
172 | /* note: arg "0" turns into speed B0 */ | 157 | /* note: arg "0" turns into speed B0 */ |
173 | op->numspeed++; | 158 | G.numspeed++; |
174 | if (op->numspeed > MAX_SPEED) | 159 | if (G.numspeed > MAX_SPEED) |
175 | bb_error_msg_and_die("too many alternate speeds"); | 160 | bb_error_msg_and_die("too many alternate speeds"); |
176 | } | 161 | } |
177 | debug("exiting parse_speeds\n"); | 162 | debug("exiting parse_speeds\n"); |
178 | } | 163 | } |
179 | 164 | ||
180 | /* parse_args - parse command-line arguments */ | 165 | /* parse command-line arguments */ |
181 | static void parse_args(char **argv, struct options *op, char **fakehost_p) | 166 | static void parse_args(char **argv) |
182 | { | 167 | { |
183 | char *ts; | 168 | char *ts; |
169 | int flags; | ||
184 | 170 | ||
185 | opt_complementary = "-2:t+"; /* at least 2 args; -t N */ | 171 | opt_complementary = "-2:t+"; /* at least 2 args; -t N */ |
186 | op->flags = getopt32(argv, opt_string, | 172 | flags = getopt32(argv, opt_string, |
187 | &(op->initstring), fakehost_p, &(op->issue), | 173 | &G.initstring, &G.fakehost, &G.issue, |
188 | &(op->login), &op->timeout); | 174 | &G.login, &G.timeout |
189 | argv += optind; | 175 | ); |
190 | if (op->flags & F_INITSTRING) { | 176 | if (flags & F_INITSTRING) { |
191 | op->initstring = xstrdup(op->initstring); | 177 | G.initstring = xstrdup(G.initstring); |
192 | /* decode \ddd octal codes into chars */ | 178 | /* decode \ddd octal codes into chars */ |
193 | strcpy_and_process_escape_sequences((char*)op->initstring, op->initstring); | 179 | strcpy_and_process_escape_sequences((char*)G.initstring, G.initstring); |
194 | } | 180 | } |
195 | op->flags ^= F_ISSUE; /* invert flag "show /etc/issue" */ | 181 | argv += optind; |
196 | debug("after getopt\n"); | 182 | debug("after getopt\n"); |
197 | 183 | ||
198 | /* we loosen up a bit and accept both "baudrate tty" and "tty baudrate" */ | 184 | /* We loosen up a bit and accept both "baudrate tty" and "tty baudrate" */ |
199 | op->tty = argv[0]; /* tty name */ | 185 | G.tty = argv[0]; /* tty name */ |
200 | ts = argv[1]; /* baud rate(s) */ | 186 | ts = argv[1]; /* baud rate(s) */ |
201 | if (isdigit(argv[0][0])) { | 187 | if (isdigit(argv[0][0])) { |
202 | /* a number first, assume it's a speed (BSD style) */ | 188 | /* A number first, assume it's a speed (BSD style) */ |
203 | op->tty = ts; /* tty name is in argv[1] */ | 189 | G.tty = ts; /* tty name is in argv[1] */ |
204 | ts = argv[0]; /* baud rate(s) */ | 190 | ts = argv[0]; /* baud rate(s) */ |
205 | } | 191 | } |
206 | parse_speeds(op, ts); | 192 | parse_speeds(ts); |
207 | applet_name = xasprintf("getty: %s", op->tty); | 193 | applet_name = xasprintf("getty: %s", G.tty); |
208 | 194 | ||
209 | if (argv[2]) | 195 | if (argv[2]) |
210 | xsetenv("TERM", argv[2]); | 196 | xsetenv("TERM", argv[2]); |
@@ -212,40 +198,20 @@ static void parse_args(char **argv, struct options *op, char **fakehost_p) | |||
212 | debug("exiting parse_args\n"); | 198 | debug("exiting parse_args\n"); |
213 | } | 199 | } |
214 | 200 | ||
215 | /* open_tty - set up tty as standard { input, output, error } */ | 201 | /* set up tty as standard input, output, error */ |
216 | static void open_tty(const char *tty) | 202 | static void open_tty(void) |
217 | { | 203 | { |
218 | /* Set up new standard input, unless we are given an already opened port. */ | 204 | /* Set up new standard input, unless we are given an already opened port */ |
219 | if (NOT_LONE_DASH(tty)) { | 205 | if (NOT_LONE_DASH(G.tty)) { |
220 | // struct stat st; | 206 | if (G.tty[0] != '/') |
221 | // int cur_dir_fd; | 207 | G.tty = xasprintf("/dev/%s", G.tty); /* will leak it */ |
222 | // int fd; | 208 | |
223 | 209 | /* Open the tty as standard input */ | |
224 | /* Sanity checks... */ | ||
225 | // cur_dir_fd = xopen(".", O_DIRECTORY | O_NONBLOCK); | ||
226 | // xchdir("/dev"); | ||
227 | // xstat(tty, &st); | ||
228 | // if (!S_ISCHR(st.st_mode)) | ||
229 | // bb_error_msg_and_die("not a character device"); | ||
230 | |||
231 | if (tty[0] != '/') | ||
232 | tty = xasprintf("/dev/%s", tty); /* will leak it */ | ||
233 | |||
234 | /* Open the tty as standard input. */ | ||
235 | debug("open(2)\n"); | 210 | debug("open(2)\n"); |
236 | close(0); | 211 | close(0); |
237 | /*fd =*/ xopen(tty, O_RDWR | O_NONBLOCK); /* uses fd 0 */ | 212 | xopen(G.tty, O_RDWR | O_NONBLOCK); /* uses fd 0 */ |
238 | |||
239 | // /* Restore current directory */ | ||
240 | // fchdir(cur_dir_fd); | ||
241 | 213 | ||
242 | /* Open the tty as standard input, continued */ | 214 | /* Set proper protections and ownership */ |
243 | // xmove_fd(fd, 0); | ||
244 | // /* fd is >= cur_dir_fd, and cur_dir_fd gets closed too here: */ | ||
245 | // while (fd > 2) | ||
246 | // close(fd--); | ||
247 | |||
248 | /* Set proper protections and ownership. */ | ||
249 | fchown(0, 0, 0); /* 0:0 */ | 215 | fchown(0, 0, 0); /* 0:0 */ |
250 | fchmod(0, 0620); /* crw--w---- */ | 216 | fchmod(0, 0620); /* crw--w---- */ |
251 | } else { | 217 | } else { |
@@ -253,62 +219,100 @@ static void open_tty(const char *tty) | |||
253 | * Standard input should already be connected to an open port. Make | 219 | * Standard input should already be connected to an open port. Make |
254 | * sure it is open for read/write. | 220 | * sure it is open for read/write. |
255 | */ | 221 | */ |
256 | if ((fcntl(0, F_GETFL) & O_RDWR) != O_RDWR) | 222 | if ((fcntl(0, F_GETFL) & (O_RDWR|O_RDONLY|O_WRONLY)) != O_RDWR) |
257 | bb_error_msg_and_die("stdin is not open for read/write"); | 223 | bb_error_msg_and_die("stdin is not open for read/write"); |
258 | } | 224 | } |
259 | } | 225 | } |
260 | 226 | ||
261 | /* termios_init - initialize termios settings */ | 227 | /* We manipulate termios this way: |
262 | static void termios_init(struct termios *tp, int speed, struct options *op) | 228 | * - first, we read existing termios settings |
229 | * - termios_init modifies some parts and sets it | ||
230 | * - auto_baud and/or BREAK processing can set different speed and set termios | ||
231 | * - termios_final again modifies some parts and sets termios before | ||
232 | * execing login | ||
233 | */ | ||
234 | static void termios_init(int speed) | ||
263 | { | 235 | { |
264 | speed_t ispeed, ospeed; | 236 | /* Flush input and output queues, important for modems! |
237 | * Users report losing previously queued output chars, and I hesitate | ||
238 | * to use tcdrain here instead of tcflush - I imagine it can block. | ||
239 | * Using small sleep instead. | ||
240 | */ | ||
241 | usleep(100*1000); /* 0.1 sec */ | ||
242 | tcflush(STDIN_FILENO, TCIOFLUSH); | ||
243 | |||
244 | /* Set speed if it wasn't specified as "0" on command line */ | ||
245 | if (speed != B0) | ||
246 | cfsetspeed(&G.termios, speed); | ||
247 | |||
265 | /* | 248 | /* |
266 | * Initial termios settings: 8-bit characters, raw-mode, blocking i/o. | 249 | * Initial termios settings: 8-bit characters, raw-mode, blocking i/o. |
267 | * Special characters are set after we have read the login name; all | 250 | * Special characters are set after we have read the login name; all |
268 | * reads will be done in raw mode anyway. Errors will be dealt with | 251 | * reads will be done in raw mode anyway. Errors will be dealt with |
269 | * later on. | 252 | * later on. |
270 | */ | 253 | */ |
271 | /* flush input and output queues, important for modems! */ | 254 | G.termios.c_cflag = CS8 | HUPCL | CREAD; |
272 | tcflush(0, TCIOFLUSH); | 255 | if (option_mask32 & F_LOCAL) |
273 | ispeed = ospeed = speed; | 256 | G.termios.c_cflag |= CLOCAL; |
274 | if (speed == B0) { | 257 | G.termios.c_iflag = 0; |
275 | /* Speed was specified as "0" on command line. | 258 | G.termios.c_lflag = 0; |
276 | * Just leave it unchanged */ | 259 | G.termios.c_oflag = OPOST | ONLCR; |
277 | ispeed = cfgetispeed(tp); | 260 | G.termios.c_cc[VMIN] = 1; |
278 | ospeed = cfgetospeed(tp); | 261 | G.termios.c_cc[VTIME] = 0; |
279 | } | ||
280 | tp->c_cflag = CS8 | HUPCL | CREAD; | ||
281 | if (op->flags & F_LOCAL) | ||
282 | tp->c_cflag |= CLOCAL; | ||
283 | cfsetispeed(tp, ispeed); | ||
284 | cfsetospeed(tp, ospeed); | ||
285 | |||
286 | tp->c_iflag = tp->c_lflag = 0; | ||
287 | tp->c_oflag = OPOST | ONLCR; | ||
288 | tp->c_cc[VMIN] = 1; | ||
289 | tp->c_cc[VTIME] = 0; | ||
290 | #ifdef __linux__ | 262 | #ifdef __linux__ |
291 | tp->c_line = 0; | 263 | G.termios.c_line = 0; |
292 | #endif | 264 | #endif |
293 | |||
294 | /* Optionally enable hardware flow control */ | ||
295 | #ifdef CRTSCTS | 265 | #ifdef CRTSCTS |
296 | if (op->flags & F_RTSCTS) | 266 | if (option_mask32 & F_RTSCTS) |
297 | tp->c_cflag |= CRTSCTS; | 267 | G.termios.c_cflag |= CRTSCTS; |
298 | #endif | 268 | #endif |
299 | 269 | ||
300 | tcsetattr_stdin_TCSANOW(tp); | 270 | tcsetattr_stdin_TCSANOW(&G.termios); |
301 | 271 | ||
302 | debug("term_io 2\n"); | 272 | debug("term_io 2\n"); |
303 | } | 273 | } |
304 | 274 | ||
305 | /* auto_baud - extract baud rate from modem status message */ | 275 | static void termios_final(void) |
306 | static void auto_baud(char *buf, unsigned size_buf, struct termios *tp) | 276 | { |
277 | /* General terminal-independent stuff */ | ||
278 | G.termios.c_iflag |= IXON | IXOFF; /* 2-way flow control */ | ||
279 | G.termios.c_lflag |= ICANON | ISIG | ECHO | ECHOE | ECHOK | ECHOKE; | ||
280 | /* no longer in lflag: | ECHOCTL | ECHOPRT */ | ||
281 | G.termios.c_oflag |= OPOST; | ||
282 | /* G.termios.c_cflag = 0; */ | ||
283 | G.termios.c_cc[VINTR] = DEF_INTR; | ||
284 | G.termios.c_cc[VQUIT] = DEF_QUIT; | ||
285 | G.termios.c_cc[VEOF] = DEF_EOF; | ||
286 | G.termios.c_cc[VEOL] = DEF_EOL; | ||
287 | #ifdef VSWTC | ||
288 | G.termios.c_cc[VSWTC] = DEF_SWITCH; | ||
289 | #endif | ||
290 | #ifdef VSWTCH | ||
291 | G.termios.c_cc[VSWTCH] = DEF_SWITCH; | ||
292 | #endif | ||
293 | |||
294 | /* Account for special characters seen in input */ | ||
295 | if (G.eol == '\r') { | ||
296 | G.termios.c_iflag |= ICRNL; /* map CR in input to NL */ | ||
297 | /* already done by termios_init */ | ||
298 | /* G.termios.c_oflag |= ONLCR; map NL in output to CR-NL */ | ||
299 | } | ||
300 | G.termios.c_cc[VKILL] = DEF_KILL; | ||
301 | |||
302 | #ifdef CRTSCTS | ||
303 | /* Optionally enable hardware flow control */ | ||
304 | if (option_mask32 & F_RTSCTS) | ||
305 | G.termios.c_cflag |= CRTSCTS; | ||
306 | #endif | ||
307 | |||
308 | /* Finally, make the new settings effective */ | ||
309 | if (tcsetattr_stdin_TCSANOW(&G.termios) < 0) | ||
310 | bb_perror_msg_and_die("tcsetattr"); | ||
311 | } | ||
312 | |||
313 | /* extract baud rate from modem status message */ | ||
314 | static void auto_baud(void) | ||
307 | { | 315 | { |
308 | int speed; | ||
309 | int vmin; | ||
310 | unsigned iflag; | ||
311 | char *bp; | ||
312 | int nread; | 316 | int nread; |
313 | 317 | ||
314 | /* | 318 | /* |
@@ -327,95 +331,64 @@ static void auto_baud(char *buf, unsigned size_buf, struct termios *tp) | |||
327 | */ | 331 | */ |
328 | 332 | ||
329 | /* | 333 | /* |
330 | * Use 7-bit characters, don't block if input queue is empty. Errors will | 334 | * Don't block if input queue is empty. |
331 | * be dealt with later on. | 335 | * Errors will be dealt with later on. |
332 | */ | 336 | */ |
333 | iflag = tp->c_iflag; | 337 | G.termios.c_cc[VMIN] = 0; /* don't block if queue empty */ |
334 | tp->c_iflag |= ISTRIP; /* enable 8th-bit stripping */ | 338 | tcsetattr_stdin_TCSANOW(&G.termios); |
335 | vmin = tp->c_cc[VMIN]; | ||
336 | tp->c_cc[VMIN] = 0; /* don't block if queue empty */ | ||
337 | tcsetattr_stdin_TCSANOW(tp); | ||
338 | 339 | ||
339 | /* | 340 | /* |
340 | * Wait for a while, then read everything the modem has said so far and | 341 | * Wait for a while, then read everything the modem has said so far and |
341 | * try to extract the speed of the dial-in call. | 342 | * try to extract the speed of the dial-in call. |
342 | */ | 343 | */ |
343 | sleep(1); | 344 | sleep(1); |
344 | nread = safe_read(STDIN_FILENO, buf, size_buf - 1); | 345 | nread = safe_read(STDIN_FILENO, G.line_buf, sizeof(G.line_buf) - 1); |
345 | if (nread > 0) { | 346 | if (nread > 0) { |
346 | buf[nread] = '\0'; | 347 | int speed; |
347 | for (bp = buf; bp < buf + nread; bp++) { | 348 | char *bp; |
349 | G.line_buf[nread] = '\0'; | ||
350 | for (bp = G.line_buf; bp < G.line_buf + nread; bp++) { | ||
348 | if (isdigit(*bp)) { | 351 | if (isdigit(*bp)) { |
349 | speed = bcode(bp); | 352 | speed = bcode(bp); |
350 | if (speed > 0) | 353 | if (speed > 0) |
351 | cfsetspeed(tp, speed); | 354 | cfsetspeed(&G.termios, speed); |
352 | break; | 355 | break; |
353 | } | 356 | } |
354 | } | 357 | } |
355 | } | 358 | } |
356 | 359 | ||
357 | /* Restore terminal settings. Errors will be dealt with later on. */ | 360 | /* Restore terminal settings. Errors will be dealt with later on */ |
358 | tp->c_iflag = iflag; | 361 | G.termios.c_cc[VMIN] = 1; /* restore to value set by termios_init */ |
359 | tp->c_cc[VMIN] = vmin; | 362 | tcsetattr_stdin_TCSANOW(&G.termios); |
360 | tcsetattr_stdin_TCSANOW(tp); | ||
361 | } | 363 | } |
362 | 364 | ||
363 | /* do_prompt - show login prompt, optionally preceded by /etc/issue contents */ | 365 | /* get user name, establish parity, speed, erase, kill, eol; |
364 | static void do_prompt(struct options *op) | 366 | * return NULL on BREAK, logname on success |
365 | { | 367 | */ |
366 | #ifdef ISSUE | 368 | static char *get_logname(void) |
367 | print_login_issue(op->issue, op->tty); | ||
368 | #endif | ||
369 | print_login_prompt(); | ||
370 | } | ||
371 | |||
372 | #ifdef HANDLE_ALLCAPS | ||
373 | /* all_is_upcase - string contains upper case without lower case */ | ||
374 | /* returns 1 if true, 0 if false */ | ||
375 | static int all_is_upcase(const char *s) | ||
376 | { | ||
377 | while (*s) | ||
378 | if (islower(*s++)) | ||
379 | return 0; | ||
380 | return 1; | ||
381 | } | ||
382 | #endif | ||
383 | |||
384 | /* get_logname - get user name, establish parity, speed, erase, kill, eol; | ||
385 | * return NULL on BREAK, logname on success */ | ||
386 | static char *get_logname(char *logname, unsigned size_logname, | ||
387 | struct options *op, struct chardata *cp) | ||
388 | { | 369 | { |
389 | char *bp; | 370 | char *bp; |
390 | char c; /* input character, full eight bits */ | 371 | char c; |
391 | char ascval; /* low 7 bits of input character */ | ||
392 | int bits; /* # of "1" bits per character */ | ||
393 | int mask; /* mask with 1 bit up */ | ||
394 | static const char erase[][3] = {/* backspace-space-backspace */ | ||
395 | "\010\040\010", /* space parity */ | ||
396 | "\010\040\010", /* odd parity */ | ||
397 | "\210\240\210", /* even parity */ | ||
398 | "\010\040\010", /* 8 bit no parity */ | ||
399 | }; | ||
400 | |||
401 | /* NB: *cp is pre-initialized with init_chardata */ | ||
402 | |||
403 | /* Flush pending input (esp. after parsing or switching the baud rate). */ | ||
404 | sleep(1); | ||
405 | tcflush(0, TCIOFLUSH); | ||
406 | 372 | ||
407 | /* Prompt for and read a login name. */ | 373 | /* Flush pending input (esp. after parsing or switching the baud rate) */ |
408 | logname[0] = '\0'; | 374 | usleep(100*1000); /* 0.1 sec */ |
409 | while (!logname[0]) { | 375 | tcflush(STDIN_FILENO, TCIFLUSH); |
410 | /* Write issue file and prompt, with "parity" bit == 0. */ | ||
411 | do_prompt(op); | ||
412 | 376 | ||
413 | /* Read name, watch for break, parity, erase, kill, end-of-line. */ | 377 | /* Prompt for and read a login name */ |
414 | bp = logname; | 378 | G.line_buf[0] = '\0'; |
415 | cp->eol = '\0'; | 379 | while (!G.line_buf[0]) { |
416 | while (cp->eol == '\0') { | 380 | /* Write issue file and prompt */ |
381 | #ifdef ISSUE | ||
382 | if (!(option_mask32 & F_NOISSUE)) | ||
383 | print_login_issue(G.issue, G.tty); | ||
384 | #endif | ||
385 | print_login_prompt(); | ||
417 | 386 | ||
418 | /* Do not report trivial EINTR/EIO errors. */ | 387 | /* Read name, watch for break, parity, erase, kill, end-of-line */ |
388 | bp = G.line_buf; | ||
389 | G.eol = '\0'; | ||
390 | while (1) { | ||
391 | /* Do not report trivial EINTR/EIO errors */ | ||
419 | errno = EINTR; /* make read of 0 bytes be silent too */ | 392 | errno = EINTR; /* make read of 0 bytes be silent too */ |
420 | if (read(STDIN_FILENO, &c, 1) < 1) { | 393 | if (read(STDIN_FILENO, &c, 1) < 1) { |
421 | if (errno == EINTR || errno == EIO) | 394 | if (errno == EINTR || errno == EIO) |
@@ -425,142 +398,47 @@ static char *get_logname(char *logname, unsigned size_logname, | |||
425 | 398 | ||
426 | /* BREAK. If we have speeds to try, | 399 | /* BREAK. If we have speeds to try, |
427 | * return NULL (will switch speeds and return here) */ | 400 | * return NULL (will switch speeds and return here) */ |
428 | if (c == '\0' && op->numspeed > 1) | 401 | if (c == '\0' && G.numspeed > 1) |
429 | return NULL; | 402 | return NULL; |
430 | 403 | ||
431 | /* Do parity bit handling. */ | 404 | /* Do erase, kill and end-of-line processing */ |
432 | if (!(op->flags & F_LOCAL) && (c & 0x80)) { /* "parity" bit on? */ | 405 | switch (c) { |
433 | bits = 1; | 406 | case '\r': |
434 | mask = 1; | 407 | case '\n': |
435 | while (mask & 0x7f) { | 408 | *bp = '\0'; |
436 | if (mask & c) | 409 | G.eol = c; |
437 | bits++; /* count "1" bits */ | 410 | goto got_logname; |
438 | mask <<= 1; | ||
439 | } | ||
440 | /* ... |= 2 - even, 1 - odd */ | ||
441 | cp->parity |= 2 - (bits & 1); | ||
442 | } | ||
443 | |||
444 | /* Do erase, kill and end-of-line processing. */ | ||
445 | ascval = c & 0x7f; | ||
446 | switch (ascval) { | ||
447 | case CR: | ||
448 | case NL: | ||
449 | *bp = '\0'; /* terminate logname */ | ||
450 | cp->eol = ascval; /* set end-of-line char */ | ||
451 | break; | ||
452 | case BS: | 411 | case BS: |
453 | case DEL: | 412 | case DEL: |
454 | #ifdef ANCIENT_BS_KILL_CHARS | 413 | G.termios.c_cc[VERASE] = c; |
455 | case '#': | 414 | if (bp > G.line_buf) { |
456 | #endif | 415 | full_write(STDOUT_FILENO, "\010 \010", 3); |
457 | cp->erase = ascval; /* set erase character */ | ||
458 | if (bp > logname) { | ||
459 | full_write(STDOUT_FILENO, erase[cp->parity], 3); | ||
460 | bp--; | 416 | bp--; |
461 | } | 417 | } |
462 | break; | 418 | break; |
463 | case CTL('U'): | 419 | case CTL('U'): |
464 | #ifdef ANCIENT_BS_KILL_CHARS | 420 | while (bp > G.line_buf) { |
465 | case '@': | 421 | full_write(STDOUT_FILENO, "\010 \010", 3); |
466 | #endif | ||
467 | cp->kill = ascval; /* set kill character */ | ||
468 | while (bp > logname) { | ||
469 | full_write(STDOUT_FILENO, erase[cp->parity], 3); | ||
470 | bp--; | 422 | bp--; |
471 | } | 423 | } |
472 | break; | 424 | break; |
473 | case CTL('D'): | 425 | case CTL('D'): |
474 | exit(EXIT_SUCCESS); | 426 | exit(EXIT_SUCCESS); |
475 | default: | 427 | default: |
476 | if (ascval < ' ') { | 428 | if ((unsigned char)c < ' ') { |
477 | /* ignore garbage characters */ | 429 | /* ignore garbage characters */ |
478 | } else if ((int)(bp - logname) >= size_logname - 1) { | 430 | } else if ((int)(bp - G.line_buf) < sizeof(G.line_buf) - 1) { |
479 | bb_error_msg_and_die("input overrun"); | 431 | /* echo and store the character */ |
480 | } else { | 432 | full_write(STDOUT_FILENO, &c, 1); |
481 | full_write(STDOUT_FILENO, &c, 1); /* echo the character */ | 433 | *bp++ = c; |
482 | *bp++ = ascval; /* and store it */ | ||
483 | } | 434 | } |
484 | break; | 435 | break; |
485 | } | 436 | } |
486 | } | 437 | } /* end of get char loop */ |
487 | } | 438 | got_logname: ; |
488 | /* Handle names with upper case and no lower case. */ | 439 | } /* while logname is empty */ |
489 | |||
490 | #ifdef HANDLE_ALLCAPS | ||
491 | cp->capslock = all_is_upcase(logname); | ||
492 | if (cp->capslock) { | ||
493 | for (bp = logname; *bp; bp++) | ||
494 | if (isupper(*bp)) | ||
495 | *bp = tolower(*bp); /* map name to lower case */ | ||
496 | } | ||
497 | #endif | ||
498 | return logname; | ||
499 | } | ||
500 | |||
501 | /* termios_final - set the final tty mode bits */ | ||
502 | static void termios_final(struct options *op, struct termios *tp, struct chardata *cp) | ||
503 | { | ||
504 | /* General terminal-independent stuff. */ | ||
505 | tp->c_iflag |= IXON | IXOFF; /* 2-way flow control */ | ||
506 | tp->c_lflag |= ICANON | ISIG | ECHO | ECHOE | ECHOK | ECHOKE; | ||
507 | /* no longer| ECHOCTL | ECHOPRT */ | ||
508 | tp->c_oflag |= OPOST; | ||
509 | /* tp->c_cflag = 0; */ | ||
510 | tp->c_cc[VINTR] = DEF_INTR; /* default interrupt */ | ||
511 | tp->c_cc[VQUIT] = DEF_QUIT; /* default quit */ | ||
512 | tp->c_cc[VEOF] = DEF_EOF; /* default EOF character */ | ||
513 | tp->c_cc[VEOL] = DEF_EOL; | ||
514 | #ifdef VSWTC | ||
515 | tp->c_cc[VSWTC] = DEF_SWITCH; /* default switch character */ | ||
516 | #endif | ||
517 | |||
518 | /* Account for special characters seen in input. */ | ||
519 | if (cp->eol == CR) { | ||
520 | tp->c_iflag |= ICRNL; /* map CR in input to NL */ | ||
521 | tp->c_oflag |= ONLCR; /* map NL in output to CR-NL */ | ||
522 | } | ||
523 | tp->c_cc[VERASE] = cp->erase; /* set erase character */ | ||
524 | tp->c_cc[VKILL] = cp->kill; /* set kill character */ | ||
525 | |||
526 | /* Account for the presence or absence of parity bits in input. */ | ||
527 | switch (cp->parity) { | ||
528 | case 0: /* space (always 0) parity */ | ||
529 | // I bet most people go here - they use only 7-bit chars in usernames.... | ||
530 | break; | ||
531 | case 1: /* odd parity */ | ||
532 | tp->c_cflag |= PARODD; | ||
533 | /* FALLTHROUGH */ | ||
534 | case 2: /* even parity */ | ||
535 | tp->c_cflag |= PARENB; | ||
536 | tp->c_iflag |= INPCK | ISTRIP; | ||
537 | /* FALLTHROUGH */ | ||
538 | case (1 | 2): /* no parity bit */ | ||
539 | tp->c_cflag &= ~CSIZE; | ||
540 | tp->c_cflag |= CS7; | ||
541 | // FIXME: wtf? case 3: we saw both even and odd 8-bit bytes - | ||
542 | // it's probably some umlauts etc, but definitely NOT 7-bit!!! | ||
543 | // Entire parity detection madness here just begs for deletion... | ||
544 | break; | ||
545 | } | ||
546 | |||
547 | /* Account for upper case without lower case. */ | ||
548 | #ifdef HANDLE_ALLCAPS | ||
549 | if (cp->capslock) { | ||
550 | tp->c_iflag |= IUCLC; | ||
551 | tp->c_lflag |= XCASE; | ||
552 | tp->c_oflag |= OLCUC; | ||
553 | } | ||
554 | #endif | ||
555 | /* Optionally enable hardware flow control */ | ||
556 | #ifdef CRTSCTS | ||
557 | if (op->flags & F_RTSCTS) | ||
558 | tp->c_cflag |= CRTSCTS; | ||
559 | #endif | ||
560 | 440 | ||
561 | /* Finally, make the new settings effective */ | 441 | return G.line_buf; |
562 | if (tcsetattr_stdin_TCSANOW(tp) < 0) | ||
563 | bb_perror_msg_and_die("tcsetattr"); | ||
564 | } | 442 | } |
565 | 443 | ||
566 | int getty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 444 | int getty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
@@ -568,27 +446,17 @@ int getty_main(int argc UNUSED_PARAM, char **argv) | |||
568 | { | 446 | { |
569 | int n; | 447 | int n; |
570 | pid_t pid; | 448 | pid_t pid; |
571 | char *fakehost = NULL; /* Fake hostname for ut_host */ | 449 | char *logname; |
572 | char *logname; /* login name, given to /bin/login */ | ||
573 | /* Merging these into "struct local" may _seem_ to reduce | ||
574 | * parameter passing, but today's gcc will inline | ||
575 | * statics which are called once anyway, so don't do that */ | ||
576 | struct chardata chardata; /* set by get_logname() */ | ||
577 | struct termios termios; /* terminal mode bits */ | ||
578 | struct options options; | ||
579 | |||
580 | chardata = init_chardata; | ||
581 | 450 | ||
582 | memset(&options, 0, sizeof(options)); | 451 | INIT_G(); |
583 | options.login = _PATH_LOGIN; /* default login program */ | 452 | G.login = _PATH_LOGIN; /* default login program */ |
584 | options.tty = "tty1"; /* default tty line */ | ||
585 | options.initstring = ""; /* modem init string */ | ||
586 | #ifdef ISSUE | 453 | #ifdef ISSUE |
587 | options.issue = ISSUE; /* default issue file */ | 454 | G.issue = ISSUE; /* default issue file */ |
588 | #endif | 455 | #endif |
456 | G.eol = '\r'; | ||
589 | 457 | ||
590 | /* Parse command-line arguments. */ | 458 | /* Parse command-line arguments */ |
591 | parse_args(argv, &options, &fakehost); | 459 | parse_args(argv); |
592 | 460 | ||
593 | logmode = LOGMODE_NONE; | 461 | logmode = LOGMODE_NONE; |
594 | 462 | ||
@@ -623,7 +491,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv) | |||
623 | /* Open the tty as standard input, if it is not "-" */ | 491 | /* Open the tty as standard input, if it is not "-" */ |
624 | /* If it's not "-" and not taken yet, it will become our ctty */ | 492 | /* If it's not "-" and not taken yet, it will become our ctty */ |
625 | debug("calling open_tty\n"); | 493 | debug("calling open_tty\n"); |
626 | open_tty(options.tty); | 494 | open_tty(); |
627 | ndelay_off(0); | 495 | ndelay_off(0); |
628 | debug("duping\n"); | 496 | debug("duping\n"); |
629 | xdup2(0, 1); | 497 | xdup2(0, 1); |
@@ -637,7 +505,7 @@ int getty_main(int argc UNUSED_PARAM, char **argv) | |||
637 | * by patching the SunOS kernel variable "zsadtrlow" to a larger value; | 505 | * by patching the SunOS kernel variable "zsadtrlow" to a larger value; |
638 | * 5 seconds seems to be a good value. | 506 | * 5 seconds seems to be a good value. |
639 | */ | 507 | */ |
640 | if (tcgetattr(0, &termios) < 0) | 508 | if (tcgetattr(STDIN_FILENO, &G.termios) < 0) |
641 | bb_perror_msg_and_die("tcgetattr"); | 509 | bb_perror_msg_and_die("tcgetattr"); |
642 | 510 | ||
643 | pid = getpid(); | 511 | pid = getpid(); |
@@ -645,79 +513,75 @@ int getty_main(int argc UNUSED_PARAM, char **argv) | |||
645 | // FIXME: do we need this? Otherwise "-" case seems to be broken... | 513 | // FIXME: do we need this? Otherwise "-" case seems to be broken... |
646 | // /* Forcibly make fd 0 our controlling tty, even if another session | 514 | // /* Forcibly make fd 0 our controlling tty, even if another session |
647 | // * has it as a ctty. (Another session loses ctty). */ | 515 | // * has it as a ctty. (Another session loses ctty). */ |
648 | // ioctl(0, TIOCSCTTY, (void*)1); | 516 | // ioctl(STDIN_FILENO, TIOCSCTTY, (void*)1); |
649 | /* Make ourself a foreground process group within our session */ | 517 | /* Make ourself a foreground process group within our session */ |
650 | tcsetpgrp(0, pid); | 518 | tcsetpgrp(STDIN_FILENO, pid); |
651 | #endif | 519 | #endif |
652 | 520 | ||
653 | /* Update the utmp file. This tty is ours now! */ | 521 | /* Update the utmp file. This tty is ours now! */ |
654 | update_utmp(pid, LOGIN_PROCESS, options.tty, "LOGIN", fakehost); | 522 | update_utmp(pid, LOGIN_PROCESS, G.tty, "LOGIN", G.fakehost); |
655 | 523 | ||
656 | /* Initialize the termios settings (raw mode, eight-bit, blocking i/o). */ | 524 | /* Initialize the termios settings (raw mode, eight-bit, blocking i/o) */ |
657 | debug("calling termios_init\n"); | 525 | debug("calling termios_init\n"); |
658 | termios_init(&termios, options.speeds[0], &options); | 526 | termios_init(G.speeds[0]); |
659 | 527 | ||
660 | /* Write the modem init string and DON'T flush the buffers */ | 528 | /* Write the modem init string and DON'T flush the buffers */ |
661 | if (options.flags & F_INITSTRING) { | 529 | if (option_mask32 & F_INITSTRING) { |
662 | debug("writing init string\n"); | 530 | debug("writing init string\n"); |
663 | full_write1_str(options.initstring); | 531 | full_write1_str(G.initstring); |
664 | } | 532 | } |
665 | 533 | ||
666 | /* Optionally detect the baud rate from the modem status message */ | 534 | /* Optionally detect the baud rate from the modem status message */ |
667 | debug("before autobaud\n"); | 535 | debug("before autobaud\n"); |
668 | if (options.flags & F_PARSE) | 536 | if (option_mask32 & F_PARSE) |
669 | auto_baud(line_buf, sizeof(line_buf), &termios); | 537 | auto_baud(); |
670 | 538 | ||
671 | /* Set the optional timer */ | 539 | /* Set the optional timer */ |
672 | alarm(options.timeout); /* if 0, alarm is not set */ | 540 | alarm(G.timeout); /* if 0, alarm is not set */ |
673 | 541 | ||
674 | /* Optionally wait for CR or LF before writing /etc/issue */ | 542 | /* Optionally wait for CR or LF before writing /etc/issue */ |
675 | if (options.flags & F_WAITCRLF) { | 543 | if (option_mask32 & F_WAITCRLF) { |
676 | char ch; | 544 | char ch; |
677 | |||
678 | debug("waiting for cr-lf\n"); | 545 | debug("waiting for cr-lf\n"); |
679 | while (safe_read(STDIN_FILENO, &ch, 1) == 1) { | 546 | while (safe_read(STDIN_FILENO, &ch, 1) == 1) { |
680 | debug("read %x\n", (unsigned char)ch); | 547 | debug("read %x\n", (unsigned char)ch); |
681 | ch &= 0x7f; /* strip "parity bit" */ | ||
682 | if (ch == '\n' || ch == '\r') | 548 | if (ch == '\n' || ch == '\r') |
683 | break; | 549 | break; |
684 | } | 550 | } |
685 | } | 551 | } |
686 | 552 | ||
687 | logname = NULL; | 553 | logname = NULL; |
688 | if (!(options.flags & F_NOPROMPT)) { | 554 | if (!(option_mask32 & F_NOPROMPT)) { |
689 | /* NB:termios_init already set line speed | 555 | /* NB: termios_init already set line speed |
690 | * to options.speeds[0] */ | 556 | * to G.speeds[0] */ |
691 | int baud_index = 0; | 557 | int baud_index = 0; |
692 | 558 | ||
693 | while (1) { | 559 | while (1) { |
694 | /* Read the login name. */ | 560 | /* Read the login name */ |
695 | debug("reading login name\n"); | 561 | debug("reading login name\n"); |
696 | logname = get_logname(line_buf, sizeof(line_buf), | 562 | logname = get_logname(); |
697 | &options, &chardata); | ||
698 | if (logname) | 563 | if (logname) |
699 | break; | 564 | break; |
700 | /* we are here only if options.numspeed > 1 */ | 565 | /* We are here only if G.numspeed > 1 */ |
701 | baud_index = (baud_index + 1) % options.numspeed; | 566 | baud_index = (baud_index + 1) % G.numspeed; |
702 | cfsetispeed(&termios, options.speeds[baud_index]); | 567 | cfsetspeed(&G.termios, G.speeds[baud_index]); |
703 | cfsetospeed(&termios, options.speeds[baud_index]); | 568 | tcsetattr_stdin_TCSANOW(&G.termios); |
704 | tcsetattr_stdin_TCSANOW(&termios); | ||
705 | } | 569 | } |
706 | } | 570 | } |
707 | 571 | ||
708 | /* Disable timer. */ | 572 | /* Disable timer */ |
709 | alarm(0); | 573 | alarm(0); |
710 | 574 | ||
711 | /* Finalize the termios settings. */ | 575 | /* Finalize the termios settings */ |
712 | termios_final(&options, &termios, &chardata); | 576 | termios_final(); |
713 | 577 | ||
714 | /* Now the newline character should be properly written. */ | 578 | /* Now the newline character should be properly written */ |
715 | full_write(STDOUT_FILENO, "\n", 1); | 579 | full_write(STDOUT_FILENO, "\n", 1); |
716 | 580 | ||
717 | /* Let the login program take care of password validation. */ | 581 | /* Let the login program take care of password validation */ |
718 | /* We use PATH because we trust that root doesn't set "bad" PATH, | 582 | /* We use PATH because we trust that root doesn't set "bad" PATH, |
719 | * and getty is not suid-root applet. */ | 583 | * and getty is not suid-root applet */ |
720 | /* With -n, logname == NULL, and login will ask for username instead */ | 584 | /* With -n, logname == NULL, and login will ask for username instead */ |
721 | BB_EXECLP(options.login, options.login, "--", logname, NULL); | 585 | BB_EXECLP(G.login, G.login, "--", logname, NULL); |
722 | bb_error_msg_and_die("can't execute '%s'", options.login); | 586 | bb_error_msg_and_die("can't execute '%s'", G.login); |
723 | } | 587 | } |
diff --git a/loginutils/login.c b/loginutils/login.c index c285b45a1..952b3aadd 100644 --- a/loginutils/login.c +++ b/loginutils/login.c | |||
@@ -4,9 +4,6 @@ | |||
4 | */ | 4 | */ |
5 | #include "libbb.h" | 5 | #include "libbb.h" |
6 | #include <syslog.h> | 6 | #include <syslog.h> |
7 | #if ENABLE_FEATURE_UTMP | ||
8 | # include <utmp.h> /* USER_PROCESS */ | ||
9 | #endif | ||
10 | #include <sys/resource.h> | 7 | #include <sys/resource.h> |
11 | 8 | ||
12 | #if ENABLE_SELINUX | 9 | #if ENABLE_SELINUX |
diff --git a/miscutils/Config.src b/miscutils/Config.src index 4912daf88..da52e14c6 100644 --- a/miscutils/Config.src +++ b/miscutils/Config.src | |||
@@ -170,7 +170,6 @@ config FEATURE_CROND_DIR | |||
170 | config CRONTAB | 170 | config CRONTAB |
171 | bool "crontab" | 171 | bool "crontab" |
172 | default y | 172 | default y |
173 | select FEATURE_SUID | ||
174 | help | 173 | help |
175 | Crontab manipulates the crontab for a particular user. Only | 174 | Crontab manipulates the crontab for a particular user. Only |
176 | the superuser may specify a different user and/or crontab directory. | 175 | the superuser may specify a different user and/or crontab directory. |
diff --git a/miscutils/conspy.c b/miscutils/conspy.c index 723b4208a..721eb6d59 100644 --- a/miscutils/conspy.c +++ b/miscutils/conspy.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 10 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | //applet:IF_CONSPY(APPLET(conspy, _BB_DIR_BIN, _BB_SUID_DROP)) | 13 | //applet:IF_CONSPY(APPLET(conspy, BB_DIR_BIN, BB_SUID_DROP)) |
14 | 14 | ||
15 | //kbuild:lib-$(CONFIG_CONSPY) += conspy.o | 15 | //kbuild:lib-$(CONFIG_CONSPY) += conspy.o |
16 | 16 | ||
diff --git a/miscutils/last.c b/miscutils/last.c index fec5b70a8..12457b157 100644 --- a/miscutils/last.c +++ b/miscutils/last.c | |||
@@ -8,7 +8,6 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include "libbb.h" | 10 | #include "libbb.h" |
11 | #include <utmp.h> | ||
12 | 11 | ||
13 | /* NB: ut_name and ut_user are the same field, use only one name (ut_user) | 12 | /* NB: ut_name and ut_user are the same field, use only one name (ut_user) |
14 | * to reduce confusion */ | 13 | * to reduce confusion */ |
diff --git a/miscutils/last_fancy.c b/miscutils/last_fancy.c index 7e69fc281..7e61b7691 100644 --- a/miscutils/last_fancy.c +++ b/miscutils/last_fancy.c | |||
@@ -8,7 +8,6 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include "libbb.h" | 10 | #include "libbb.h" |
11 | #include <utmp.h> | ||
12 | 11 | ||
13 | /* NB: ut_name and ut_user are the same field, use only one name (ut_user) | 12 | /* NB: ut_name and ut_user are the same field, use only one name (ut_user) |
14 | * to reduce confusion */ | 13 | * to reduce confusion */ |
diff --git a/miscutils/nandwrite.c b/miscutils/nandwrite.c index 831d2f76b..c5e2fb841 100644 --- a/miscutils/nandwrite.c +++ b/miscutils/nandwrite.c | |||
@@ -8,8 +8,8 @@ | |||
8 | * TODO: add support for large (>4GB) MTD devices | 8 | * TODO: add support for large (>4GB) MTD devices |
9 | */ | 9 | */ |
10 | 10 | ||
11 | //applet:IF_NANDWRITE(APPLET(nandwrite, _BB_DIR_USR_SBIN, _BB_SUID_DROP)) | 11 | //applet:IF_NANDWRITE(APPLET(nandwrite, BB_DIR_USR_SBIN, BB_SUID_DROP)) |
12 | //applet:IF_NANDWRITE(APPLET_ODDNAME(nanddump, nandwrite, _BB_DIR_USR_SBIN, _BB_SUID_DROP, nanddump)) | 12 | //applet:IF_NANDWRITE(APPLET_ODDNAME(nanddump, nandwrite, BB_DIR_USR_SBIN, BB_SUID_DROP, nanddump)) |
13 | 13 | ||
14 | //kbuild:lib-$(CONFIG_NANDWRITE) += nandwrite.o | 14 | //kbuild:lib-$(CONFIG_NANDWRITE) += nandwrite.o |
15 | //kbuild:lib-$(CONFIG_NANDDUMP) += nandwrite.o | 15 | //kbuild:lib-$(CONFIG_NANDDUMP) += nandwrite.o |
diff --git a/miscutils/runlevel.c b/miscutils/runlevel.c index 363e45049..7024361e7 100644 --- a/miscutils/runlevel.c +++ b/miscutils/runlevel.c | |||
@@ -12,7 +12,6 @@ | |||
12 | * initially busyboxified by Bernhard Reutner-Fischer | 12 | * initially busyboxified by Bernhard Reutner-Fischer |
13 | */ | 13 | */ |
14 | #include "libbb.h" | 14 | #include "libbb.h" |
15 | #include <utmp.h> | ||
16 | 15 | ||
17 | int runlevel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 16 | int runlevel_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
18 | int runlevel_main(int argc UNUSED_PARAM, char **argv) | 17 | int runlevel_main(int argc UNUSED_PARAM, char **argv) |
diff --git a/miscutils/ubi_attach_detach.c b/miscutils/ubi_attach_detach.c index b74d97b68..aa8a5171a 100644 --- a/miscutils/ubi_attach_detach.c +++ b/miscutils/ubi_attach_detach.c | |||
@@ -3,8 +3,8 @@ | |||
3 | * Licensed under GPLv2, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2, see file LICENSE in this source tree. |
4 | */ | 4 | */ |
5 | 5 | ||
6 | //applet:IF_UBIATTACH(APPLET_ODDNAME(ubiattach, ubi_attach_detach, _BB_DIR_USR_SBIN, _BB_SUID_DROP, ubiattach)) | 6 | //applet:IF_UBIATTACH(APPLET_ODDNAME(ubiattach, ubi_attach_detach, BB_DIR_USR_SBIN, BB_SUID_DROP, ubiattach)) |
7 | //applet:IF_UBIDETACH(APPLET_ODDNAME(ubidetach, ubi_attach_detach, _BB_DIR_USR_SBIN, _BB_SUID_DROP, ubidetach)) | 7 | //applet:IF_UBIDETACH(APPLET_ODDNAME(ubidetach, ubi_attach_detach, BB_DIR_USR_SBIN, BB_SUID_DROP, ubidetach)) |
8 | 8 | ||
9 | //kbuild:lib-$(CONFIG_UBIATTACH) += ubi_attach_detach.o | 9 | //kbuild:lib-$(CONFIG_UBIATTACH) += ubi_attach_detach.o |
10 | //kbuild:lib-$(CONFIG_UBIDETACH) += ubi_attach_detach.o | 10 | //kbuild:lib-$(CONFIG_UBIDETACH) += ubi_attach_detach.o |
diff --git a/miscutils/wall.c b/miscutils/wall.c index eecfc166b..0a2b89e5e 100644 --- a/miscutils/wall.c +++ b/miscutils/wall.c | |||
@@ -7,7 +7,6 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "libbb.h" | 9 | #include "libbb.h" |
10 | #include <utmp.h> | ||
11 | 10 | ||
12 | int wall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 11 | int wall_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
13 | int wall_main(int argc UNUSED_PARAM, char **argv) | 12 | int wall_main(int argc UNUSED_PARAM, char **argv) |
diff --git a/modutils/depmod.c b/modutils/depmod.c index 85b64a229..f6c0bf33a 100644 --- a/modutils/depmod.c +++ b/modutils/depmod.c | |||
@@ -8,7 +8,7 @@ | |||
8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | //applet:IF_DEPMOD(APPLET(depmod, _BB_DIR_SBIN, _BB_SUID_DROP)) | 11 | //applet:IF_DEPMOD(APPLET(depmod, BB_DIR_SBIN, BB_SUID_DROP)) |
12 | 12 | ||
13 | //usage:#if !ENABLE_MODPROBE_SMALL | 13 | //usage:#if !ENABLE_MODPROBE_SMALL |
14 | //usage:#define depmod_trivial_usage NOUSAGE_STR | 14 | //usage:#define depmod_trivial_usage NOUSAGE_STR |
diff --git a/modutils/insmod.c b/modutils/insmod.c index 7ec3cae47..e5b46f402 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | //applet:IF_INSMOD(APPLET(insmod, _BB_DIR_SBIN, _BB_SUID_DROP)) | 10 | //applet:IF_INSMOD(APPLET(insmod, BB_DIR_SBIN, BB_SUID_DROP)) |
11 | 11 | ||
12 | #include "libbb.h" | 12 | #include "libbb.h" |
13 | #include "modutils.h" | 13 | #include "modutils.h" |
diff --git a/modutils/lsmod.c b/modutils/lsmod.c index ab7c11f2a..3b3c166b9 100644 --- a/modutils/lsmod.c +++ b/modutils/lsmod.c | |||
@@ -8,7 +8,7 @@ | |||
8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | //applet:IF_LSMOD(APPLET(lsmod, _BB_DIR_SBIN, _BB_SUID_DROP)) | 11 | //applet:IF_LSMOD(APPLET(lsmod, BB_DIR_SBIN, BB_SUID_DROP)) |
12 | 12 | ||
13 | //usage:#if !ENABLE_MODPROBE_SMALL | 13 | //usage:#if !ENABLE_MODPROBE_SMALL |
14 | //usage:#define lsmod_trivial_usage | 14 | //usage:#define lsmod_trivial_usage |
@@ -87,7 +87,8 @@ int lsmod_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
87 | // N.B. token[3] is either '-' (module is not used by others) | 87 | // N.B. token[3] is either '-' (module is not used by others) |
88 | // or comma-separated list ended by comma | 88 | // or comma-separated list ended by comma |
89 | // so trimming the trailing char is just what we need! | 89 | // so trimming the trailing char is just what we need! |
90 | token[3][strlen(token[3])-1] = '\0'; | 90 | if (token[3][0]) |
91 | token[3][strlen(token[3]) - 1] = '\0'; | ||
91 | # if ENABLE_UNICODE_SUPPORT | 92 | # if ENABLE_UNICODE_SUPPORT |
92 | { | 93 | { |
93 | uni_stat_t uni_stat; | 94 | uni_stat_t uni_stat; |
diff --git a/modutils/modinfo.c b/modutils/modinfo.c index 37ba77edf..731fc0553 100644 --- a/modutils/modinfo.c +++ b/modutils/modinfo.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 6 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | //applet:IF_MODINFO(APPLET(modinfo, _BB_DIR_SBIN, _BB_SUID_DROP)) | 9 | //applet:IF_MODINFO(APPLET(modinfo, BB_DIR_SBIN, BB_SUID_DROP)) |
10 | 10 | ||
11 | //kbuild:lib-$(CONFIG_MODINFO) += modinfo.o modutils.o | 11 | //kbuild:lib-$(CONFIG_MODINFO) += modinfo.o modutils.o |
12 | 12 | ||
diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c index ec3ddfb8f..2a69eb513 100644 --- a/modutils/modprobe-small.c +++ b/modutils/modprobe-small.c | |||
@@ -8,11 +8,11 @@ | |||
8 | * Licensed under GPLv2, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2, see file LICENSE in this source tree. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | //applet:IF_MODPROBE_SMALL(APPLET(modprobe, _BB_DIR_SBIN, _BB_SUID_DROP)) | 11 | //applet:IF_MODPROBE_SMALL(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP)) |
12 | //applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(depmod, modprobe, _BB_DIR_SBIN, _BB_SUID_DROP, modprobe)) | 12 | //applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(depmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, modprobe)) |
13 | //applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(insmod, modprobe, _BB_DIR_SBIN, _BB_SUID_DROP, modprobe)) | 13 | //applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(insmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, modprobe)) |
14 | //applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(lsmod, modprobe, _BB_DIR_SBIN, _BB_SUID_DROP, modprobe)) | 14 | //applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(lsmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, modprobe)) |
15 | //applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(rmmod, modprobe, _BB_DIR_SBIN, _BB_SUID_DROP, modprobe)) | 15 | //applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(rmmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, modprobe)) |
16 | 16 | ||
17 | #include "libbb.h" | 17 | #include "libbb.h" |
18 | /* After libbb.h, since it needs sys/types.h on some systems */ | 18 | /* After libbb.h, since it needs sys/types.h on some systems */ |
@@ -205,6 +205,7 @@ static void parse_module(module_info *info, const char *pathname) | |||
205 | /* Read (possibly compressed) module */ | 205 | /* Read (possibly compressed) module */ |
206 | len = 64 * 1024 * 1024; /* 64 Mb at most */ | 206 | len = 64 * 1024 * 1024; /* 64 Mb at most */ |
207 | module_image = xmalloc_open_zipped_read_close(pathname, &len); | 207 | module_image = xmalloc_open_zipped_read_close(pathname, &len); |
208 | /* module_image == NULL is ok here, find_keyword handles it */ | ||
208 | //TODO: optimize redundant module body reads | 209 | //TODO: optimize redundant module body reads |
209 | 210 | ||
210 | /* "alias1 symbol:sym1 alias2 symbol:sym2" */ | 211 | /* "alias1 symbol:sym1 alias2 symbol:sym2" */ |
@@ -844,13 +845,17 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv) | |||
844 | void *map; | 845 | void *map; |
845 | 846 | ||
846 | len = MAXINT(ssize_t); | 847 | len = MAXINT(ssize_t); |
847 | map = xmalloc_xopen_read_close(*argv, &len); | 848 | map = xmalloc_open_zipped_read_close(*argv, &len); |
849 | if (!map) | ||
850 | bb_perror_msg_and_die("can't read '%s'", *argv); | ||
848 | if (init_module(map, len, | 851 | if (init_module(map, len, |
849 | IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(options ? options : "") | 852 | IF_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE(options ? options : "") |
850 | IF_NOT_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE("") | 853 | IF_NOT_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE("") |
851 | ) != 0) | 854 | ) != 0 |
855 | ) { | ||
852 | bb_error_msg_and_die("can't insert '%s': %s", | 856 | bb_error_msg_and_die("can't insert '%s': %s", |
853 | *argv, moderror(errno)); | 857 | *argv, moderror(errno)); |
858 | } | ||
854 | return 0; | 859 | return 0; |
855 | } | 860 | } |
856 | 861 | ||
diff --git a/modutils/modprobe.c b/modutils/modprobe.c index 73df39c6c..e3bacac56 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c | |||
@@ -8,7 +8,7 @@ | |||
8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | //applet:IF_MODPROBE(APPLET(modprobe, _BB_DIR_SBIN, _BB_SUID_DROP)) | 11 | //applet:IF_MODPROBE(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP)) |
12 | 12 | ||
13 | #include "libbb.h" | 13 | #include "libbb.h" |
14 | #include "modutils.h" | 14 | #include "modutils.h" |
diff --git a/modutils/rmmod.c b/modutils/rmmod.c index 2486511d7..65a4911cd 100644 --- a/modutils/rmmod.c +++ b/modutils/rmmod.c | |||
@@ -8,7 +8,7 @@ | |||
8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | //applet:IF_RMMOD(APPLET(rmmod, _BB_DIR_SBIN, _BB_SUID_DROP)) | 11 | //applet:IF_RMMOD(APPLET(rmmod, BB_DIR_SBIN, BB_SUID_DROP)) |
12 | 12 | ||
13 | //usage:#if !ENABLE_MODPROBE_SMALL | 13 | //usage:#if !ENABLE_MODPROBE_SMALL |
14 | //usage:#define rmmod_trivial_usage | 14 | //usage:#define rmmod_trivial_usage |
diff --git a/networking/httpd.c b/networking/httpd.c index fa42d9850..b8113a843 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -1522,6 +1522,7 @@ static NOINLINE void send_file_and_exit(const char *url, int what) | |||
1522 | struct stat sb; | 1522 | struct stat sb; |
1523 | fstat(fd, &sb); | 1523 | fstat(fd, &sb); |
1524 | file_size = sb.st_size; | 1524 | file_size = sb.st_size; |
1525 | last_mod = sb.st_mtime; | ||
1525 | } else { | 1526 | } else { |
1526 | IF_FEATURE_HTTPD_GZIP(content_gzip = 0;) | 1527 | IF_FEATURE_HTTPD_GZIP(content_gzip = 0;) |
1527 | fd = open(url, O_RDONLY); | 1528 | fd = open(url, O_RDONLY); |
diff --git a/networking/ifplugd.c b/networking/ifplugd.c index 58f56dbf1..8dd0a5bd8 100644 --- a/networking/ifplugd.c +++ b/networking/ifplugd.c | |||
@@ -131,18 +131,21 @@ static int network_ioctl(int request, void* data, const char *errmsg) | |||
131 | 131 | ||
132 | static smallint detect_link_mii(void) | 132 | static smallint detect_link_mii(void) |
133 | { | 133 | { |
134 | struct ifreq ifreq; | 134 | /* char buffer instead of bona-fide struct avoids aliasing warning */ |
135 | struct mii_ioctl_data *mii = (void *)&ifreq.ifr_data; | 135 | char buf[sizeof(struct ifreq)]; |
136 | struct ifreq *const ifreq = (void *)buf; | ||
136 | 137 | ||
137 | set_ifreq_to_ifname(&ifreq); | 138 | struct mii_ioctl_data *mii = (void *)&ifreq->ifr_data; |
139 | |||
140 | set_ifreq_to_ifname(ifreq); | ||
138 | 141 | ||
139 | if (network_ioctl(SIOCGMIIPHY, &ifreq, "SIOCGMIIPHY") < 0) { | 142 | if (network_ioctl(SIOCGMIIPHY, ifreq, "SIOCGMIIPHY") < 0) { |
140 | return IFSTATUS_ERR; | 143 | return IFSTATUS_ERR; |
141 | } | 144 | } |
142 | 145 | ||
143 | mii->reg_num = 1; | 146 | mii->reg_num = 1; |
144 | 147 | ||
145 | if (network_ioctl(SIOCGMIIREG, &ifreq, "SIOCGMIIREG") < 0) { | 148 | if (network_ioctl(SIOCGMIIREG, ifreq, "SIOCGMIIREG") < 0) { |
146 | return IFSTATUS_ERR; | 149 | return IFSTATUS_ERR; |
147 | } | 150 | } |
148 | 151 | ||
@@ -151,18 +154,21 @@ static smallint detect_link_mii(void) | |||
151 | 154 | ||
152 | static smallint detect_link_priv(void) | 155 | static smallint detect_link_priv(void) |
153 | { | 156 | { |
154 | struct ifreq ifreq; | 157 | /* char buffer instead of bona-fide struct avoids aliasing warning */ |
155 | struct mii_ioctl_data *mii = (void *)&ifreq.ifr_data; | 158 | char buf[sizeof(struct ifreq)]; |
159 | struct ifreq *const ifreq = (void *)buf; | ||
156 | 160 | ||
157 | set_ifreq_to_ifname(&ifreq); | 161 | struct mii_ioctl_data *mii = (void *)&ifreq->ifr_data; |
162 | |||
163 | set_ifreq_to_ifname(ifreq); | ||
158 | 164 | ||
159 | if (network_ioctl(SIOCDEVPRIVATE, &ifreq, "SIOCDEVPRIVATE") < 0) { | 165 | if (network_ioctl(SIOCDEVPRIVATE, ifreq, "SIOCDEVPRIVATE") < 0) { |
160 | return IFSTATUS_ERR; | 166 | return IFSTATUS_ERR; |
161 | } | 167 | } |
162 | 168 | ||
163 | mii->reg_num = 1; | 169 | mii->reg_num = 1; |
164 | 170 | ||
165 | if (network_ioctl(SIOCDEVPRIVATE+1, &ifreq, "SIOCDEVPRIVATE+1") < 0) { | 171 | if (network_ioctl(SIOCDEVPRIVATE+1, ifreq, "SIOCDEVPRIVATE+1") < 0) { |
166 | return IFSTATUS_ERR; | 172 | return IFSTATUS_ERR; |
167 | } | 173 | } |
168 | 174 | ||
diff --git a/networking/nbd-client.c b/networking/nbd-client.c index 8b856eda7..cadda5261 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_ODDNAME(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 | ||
diff --git a/networking/ping.c b/networking/ping.c index 366a98668..11ce24eb5 100644 --- a/networking/ping.c +++ b/networking/ping.c | |||
@@ -52,9 +52,9 @@ | |||
52 | //config: Make the output from the ping applet include statistics, and at the | 52 | //config: Make the output from the ping applet include statistics, and at the |
53 | //config: same time provide full support for ICMP packets. | 53 | //config: same time provide full support for ICMP packets. |
54 | 54 | ||
55 | /* Needs socket(AF_INET, SOCK_RAW, IPPROTO_ICMP), therefore _BB_SUID_MAYBE: */ | 55 | /* Needs socket(AF_INET, SOCK_RAW, IPPROTO_ICMP), therefore BB_SUID_MAYBE: */ |
56 | //applet:IF_PING(APPLET(ping, _BB_DIR_BIN, _BB_SUID_MAYBE)) | 56 | //applet:IF_PING(APPLET(ping, BB_DIR_BIN, BB_SUID_MAYBE)) |
57 | //applet:IF_PING6(APPLET(ping6, _BB_DIR_BIN, _BB_SUID_MAYBE)) | 57 | //applet:IF_PING6(APPLET(ping6, BB_DIR_BIN, BB_SUID_MAYBE)) |
58 | 58 | ||
59 | //kbuild:lib-$(CONFIG_PING) += ping.o | 59 | //kbuild:lib-$(CONFIG_PING) += ping.o |
60 | //kbuild:lib-$(CONFIG_PING6) += ping.o | 60 | //kbuild:lib-$(CONFIG_PING6) += ping.o |
diff --git a/networking/route.c b/networking/route.c index 98567aaee..b7d08dd63 100644 --- a/networking/route.c +++ b/networking/route.c | |||
@@ -153,7 +153,10 @@ static int kw_lookup(const char *kwtbl, char ***pargs) | |||
153 | 153 | ||
154 | static NOINLINE void INET_setroute(int action, char **args) | 154 | static NOINLINE void INET_setroute(int action, char **args) |
155 | { | 155 | { |
156 | struct rtentry rt; | 156 | /* char buffer instead of bona-fide struct avoids aliasing warning */ |
157 | char rt_buf[sizeof(struct rtentry)]; | ||
158 | struct rtentry *const rt = (void *)rt_buf; | ||
159 | |||
157 | const char *netmask = NULL; | 160 | const char *netmask = NULL; |
158 | int skfd, isnet, xflag; | 161 | int skfd, isnet, xflag; |
159 | 162 | ||
@@ -166,7 +169,7 @@ static NOINLINE void INET_setroute(int action, char **args) | |||
166 | } | 169 | } |
167 | 170 | ||
168 | /* Clean out the RTREQ structure. */ | 171 | /* Clean out the RTREQ structure. */ |
169 | memset(&rt, 0, sizeof(rt)); | 172 | memset(rt, 0, sizeof(*rt)); |
170 | 173 | ||
171 | { | 174 | { |
172 | const char *target = *args++; | 175 | const char *target = *args++; |
@@ -178,17 +181,17 @@ static NOINLINE void INET_setroute(int action, char **args) | |||
178 | int prefix_len; | 181 | int prefix_len; |
179 | 182 | ||
180 | prefix_len = xatoul_range(prefix+1, 0, 32); | 183 | prefix_len = xatoul_range(prefix+1, 0, 32); |
181 | mask_in_addr(rt) = htonl( ~(0xffffffffUL >> prefix_len)); | 184 | mask_in_addr(*rt) = htonl( ~(0xffffffffUL >> prefix_len)); |
182 | *prefix = '\0'; | 185 | *prefix = '\0'; |
183 | #if HAVE_NEW_ADDRT | 186 | #if HAVE_NEW_ADDRT |
184 | rt.rt_genmask.sa_family = AF_INET; | 187 | rt->rt_genmask.sa_family = AF_INET; |
185 | #endif | 188 | #endif |
186 | } else { | 189 | } else { |
187 | /* Default netmask. */ | 190 | /* Default netmask. */ |
188 | netmask = "default"; | 191 | netmask = "default"; |
189 | } | 192 | } |
190 | /* Prefer hostname lookup is -host flag (xflag==1) was given. */ | 193 | /* Prefer hostname lookup is -host flag (xflag==1) was given. */ |
191 | isnet = INET_resolve(target, (struct sockaddr_in *) &rt.rt_dst, | 194 | isnet = INET_resolve(target, (struct sockaddr_in *) &rt->rt_dst, |
192 | (xflag & HOST_FLAG)); | 195 | (xflag & HOST_FLAG)); |
193 | if (isnet < 0) { | 196 | if (isnet < 0) { |
194 | bb_error_msg_and_die("resolving %s", target); | 197 | bb_error_msg_and_die("resolving %s", target); |
@@ -204,20 +207,20 @@ static NOINLINE void INET_setroute(int action, char **args) | |||
204 | } | 207 | } |
205 | 208 | ||
206 | /* Fill in the other fields. */ | 209 | /* Fill in the other fields. */ |
207 | rt.rt_flags = ((isnet) ? RTF_UP : (RTF_UP | RTF_HOST)); | 210 | rt->rt_flags = ((isnet) ? RTF_UP : (RTF_UP | RTF_HOST)); |
208 | 211 | ||
209 | while (*args) { | 212 | while (*args) { |
210 | int k = kw_lookup(tbl_ipvx, &args); | 213 | int k = kw_lookup(tbl_ipvx, &args); |
211 | const char *args_m1 = args[-1]; | 214 | const char *args_m1 = args[-1]; |
212 | 215 | ||
213 | if (k & KW_IPVx_FLAG_ONLY) { | 216 | if (k & KW_IPVx_FLAG_ONLY) { |
214 | rt.rt_flags |= flags_ipvx[k & 3]; | 217 | rt->rt_flags |= flags_ipvx[k & 3]; |
215 | continue; | 218 | continue; |
216 | } | 219 | } |
217 | 220 | ||
218 | #if HAVE_NEW_ADDRT | 221 | #if HAVE_NEW_ADDRT |
219 | if (k == KW_IPVx_METRIC) { | 222 | if (k == KW_IPVx_METRIC) { |
220 | rt.rt_metric = xatoul(args_m1) + 1; | 223 | rt->rt_metric = xatoul(args_m1) + 1; |
221 | continue; | 224 | continue; |
222 | } | 225 | } |
223 | #endif | 226 | #endif |
@@ -225,7 +228,7 @@ static NOINLINE void INET_setroute(int action, char **args) | |||
225 | if (k == KW_IPVx_NETMASK) { | 228 | if (k == KW_IPVx_NETMASK) { |
226 | struct sockaddr mask; | 229 | struct sockaddr mask; |
227 | 230 | ||
228 | if (mask_in_addr(rt)) { | 231 | if (mask_in_addr(*rt)) { |
229 | bb_show_usage(); | 232 | bb_show_usage(); |
230 | } | 233 | } |
231 | 234 | ||
@@ -234,18 +237,18 @@ static NOINLINE void INET_setroute(int action, char **args) | |||
234 | if (isnet < 0) { | 237 | if (isnet < 0) { |
235 | bb_error_msg_and_die("resolving %s", netmask); | 238 | bb_error_msg_and_die("resolving %s", netmask); |
236 | } | 239 | } |
237 | rt.rt_genmask = full_mask(mask); | 240 | rt->rt_genmask = full_mask(mask); |
238 | continue; | 241 | continue; |
239 | } | 242 | } |
240 | 243 | ||
241 | if (k == KW_IPVx_GATEWAY) { | 244 | if (k == KW_IPVx_GATEWAY) { |
242 | if (rt.rt_flags & RTF_GATEWAY) { | 245 | if (rt->rt_flags & RTF_GATEWAY) { |
243 | bb_show_usage(); | 246 | bb_show_usage(); |
244 | } | 247 | } |
245 | 248 | ||
246 | isnet = INET_resolve(args_m1, | 249 | isnet = INET_resolve(args_m1, |
247 | (struct sockaddr_in *) &rt.rt_gateway, 1); | 250 | (struct sockaddr_in *) &rt->rt_gateway, 1); |
248 | rt.rt_flags |= RTF_GATEWAY; | 251 | rt->rt_flags |= RTF_GATEWAY; |
249 | 252 | ||
250 | if (isnet) { | 253 | if (isnet) { |
251 | if (isnet < 0) { | 254 | if (isnet < 0) { |
@@ -257,24 +260,24 @@ static NOINLINE void INET_setroute(int action, char **args) | |||
257 | } | 260 | } |
258 | 261 | ||
259 | if (k == KW_IPVx_MSS) { /* Check valid MSS bounds. */ | 262 | if (k == KW_IPVx_MSS) { /* Check valid MSS bounds. */ |
260 | rt.rt_flags |= RTF_MSS; | 263 | rt->rt_flags |= RTF_MSS; |
261 | rt.rt_mss = xatoul_range(args_m1, 64, 32768); | 264 | rt->rt_mss = xatoul_range(args_m1, 64, 32768); |
262 | continue; | 265 | continue; |
263 | } | 266 | } |
264 | 267 | ||
265 | if (k == KW_IPVx_WINDOW) { /* Check valid window bounds. */ | 268 | if (k == KW_IPVx_WINDOW) { /* Check valid window bounds. */ |
266 | rt.rt_flags |= RTF_WINDOW; | 269 | rt->rt_flags |= RTF_WINDOW; |
267 | rt.rt_window = xatoul_range(args_m1, 128, INT_MAX); | 270 | rt->rt_window = xatoul_range(args_m1, 128, INT_MAX); |
268 | continue; | 271 | continue; |
269 | } | 272 | } |
270 | 273 | ||
271 | #ifdef RTF_IRTT | 274 | #ifdef RTF_IRTT |
272 | if (k == KW_IPVx_IRTT) { | 275 | if (k == KW_IPVx_IRTT) { |
273 | rt.rt_flags |= RTF_IRTT; | 276 | rt->rt_flags |= RTF_IRTT; |
274 | rt.rt_irtt = xatoul(args_m1); | 277 | rt->rt_irtt = xatoul(args_m1); |
275 | rt.rt_irtt *= (sysconf(_SC_CLK_TCK) / 100); /* FIXME */ | 278 | rt->rt_irtt *= (sysconf(_SC_CLK_TCK) / 100); /* FIXME */ |
276 | #if 0 /* FIXME: do we need to check anything of this? */ | 279 | #if 0 /* FIXME: do we need to check anything of this? */ |
277 | if (rt.rt_irtt < 1 || rt.rt_irtt > (120 * HZ)) { | 280 | if (rt->rt_irtt < 1 || rt->rt_irtt > (120 * HZ)) { |
278 | bb_error_msg_and_die("bad irtt"); | 281 | bb_error_msg_and_die("bad irtt"); |
279 | } | 282 | } |
280 | #endif | 283 | #endif |
@@ -284,9 +287,9 @@ static NOINLINE void INET_setroute(int action, char **args) | |||
284 | 287 | ||
285 | /* Device is special in that it can be the last arg specified | 288 | /* Device is special in that it can be the last arg specified |
286 | * and doesn't requre the dev/device keyword in that case. */ | 289 | * and doesn't requre the dev/device keyword in that case. */ |
287 | if (!rt.rt_dev && ((k == KW_IPVx_DEVICE) || (!k && !*++args))) { | 290 | if (!rt->rt_dev && ((k == KW_IPVx_DEVICE) || (!k && !*++args))) { |
288 | /* Don't use args_m1 here since args may have changed! */ | 291 | /* Don't use args_m1 here since args may have changed! */ |
289 | rt.rt_dev = args[-1]; | 292 | rt->rt_dev = args[-1]; |
290 | continue; | 293 | continue; |
291 | } | 294 | } |
292 | 295 | ||
@@ -295,41 +298,41 @@ static NOINLINE void INET_setroute(int action, char **args) | |||
295 | } | 298 | } |
296 | 299 | ||
297 | #ifdef RTF_REJECT | 300 | #ifdef RTF_REJECT |
298 | if ((rt.rt_flags & RTF_REJECT) && !rt.rt_dev) { | 301 | if ((rt->rt_flags & RTF_REJECT) && !rt->rt_dev) { |
299 | rt.rt_dev = (char*)"lo"; | 302 | rt->rt_dev = (char*)"lo"; |
300 | } | 303 | } |
301 | #endif | 304 | #endif |
302 | 305 | ||
303 | /* sanity checks.. */ | 306 | /* sanity checks.. */ |
304 | if (mask_in_addr(rt)) { | 307 | if (mask_in_addr(*rt)) { |
305 | uint32_t mask = mask_in_addr(rt); | 308 | uint32_t mask = mask_in_addr(*rt); |
306 | 309 | ||
307 | mask = ~ntohl(mask); | 310 | mask = ~ntohl(mask); |
308 | if ((rt.rt_flags & RTF_HOST) && mask != 0xffffffff) { | 311 | if ((rt->rt_flags & RTF_HOST) && mask != 0xffffffff) { |
309 | bb_error_msg_and_die("netmask %.8x and host route conflict", | 312 | bb_error_msg_and_die("netmask %.8x and host route conflict", |
310 | (unsigned int) mask); | 313 | (unsigned int) mask); |
311 | } | 314 | } |
312 | if (mask & (mask + 1)) { | 315 | if (mask & (mask + 1)) { |
313 | bb_error_msg_and_die("bogus netmask %s", netmask); | 316 | bb_error_msg_and_die("bogus netmask %s", netmask); |
314 | } | 317 | } |
315 | mask = ((struct sockaddr_in *) &rt.rt_dst)->sin_addr.s_addr; | 318 | mask = ((struct sockaddr_in *) &rt->rt_dst)->sin_addr.s_addr; |
316 | if (mask & ~(uint32_t)mask_in_addr(rt)) { | 319 | if (mask & ~(uint32_t)mask_in_addr(*rt)) { |
317 | bb_error_msg_and_die("netmask and route address conflict"); | 320 | bb_error_msg_and_die("netmask and route address conflict"); |
318 | } | 321 | } |
319 | } | 322 | } |
320 | 323 | ||
321 | /* Fill out netmask if still unset */ | 324 | /* Fill out netmask if still unset */ |
322 | if ((action == RTACTION_ADD) && (rt.rt_flags & RTF_HOST)) { | 325 | if ((action == RTACTION_ADD) && (rt->rt_flags & RTF_HOST)) { |
323 | mask_in_addr(rt) = 0xffffffff; | 326 | mask_in_addr(*rt) = 0xffffffff; |
324 | } | 327 | } |
325 | 328 | ||
326 | /* Create a socket to the INET kernel. */ | 329 | /* Create a socket to the INET kernel. */ |
327 | skfd = xsocket(AF_INET, SOCK_DGRAM, 0); | 330 | skfd = xsocket(AF_INET, SOCK_DGRAM, 0); |
328 | 331 | ||
329 | if (action == RTACTION_ADD) | 332 | if (action == RTACTION_ADD) |
330 | xioctl(skfd, SIOCADDRT, &rt); | 333 | xioctl(skfd, SIOCADDRT, rt); |
331 | else | 334 | else |
332 | xioctl(skfd, SIOCDELRT, &rt); | 335 | xioctl(skfd, SIOCDELRT, rt); |
333 | 336 | ||
334 | if (ENABLE_FEATURE_CLEAN_UP) close(skfd); | 337 | if (ENABLE_FEATURE_CLEAN_UP) close(skfd); |
335 | } | 338 | } |
diff --git a/networking/telnetd.c b/networking/telnetd.c index 07c6a6a73..eec4417ca 100644 --- a/networking/telnetd.c +++ b/networking/telnetd.c | |||
@@ -31,10 +31,6 @@ | |||
31 | #endif | 31 | #endif |
32 | #include <arpa/telnet.h> | 32 | #include <arpa/telnet.h> |
33 | 33 | ||
34 | #if ENABLE_FEATURE_UTMP | ||
35 | # include <utmp.h> /* LOGIN_PROCESS */ | ||
36 | #endif | ||
37 | |||
38 | 34 | ||
39 | struct tsession { | 35 | struct tsession { |
40 | struct tsession *next; | 36 | struct tsession *next; |
diff --git a/networking/tftp.c b/networking/tftp.c index 04c8f0ebb..fcd933f6a 100644 --- a/networking/tftp.c +++ b/networking/tftp.c | |||
@@ -105,39 +105,22 @@ struct BUG_G_too_big { | |||
105 | #define error_pkt_str (error_pkt + 4) | 105 | #define error_pkt_str (error_pkt + 4) |
106 | 106 | ||
107 | #if ENABLE_FEATURE_TFTP_PROGRESS_BAR | 107 | #if ENABLE_FEATURE_TFTP_PROGRESS_BAR |
108 | /* SIGALRM logic nicked from the wget applet */ | 108 | static void tftp_progress_update(void) |
109 | static void progress_meter(int flag) | ||
110 | { | 109 | { |
111 | /* We can be called from signal handler */ | ||
112 | int save_errno = errno; | ||
113 | |||
114 | if (flag == -1) { /* first call to progress_meter */ | ||
115 | bb_progress_init(&G.pmt); | ||
116 | } | ||
117 | |||
118 | bb_progress_update(&G.pmt, G.file, 0, G.pos, G.size); | 110 | bb_progress_update(&G.pmt, G.file, 0, G.pos, G.size); |
119 | |||
120 | if (flag == 0) { | ||
121 | /* last call to progress_meter */ | ||
122 | alarm(0); | ||
123 | bb_putchar_stderr('\n'); | ||
124 | } else { | ||
125 | if (flag == -1) { /* first call to progress_meter */ | ||
126 | signal_SA_RESTART_empty_mask(SIGALRM, progress_meter); | ||
127 | } | ||
128 | alarm(1); | ||
129 | } | ||
130 | |||
131 | errno = save_errno; | ||
132 | } | 111 | } |
133 | static void tftp_progress_init(void) | 112 | static void tftp_progress_init(void) |
134 | { | 113 | { |
135 | progress_meter(-1); | 114 | bb_progress_init(&G.pmt); |
115 | tftp_progress_update(); | ||
136 | } | 116 | } |
137 | static void tftp_progress_done(void) | 117 | static void tftp_progress_done(void) |
138 | { | 118 | { |
139 | if (G.pmt.inited) | 119 | if (G.pmt.inited) { |
140 | progress_meter(0); | 120 | tftp_progress_update(); |
121 | bb_putchar_stderr('\n'); | ||
122 | G.pmt.inited = 0; | ||
123 | } | ||
141 | } | 124 | } |
142 | #else | 125 | #else |
143 | # define tftp_progress_init() ((void)0) | 126 | # define tftp_progress_init() ((void)0) |
@@ -460,9 +443,10 @@ static int tftp_protocol( | |||
460 | xsendto(socket_fd, xbuf, send_len, &peer_lsa->u.sa, peer_lsa->len); | 443 | xsendto(socket_fd, xbuf, send_len, &peer_lsa->u.sa, peer_lsa->len); |
461 | 444 | ||
462 | #if ENABLE_FEATURE_TFTP_PROGRESS_BAR | 445 | #if ENABLE_FEATURE_TFTP_PROGRESS_BAR |
463 | if (ENABLE_TFTP && remote_file) { /* tftp */ | 446 | if (ENABLE_TFTP && remote_file) /* tftp */ |
464 | G.pos = (block_nr - 1) * (uoff_t)blksize; | 447 | G.pos = (block_nr - 1) * (uoff_t)blksize; |
465 | } | 448 | if (G.pmt.inited) |
449 | tftp_progress_update(); | ||
466 | #endif | 450 | #endif |
467 | /* Was it final ACK? then exit */ | 451 | /* Was it final ACK? then exit */ |
468 | if (finished && (opcode == TFTP_ACK)) | 452 | if (finished && (opcode == TFTP_ACK)) |
@@ -479,6 +463,7 @@ static int tftp_protocol( | |||
479 | case 0: | 463 | case 0: |
480 | retries--; | 464 | retries--; |
481 | if (retries == 0) { | 465 | if (retries == 0) { |
466 | tftp_progress_done(); | ||
482 | bb_error_msg("timeout"); | 467 | bb_error_msg("timeout"); |
483 | goto ret; /* no err packet sent */ | 468 | goto ret; /* no err packet sent */ |
484 | } | 469 | } |
diff --git a/networking/traceroute.c b/networking/traceroute.c index c18fba8d0..82bb0118c 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -751,7 +751,8 @@ print(int read_len, const struct sockaddr *from, const struct sockaddr *to) | |||
751 | } else | 751 | } else |
752 | #endif | 752 | #endif |
753 | { | 753 | { |
754 | read_len -= ((struct ip*)recv_pkt)->ip_hl << 2; | 754 | struct ip *ip4packet = (struct ip*)recv_pkt; |
755 | read_len -= ip4packet->ip_hl << 2; | ||
755 | } | 756 | } |
756 | printf(" %d bytes to %s", read_len, ina); | 757 | printf(" %d bytes to %s", read_len, ina); |
757 | free(ina); | 758 | free(ina); |
diff --git a/networking/udhcp/dhcprelay.c b/networking/udhcp/dhcprelay.c index 759a4ba03..86ef04a62 100644 --- a/networking/udhcp/dhcprelay.c +++ b/networking/udhcp/dhcprelay.c | |||
@@ -25,7 +25,7 @@ struct xid_item { | |||
25 | uint32_t xid; | 25 | uint32_t xid; |
26 | struct sockaddr_in ip; | 26 | struct sockaddr_in ip; |
27 | struct xid_item *next; | 27 | struct xid_item *next; |
28 | }; | 28 | } FIX_ALIASING; |
29 | 29 | ||
30 | #define dhcprelay_xid_list (*(struct xid_item*)&bb_common_bufsiz1) | 30 | #define dhcprelay_xid_list (*(struct xid_item*)&bb_common_bufsiz1) |
31 | 31 | ||
diff --git a/networking/udhcp/dumpleases.c b/networking/udhcp/dumpleases.c index a15e409cc..21d62a2d2 100644 --- a/networking/udhcp/dumpleases.c +++ b/networking/udhcp/dumpleases.c | |||
@@ -57,7 +57,7 @@ int dumpleases_main(int argc UNUSED_PARAM, char **argv) | |||
57 | addr.s_addr = lease.lease_nip; | 57 | addr.s_addr = lease.lease_nip; |
58 | #if ENABLE_UNICODE_SUPPORT | 58 | #if ENABLE_UNICODE_SUPPORT |
59 | { | 59 | { |
60 | char *uni_name = unicode_conv_to_printable_fixedwidth(NULL, lease.hostname, 19); | 60 | char *uni_name = unicode_conv_to_printable_fixedwidth(/*NULL,*/ lease.hostname, 19); |
61 | printf(" %-16s%s ", inet_ntoa(addr), uni_name); | 61 | printf(" %-16s%s ", inet_ntoa(addr), uni_name); |
62 | free(uni_name); | 62 | free(uni_name); |
63 | } | 63 | } |
diff --git a/networking/udhcp/socket.c b/networking/udhcp/socket.c index 0ed7ad1c6..39f1cec54 100644 --- a/networking/udhcp/socket.c +++ b/networking/udhcp/socket.c | |||
@@ -36,42 +36,45 @@ | |||
36 | 36 | ||
37 | int FAST_FUNC udhcp_read_interface(const char *interface, int *ifindex, uint32_t *nip, uint8_t *mac) | 37 | int FAST_FUNC udhcp_read_interface(const char *interface, int *ifindex, uint32_t *nip, uint8_t *mac) |
38 | { | 38 | { |
39 | /* char buffer instead of bona-fide struct avoids aliasing warning */ | ||
40 | char ifr_buf[sizeof(struct ifreq)]; | ||
41 | struct ifreq *const ifr = (void *)ifr_buf; | ||
42 | |||
39 | int fd; | 43 | int fd; |
40 | struct ifreq ifr; | ||
41 | struct sockaddr_in *our_ip; | 44 | struct sockaddr_in *our_ip; |
42 | 45 | ||
43 | memset(&ifr, 0, sizeof(ifr)); | 46 | memset(ifr, 0, sizeof(*ifr)); |
44 | fd = xsocket(AF_INET, SOCK_RAW, IPPROTO_RAW); | 47 | fd = xsocket(AF_INET, SOCK_RAW, IPPROTO_RAW); |
45 | 48 | ||
46 | ifr.ifr_addr.sa_family = AF_INET; | 49 | ifr->ifr_addr.sa_family = AF_INET; |
47 | strncpy_IFNAMSIZ(ifr.ifr_name, interface); | 50 | strncpy_IFNAMSIZ(ifr->ifr_name, interface); |
48 | if (nip) { | 51 | if (nip) { |
49 | if (ioctl_or_perror(fd, SIOCGIFADDR, &ifr, | 52 | if (ioctl_or_perror(fd, SIOCGIFADDR, ifr, |
50 | "is interface %s up and configured?", interface) | 53 | "is interface %s up and configured?", interface) |
51 | ) { | 54 | ) { |
52 | close(fd); | 55 | close(fd); |
53 | return -1; | 56 | return -1; |
54 | } | 57 | } |
55 | our_ip = (struct sockaddr_in *) &ifr.ifr_addr; | 58 | our_ip = (struct sockaddr_in *) &ifr->ifr_addr; |
56 | *nip = our_ip->sin_addr.s_addr; | 59 | *nip = our_ip->sin_addr.s_addr; |
57 | log1("IP %s", inet_ntoa(our_ip->sin_addr)); | 60 | log1("IP %s", inet_ntoa(our_ip->sin_addr)); |
58 | } | 61 | } |
59 | 62 | ||
60 | if (ifindex) { | 63 | if (ifindex) { |
61 | if (ioctl_or_warn(fd, SIOCGIFINDEX, &ifr) != 0) { | 64 | if (ioctl_or_warn(fd, SIOCGIFINDEX, ifr) != 0) { |
62 | close(fd); | 65 | close(fd); |
63 | return -1; | 66 | return -1; |
64 | } | 67 | } |
65 | log1("Adapter index %d", ifr.ifr_ifindex); | 68 | log1("Adapter index %d", ifr->ifr_ifindex); |
66 | *ifindex = ifr.ifr_ifindex; | 69 | *ifindex = ifr->ifr_ifindex; |
67 | } | 70 | } |
68 | 71 | ||
69 | if (mac) { | 72 | if (mac) { |
70 | if (ioctl_or_warn(fd, SIOCGIFHWADDR, &ifr) != 0) { | 73 | if (ioctl_or_warn(fd, SIOCGIFHWADDR, ifr) != 0) { |
71 | close(fd); | 74 | close(fd); |
72 | return -1; | 75 | return -1; |
73 | } | 76 | } |
74 | memcpy(mac, ifr.ifr_hwaddr.sa_data, 6); | 77 | memcpy(mac, ifr->ifr_hwaddr.sa_data, 6); |
75 | log1("MAC %02x:%02x:%02x:%02x:%02x:%02x", | 78 | log1("MAC %02x:%02x:%02x:%02x:%02x:%02x", |
76 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); | 79 | mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); |
77 | } | 80 | } |
diff --git a/procps/free.c b/procps/free.c index efbac5ba6..ad8711f8a 100644 --- a/procps/free.c +++ b/procps/free.c | |||
@@ -19,7 +19,7 @@ struct globals { | |||
19 | #else | 19 | #else |
20 | # define G_unit_steps 10 | 20 | # define G_unit_steps 10 |
21 | #endif | 21 | #endif |
22 | }; | 22 | } FIX_ALIASING; |
23 | #define G (*(struct globals*)&bb_common_bufsiz1) | 23 | #define G (*(struct globals*)&bb_common_bufsiz1) |
24 | #define INIT_G() do { } while (0) | 24 | #define INIT_G() do { } while (0) |
25 | 25 | ||
diff --git a/procps/fuser.c b/procps/fuser.c index addf1a7d8..a1b93d77f 100644 --- a/procps/fuser.c +++ b/procps/fuser.c | |||
@@ -35,7 +35,7 @@ typedef struct pid_list { | |||
35 | struct globals { | 35 | struct globals { |
36 | pid_list *pid_list_head; | 36 | pid_list *pid_list_head; |
37 | inode_list *inode_list_head; | 37 | inode_list *inode_list_head; |
38 | }; | 38 | } FIX_ALIASING; |
39 | #define G (*(struct globals*)&bb_common_bufsiz1) | 39 | #define G (*(struct globals*)&bb_common_bufsiz1) |
40 | #define INIT_G() do { } while (0) | 40 | #define INIT_G() do { } while (0) |
41 | 41 | ||
diff --git a/procps/iostat.c b/procps/iostat.c index a9ff13a05..06a33eb1d 100644 --- a/procps/iostat.c +++ b/procps/iostat.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | //applet:IF_IOSTAT(APPLET(iostat, _BB_DIR_BIN, _BB_SUID_DROP)) | 10 | //applet:IF_IOSTAT(APPLET(iostat, BB_DIR_BIN, BB_SUID_DROP)) |
11 | 11 | ||
12 | //kbuild:lib-$(CONFIG_IOSTAT) += iostat.o | 12 | //kbuild:lib-$(CONFIG_IOSTAT) += iostat.o |
13 | 13 | ||
diff --git a/procps/mpstat.c b/procps/mpstat.c index 25efedf62..d643c999f 100644 --- a/procps/mpstat.c +++ b/procps/mpstat.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | //applet:IF_MPSTAT(APPLET(mpstat, _BB_DIR_BIN, _BB_SUID_DROP)) | 10 | //applet:IF_MPSTAT(APPLET(mpstat, BB_DIR_BIN, BB_SUID_DROP)) |
11 | 11 | ||
12 | //kbuild:lib-$(CONFIG_MPSTAT) += mpstat.o | 12 | //kbuild:lib-$(CONFIG_MPSTAT) += mpstat.o |
13 | 13 | ||
diff --git a/procps/nmeter.c b/procps/nmeter.c index ac019eb53..48b56a399 100644 --- a/procps/nmeter.c +++ b/procps/nmeter.c | |||
@@ -12,7 +12,7 @@ | |||
12 | //config: help | 12 | //config: help |
13 | //config: Prints selected system stats continuously, one line per update. | 13 | //config: Prints selected system stats continuously, one line per update. |
14 | 14 | ||
15 | //applet:IF_NMETER(APPLET(nmeter, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 15 | //applet:IF_NMETER(APPLET(nmeter, BB_DIR_USR_BIN, BB_SUID_DROP)) |
16 | 16 | ||
17 | //kbuild:lib-$(CONFIG_NMETER) += nmeter.o | 17 | //kbuild:lib-$(CONFIG_NMETER) += nmeter.o |
18 | 18 | ||
diff --git a/procps/pmap.c b/procps/pmap.c index bb5f9e7c2..7f7f391b9 100644 --- a/procps/pmap.c +++ b/procps/pmap.c | |||
@@ -8,7 +8,7 @@ | |||
8 | * for details. | 8 | * for details. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | //applet:IF_PMAP(APPLET(pmap, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 11 | //applet:IF_PMAP(APPLET(pmap, BB_DIR_USR_BIN, BB_SUID_DROP)) |
12 | //kbuild:lib-$(CONFIG_PMAP) += pmap.o | 12 | //kbuild:lib-$(CONFIG_PMAP) += pmap.o |
13 | 13 | ||
14 | //config:config PMAP | 14 | //config:config PMAP |
diff --git a/procps/powertop.c b/procps/powertop.c index 2f977a03b..bfe5a9568 100644 --- a/procps/powertop.c +++ b/procps/powertop.c | |||
@@ -9,7 +9,7 @@ | |||
9 | * Licensed under GPLv2, see file LICENSE in this source tree. | 9 | * Licensed under GPLv2, see file LICENSE in this source tree. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | //applet:IF_POWERTOP(APPLET(powertop, _BB_DIR_BIN, _BB_SUID_DROP)) | 12 | //applet:IF_POWERTOP(APPLET(powertop, BB_DIR_BIN, BB_SUID_DROP)) |
13 | 13 | ||
14 | //kbuild:lib-$(CONFIG_POWERTOP) += powertop.o | 14 | //kbuild:lib-$(CONFIG_POWERTOP) += powertop.o |
15 | 15 | ||
diff --git a/procps/pstree.c b/procps/pstree.c index 180d0939a..ddf5dba59 100644 --- a/procps/pstree.c +++ b/procps/pstree.c | |||
@@ -16,7 +16,7 @@ | |||
16 | //config: help | 16 | //config: help |
17 | //config: Display a tree of processes. | 17 | //config: Display a tree of processes. |
18 | 18 | ||
19 | //applet:IF_PSTREE(APPLET(pstree, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 19 | //applet:IF_PSTREE(APPLET(pstree, BB_DIR_USR_BIN, BB_SUID_DROP)) |
20 | 20 | ||
21 | //kbuild:lib-$(CONFIG_PSTREE) += pstree.o | 21 | //kbuild:lib-$(CONFIG_PSTREE) += pstree.o |
22 | 22 | ||
diff --git a/procps/smemcap.c b/procps/smemcap.c index 200df6795..e108d88ad 100644 --- a/procps/smemcap.c +++ b/procps/smemcap.c | |||
@@ -8,7 +8,7 @@ | |||
8 | herein by reference. | 8 | herein by reference. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | //applet:IF_SMEMCAP(APPLET(smemcap, _BB_DIR_USR_BIN, _BB_SUID_DROP)) | 11 | //applet:IF_SMEMCAP(APPLET(smemcap, BB_DIR_USR_BIN, BB_SUID_DROP)) |
12 | 12 | ||
13 | //kbuild:lib-$(CONFIG_SMEMCAP) += smemcap.o | 13 | //kbuild:lib-$(CONFIG_SMEMCAP) += smemcap.o |
14 | 14 | ||
diff --git a/procps/top.c b/procps/top.c index f9106fac7..ee6555188 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -19,9 +19,9 @@ | |||
19 | * | 19 | * |
20 | * Sept 2008: Vineet Gupta <vineet.gupta@arc.com> | 20 | * Sept 2008: Vineet Gupta <vineet.gupta@arc.com> |
21 | * Added Support for reporting SMP Information | 21 | * Added Support for reporting SMP Information |
22 | * - CPU where Process was last seen running | 22 | * - CPU where process was last seen running |
23 | * (to see effect of sched_setaffinity() etc) | 23 | * (to see effect of sched_setaffinity() etc) |
24 | * - CPU Time Split (idle/IO/wait etc) PER CPU | 24 | * - CPU time split (idle/IO/wait etc) per CPU |
25 | * | 25 | * |
26 | * Copyright (c) 1992 Branko Lankester | 26 | * Copyright (c) 1992 Branko Lankester |
27 | * Copyright (c) 1992 Roger Binns | 27 | * Copyright (c) 1992 Roger Binns |
@@ -30,6 +30,25 @@ | |||
30 | * | 30 | * |
31 | * Licensed under GPLv2, see file LICENSE in this source tree. | 31 | * Licensed under GPLv2, see file LICENSE in this source tree. |
32 | */ | 32 | */ |
33 | /* How to snapshot /proc for debugging top problems: | ||
34 | * for f in /proc/[0-9]*""/stat; do | ||
35 | * n=${f#/proc/} | ||
36 | * n=${n%/stat}_stat | ||
37 | * cp $f $n | ||
38 | * done | ||
39 | * cp /proc/stat /proc/meminfo /proc/loadavg . | ||
40 | * top -bn1 >top.out | ||
41 | * | ||
42 | * ...and how to run top on it on another machine: | ||
43 | * rm -rf proc; mkdir proc | ||
44 | * for f in [0-9]*_stat; do | ||
45 | * p=${f%_stat} | ||
46 | * mkdir -p proc/$p | ||
47 | * cp $f proc/$p/stat | ||
48 | * done | ||
49 | * cp stat meminfo loadavg proc | ||
50 | * chroot . ./top -bn1 >top1.out | ||
51 | */ | ||
33 | 52 | ||
34 | #include "libbb.h" | 53 | #include "libbb.h" |
35 | 54 | ||
@@ -519,7 +538,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) | |||
519 | 538 | ||
520 | /* what info of the processes is shown */ | 539 | /* what info of the processes is shown */ |
521 | printf(OPT_BATCH_MODE ? "%.*s" : "\033[7m%.*s\033[0m", scr_width, | 540 | printf(OPT_BATCH_MODE ? "%.*s" : "\033[7m%.*s\033[0m", scr_width, |
522 | " PID PPID USER STAT VSZ %MEM" | 541 | " PID PPID USER STAT VSZ %VSZ" |
523 | IF_FEATURE_TOP_SMP_PROCESS(" CPU") | 542 | IF_FEATURE_TOP_SMP_PROCESS(" CPU") |
524 | IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU") | 543 | IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU") |
525 | " COMMAND"); | 544 | " COMMAND"); |
@@ -537,7 +556,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) | |||
537 | # define FMT "%4u%%" | 556 | # define FMT "%4u%%" |
538 | #endif | 557 | #endif |
539 | /* | 558 | /* |
540 | * MEM% = s->vsz/MemTotal | 559 | * %VSZ = s->vsz/MemTotal |
541 | */ | 560 | */ |
542 | pmem_shift = BITS_PER_INT-11; | 561 | pmem_shift = BITS_PER_INT-11; |
543 | pmem_scale = UPSCALE*(1U<<(BITS_PER_INT-11)) / total_memory; | 562 | pmem_scale = UPSCALE*(1U<<(BITS_PER_INT-11)) / total_memory; |
@@ -546,7 +565,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) | |||
546 | pmem_scale /= 4; | 565 | pmem_scale /= 4; |
547 | pmem_shift -= 2; | 566 | pmem_shift -= 2; |
548 | } | 567 | } |
549 | pmem_half = (1U << pmem_shift) / (ENABLE_FEATURE_TOP_DECIMALS? 20 : 2); | 568 | pmem_half = (1U << pmem_shift) / (ENABLE_FEATURE_TOP_DECIMALS ? 20 : 2); |
550 | #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 569 | #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
551 | busy_jifs = cur_jif.busy - prev_jif.busy; | 570 | busy_jifs = cur_jif.busy - prev_jif.busy; |
552 | /* This happens if there were lots of short-lived processes | 571 | /* This happens if there were lots of short-lived processes |
@@ -577,7 +596,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) | |||
577 | pcpu_scale /= 4; | 596 | pcpu_scale /= 4; |
578 | pcpu_shift -= 2; | 597 | pcpu_shift -= 2; |
579 | } | 598 | } |
580 | pcpu_half = (1U << pcpu_shift) / (ENABLE_FEATURE_TOP_DECIMALS? 20 : 2); | 599 | pcpu_half = (1U << pcpu_shift) / (ENABLE_FEATURE_TOP_DECIMALS ? 20 : 2); |
581 | /* printf(" pmem_scale=%u pcpu_scale=%u ", pmem_scale, pcpu_scale); */ | 600 | /* printf(" pmem_scale=%u pcpu_scale=%u ", pmem_scale, pcpu_scale); */ |
582 | #endif | 601 | #endif |
583 | 602 | ||
@@ -597,7 +616,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) | |||
597 | sprintf(vsz_str_buf, "%6ldm", s->vsz/1024); | 616 | sprintf(vsz_str_buf, "%6ldm", s->vsz/1024); |
598 | else | 617 | else |
599 | sprintf(vsz_str_buf, "%7ld", s->vsz); | 618 | sprintf(vsz_str_buf, "%7ld", s->vsz); |
600 | /* PID PPID USER STAT VSZ %MEM [%CPU] COMMAND */ | 619 | /* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */ |
601 | col = snprintf(line_buf, scr_width, | 620 | col = snprintf(line_buf, scr_width, |
602 | "\n" "%5u%6u %-8.8s %s%s" FMT | 621 | "\n" "%5u%6u %-8.8s %s%s" FMT |
603 | IF_FEATURE_TOP_SMP_PROCESS(" %3d") | 622 | IF_FEATURE_TOP_SMP_PROCESS(" %3d") |
@@ -833,6 +852,35 @@ enum { | |||
833 | | PSSCAN_COMM, | 852 | | PSSCAN_COMM, |
834 | }; | 853 | }; |
835 | 854 | ||
855 | //usage:#if ENABLE_FEATURE_SHOW_THREADS || ENABLE_FEATURE_TOP_SMP_CPU | ||
856 | //usage:# define IF_SHOW_THREADS_OR_TOP_SMP(...) __VA_ARGS__ | ||
857 | //usage:#else | ||
858 | //usage:# define IF_SHOW_THREADS_OR_TOP_SMP(...) | ||
859 | //usage:#endif | ||
860 | //usage:#define top_trivial_usage | ||
861 | //usage: "[-b] [-nCOUNT] [-dSECONDS]" IF_FEATURE_TOPMEM(" [-m]") | ||
862 | //usage:#define top_full_usage "\n\n" | ||
863 | //usage: "Provide a view of process activity in real time." | ||
864 | //usage: "\n""Read the status of all processes from /proc each SECONDS" | ||
865 | //usage: "\n""and display a screenful of them." | ||
866 | //usage: "\n""Keys:" | ||
867 | //usage: "\n"" N/M" | ||
868 | //usage: IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE("/P") | ||
869 | //usage: IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE("/T") | ||
870 | //usage: ": " IF_FEATURE_TOPMEM("show CPU usage, ") "sort by pid/mem" | ||
871 | //usage: IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE("/cpu") | ||
872 | //usage: IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE("/time") | ||
873 | //usage: IF_FEATURE_TOPMEM( | ||
874 | //usage: "\n"" S: show memory, R: reverse memory sort" | ||
875 | //usage: ) | ||
876 | //usage: IF_SHOW_THREADS_OR_TOP_SMP( | ||
877 | //usage: "\n"" " | ||
878 | //usage: IF_FEATURE_SHOW_THREADS("H: toggle threads") | ||
879 | //usage: IF_FEATURE_SHOW_THREADS(IF_FEATURE_TOP_SMP_CPU(", ")) | ||
880 | //usage: IF_FEATURE_TOP_SMP_CPU("1: toggle SMP") | ||
881 | //usage: ) | ||
882 | //usage: "\n"" Q,^C: exit" | ||
883 | |||
836 | int top_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 884 | int top_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
837 | int top_main(int argc UNUSED_PARAM, char **argv) | 885 | int top_main(int argc UNUSED_PARAM, char **argv) |
838 | { | 886 | { |
diff --git a/runit/svlogd.c b/runit/svlogd.c index c3ff4e9c1..cfa20a773 100644 --- a/runit/svlogd.c +++ b/runit/svlogd.c | |||
@@ -125,6 +125,23 @@ log message, you can use a pattern like this instead | |||
125 | -*: *: pid * | 125 | -*: *: pid * |
126 | */ | 126 | */ |
127 | 127 | ||
128 | //usage:#define svlogd_trivial_usage | ||
129 | //usage: "[-ttv] [-r C] [-R CHARS] [-l MATCHLEN] [-b BUFLEN] DIR..." | ||
130 | //usage:#define svlogd_full_usage "\n\n" | ||
131 | //usage: "Continuously read log data from stdin and write to rotated log files in DIRs" | ||
132 | //usage: "\n" | ||
133 | //usage: "\n""DIR/config file modifies behavior:" | ||
134 | //usage: "\n""sSIZE - when to rotate logs" | ||
135 | //usage: "\n""nNUM - number of files to retain" | ||
136 | /*usage: "\n""NNUM - min number files to retain" - confusing */ | ||
137 | /*usage: "\n""tSEC - rotate file if it get SEC seconds old" - confusing */ | ||
138 | //usage: "\n""!PROG - process rotated log with PROG" | ||
139 | /*usage: "\n""uIPADDR - send log over UDP" - unsupported */ | ||
140 | /*usage: "\n""UIPADDR - send log over UDP and DONT log" - unsupported */ | ||
141 | /*usage: "\n""pPFX - prefix each line with PFX" - unsupported */ | ||
142 | //usage: "\n""+,-PATTERN - (de)select line for logging" | ||
143 | //usage: "\n""E,ePATTERN - (de)select line for stderr" | ||
144 | |||
128 | #include <sys/poll.h> | 145 | #include <sys/poll.h> |
129 | #include <sys/file.h> | 146 | #include <sys/file.h> |
130 | #include "libbb.h" | 147 | #include "libbb.h" |
diff --git a/scripts/defconfig.tig b/scripts/defconfig.tig index 44cd978e2..ed3058e54 100644 --- a/scripts/defconfig.tig +++ b/scripts/defconfig.tig | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
3 | # Busybox version: 1.19.0.git | 3 | # Busybox version: 1.19.0.git |
4 | # Mon Feb 20 10:36:01 2012 | 4 | # Wed Mar 21 20:40:54 2012 |
5 | # | 5 | # |
6 | CONFIG_HAVE_DOT_CONFIG=y | 6 | CONFIG_HAVE_DOT_CONFIG=y |
7 | # CONFIG_PLATFORM_POSIX is not set | 7 | # CONFIG_PLATFORM_POSIX is not set |
@@ -42,8 +42,8 @@ CONFIG_LAST_SUPPORTED_WCHAR=0 | |||
42 | CONFIG_LONG_OPTS=y | 42 | CONFIG_LONG_OPTS=y |
43 | # CONFIG_FEATURE_DEVPTS is not set | 43 | # CONFIG_FEATURE_DEVPTS is not set |
44 | # CONFIG_FEATURE_CLEAN_UP is not set | 44 | # CONFIG_FEATURE_CLEAN_UP is not set |
45 | # CONFIG_FEATURE_WTMP is not set | ||
46 | # CONFIG_FEATURE_UTMP is not set | 45 | # CONFIG_FEATURE_UTMP is not set |
46 | # CONFIG_FEATURE_WTMP is not set | ||
47 | # CONFIG_FEATURE_PIDFILE is not set | 47 | # CONFIG_FEATURE_PIDFILE is not set |
48 | # CONFIG_FEATURE_SUID is not set | 48 | # CONFIG_FEATURE_SUID is not set |
49 | # CONFIG_FEATURE_SUID_CONFIG is not set | 49 | # CONFIG_FEATURE_SUID_CONFIG is not set |
@@ -92,6 +92,7 @@ CONFIG_PREFIX="" | |||
92 | # | 92 | # |
93 | # Busybox Library Tuning | 93 | # Busybox Library Tuning |
94 | # | 94 | # |
95 | # CONFIG_FEATURE_SYSTEMD is not set | ||
95 | CONFIG_FEATURE_RTMINMAX=y | 96 | CONFIG_FEATURE_RTMINMAX=y |
96 | CONFIG_PASSWORD_MINLEN=6 | 97 | CONFIG_PASSWORD_MINLEN=6 |
97 | CONFIG_MD5_SIZE_VS_SPEED=2 | 98 | CONFIG_MD5_SIZE_VS_SPEED=2 |
diff --git a/shell/ash.c b/shell/ash.c index 93c582f73..28f988698 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -86,9 +86,9 @@ | |||
86 | # error "Do not even bother, ash will not run on NOMMU machine" | 86 | # error "Do not even bother, ash will not run on NOMMU machine" |
87 | #endif | 87 | #endif |
88 | 88 | ||
89 | //applet:IF_ASH(APPLET(ash, _BB_DIR_BIN, _BB_SUID_DROP)) | 89 | //applet:IF_ASH(APPLET(ash, BB_DIR_BIN, BB_SUID_DROP)) |
90 | //applet:IF_FEATURE_SH_IS_ASH(APPLET_ODDNAME(sh, ash, _BB_DIR_BIN, _BB_SUID_DROP, sh)) | 90 | //applet:IF_FEATURE_SH_IS_ASH(APPLET_ODDNAME(sh, ash, BB_DIR_BIN, BB_SUID_DROP, sh)) |
91 | //applet:IF_FEATURE_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, _BB_DIR_BIN, _BB_SUID_DROP, bash)) | 91 | //applet:IF_FEATURE_BASH_IS_ASH(APPLET_ODDNAME(bash, ash, BB_DIR_BIN, BB_SUID_DROP, bash)) |
92 | 92 | ||
93 | //kbuild:lib-$(CONFIG_ASH) += ash.o ash_ptr_hack.o shell_common.o | 93 | //kbuild:lib-$(CONFIG_ASH) += ash.o ash_ptr_hack.o shell_common.o |
94 | //kbuild:lib-$(CONFIG_ASH_RANDOM_SUPPORT) += random.o | 94 | //kbuild:lib-$(CONFIG_ASH_RANDOM_SUPPORT) += random.o |
@@ -5195,6 +5195,8 @@ stoppedjobs(void) | |||
5195 | * Code for dealing with input/output redirection. | 5195 | * Code for dealing with input/output redirection. |
5196 | */ | 5196 | */ |
5197 | 5197 | ||
5198 | #undef EMPTY | ||
5199 | #undef CLOSED | ||
5198 | #define EMPTY -2 /* marks an unused slot in redirtab */ | 5200 | #define EMPTY -2 /* marks an unused slot in redirtab */ |
5199 | #define CLOSED -3 /* marks a slot of previously-closed fd */ | 5201 | #define CLOSED -3 /* marks a slot of previously-closed fd */ |
5200 | 5202 | ||
diff --git a/shell/cttyhack.c b/shell/cttyhack.c index d1cb7fcc3..d1ac2cd23 100644 --- a/shell/cttyhack.c +++ b/shell/cttyhack.c | |||
@@ -6,7 +6,7 @@ | |||
6 | */ | 6 | */ |
7 | #include "libbb.h" | 7 | #include "libbb.h" |
8 | 8 | ||
9 | //applet:IF_CTTYHACK(APPLET(cttyhack, _BB_DIR_BIN, _BB_SUID_DROP)) | 9 | //applet:IF_CTTYHACK(APPLET(cttyhack, BB_DIR_BIN, BB_SUID_DROP)) |
10 | 10 | ||
11 | //kbuild:lib-$(CONFIG_CTTYHACK) += cttyhack.o | 11 | //kbuild:lib-$(CONFIG_CTTYHACK) += cttyhack.o |
12 | 12 | ||
diff --git a/shell/hush.c b/shell/hush.c index a771e9cd9..1709fd9d1 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -105,10 +105,10 @@ | |||
105 | # define PIPE_BUF 4096 /* amount of buffering in a pipe */ | 105 | # define PIPE_BUF 4096 /* amount of buffering in a pipe */ |
106 | #endif | 106 | #endif |
107 | 107 | ||
108 | //applet:IF_HUSH(APPLET(hush, _BB_DIR_BIN, _BB_SUID_DROP)) | 108 | //applet:IF_HUSH(APPLET(hush, BB_DIR_BIN, BB_SUID_DROP)) |
109 | //applet:IF_MSH(APPLET(msh, _BB_DIR_BIN, _BB_SUID_DROP)) | 109 | //applet:IF_MSH(APPLET(msh, BB_DIR_BIN, BB_SUID_DROP)) |
110 | //applet:IF_FEATURE_SH_IS_HUSH(APPLET_ODDNAME(sh, hush, _BB_DIR_BIN, _BB_SUID_DROP, sh)) | 110 | //applet:IF_FEATURE_SH_IS_HUSH(APPLET_ODDNAME(sh, hush, BB_DIR_BIN, BB_SUID_DROP, sh)) |
111 | //applet:IF_FEATURE_BASH_IS_HUSH(APPLET_ODDNAME(bash, hush, _BB_DIR_BIN, _BB_SUID_DROP, bash)) | 111 | //applet:IF_FEATURE_BASH_IS_HUSH(APPLET_ODDNAME(bash, hush, BB_DIR_BIN, BB_SUID_DROP, bash)) |
112 | 112 | ||
113 | //kbuild:lib-$(CONFIG_HUSH) += hush.o match.o shell_common.o | 113 | //kbuild:lib-$(CONFIG_HUSH) += hush.o match.o shell_common.o |
114 | //kbuild:lib-$(CONFIG_HUSH_RANDOM_SUPPORT) += random.o | 114 | //kbuild:lib-$(CONFIG_HUSH_RANDOM_SUPPORT) += random.o |
@@ -445,7 +445,6 @@ typedef struct in_str { | |||
445 | char eof_flag; /* meaningless if ->p == NULL */ | 445 | char eof_flag; /* meaningless if ->p == NULL */ |
446 | char peek_buf[2]; | 446 | char peek_buf[2]; |
447 | #if ENABLE_HUSH_INTERACTIVE | 447 | #if ENABLE_HUSH_INTERACTIVE |
448 | smallint promptme; | ||
449 | smallint promptmode; /* 0: PS1, 1: PS2 */ | 448 | smallint promptmode; /* 0: PS1, 1: PS2 */ |
450 | #endif | 449 | #endif |
451 | FILE *file; | 450 | FILE *file; |
@@ -1946,22 +1945,17 @@ static int FAST_FUNC file_get(struct in_str *i) | |||
1946 | /* need to double check i->file because we might be doing something | 1945 | /* need to double check i->file because we might be doing something |
1947 | * more complicated by now, like sourcing or substituting. */ | 1946 | * more complicated by now, like sourcing or substituting. */ |
1948 | #if ENABLE_HUSH_INTERACTIVE | 1947 | #if ENABLE_HUSH_INTERACTIVE |
1949 | if (G_interactive_fd && i->promptme && i->file == stdin) { | 1948 | if (G_interactive_fd && i->file == stdin) { |
1950 | do { | 1949 | do { |
1951 | get_user_input(i); | 1950 | get_user_input(i); |
1952 | } while (!*i->p); /* need non-empty line */ | 1951 | } while (!*i->p); /* need non-empty line */ |
1953 | i->promptmode = 1; /* PS2 */ | 1952 | i->promptmode = 1; /* PS2 */ |
1954 | i->promptme = 0; | ||
1955 | goto take_cached; | 1953 | goto take_cached; |
1956 | } | 1954 | } |
1957 | #endif | 1955 | #endif |
1958 | do ch = fgetc(i->file); while (ch == '\0'); | 1956 | do ch = fgetc(i->file); while (ch == '\0'); |
1959 | } | 1957 | } |
1960 | debug_printf("file_get: got '%c' %d\n", ch, ch); | 1958 | debug_printf("file_get: got '%c' %d\n", ch, ch); |
1961 | #if ENABLE_HUSH_INTERACTIVE | ||
1962 | if (ch == '\n') | ||
1963 | i->promptme = 1; | ||
1964 | #endif | ||
1965 | return ch; | 1959 | return ch; |
1966 | } | 1960 | } |
1967 | 1961 | ||
@@ -1988,26 +1982,22 @@ static int FAST_FUNC file_peek(struct in_str *i) | |||
1988 | 1982 | ||
1989 | static void setup_file_in_str(struct in_str *i, FILE *f) | 1983 | static void setup_file_in_str(struct in_str *i, FILE *f) |
1990 | { | 1984 | { |
1985 | memset(i, 0, sizeof(*i)); | ||
1991 | i->peek = file_peek; | 1986 | i->peek = file_peek; |
1992 | i->get = file_get; | 1987 | i->get = file_get; |
1993 | #if ENABLE_HUSH_INTERACTIVE | 1988 | /* i->promptmode = 0; - PS1 (memset did it) */ |
1994 | i->promptme = 1; | ||
1995 | i->promptmode = 0; /* PS1 */ | ||
1996 | #endif | ||
1997 | i->file = f; | 1989 | i->file = f; |
1998 | i->p = NULL; | 1990 | /* i->p = NULL; */ |
1999 | } | 1991 | } |
2000 | 1992 | ||
2001 | static void setup_string_in_str(struct in_str *i, const char *s) | 1993 | static void setup_string_in_str(struct in_str *i, const char *s) |
2002 | { | 1994 | { |
1995 | memset(i, 0, sizeof(*i)); | ||
2003 | i->peek = static_peek; | 1996 | i->peek = static_peek; |
2004 | i->get = static_get; | 1997 | i->get = static_get; |
2005 | #if ENABLE_HUSH_INTERACTIVE | 1998 | /* i->promptmode = 0; - PS1 (memset did it) */ |
2006 | i->promptme = 1; | ||
2007 | i->promptmode = 0; /* PS1 */ | ||
2008 | #endif | ||
2009 | i->p = s; | 1999 | i->p = s; |
2010 | i->eof_flag = 0; | 2000 | /* i->eof_flag = 0; */ |
2011 | } | 2001 | } |
2012 | 2002 | ||
2013 | 2003 | ||
@@ -4031,9 +4021,6 @@ static struct pipe *parse_stream(char **pstring, | |||
4031 | 4021 | ||
4032 | reset: /* we come back here only on syntax errors in interactive shell */ | 4022 | reset: /* we come back here only on syntax errors in interactive shell */ |
4033 | 4023 | ||
4034 | #if ENABLE_HUSH_INTERACTIVE | ||
4035 | input->promptmode = 0; /* PS1 */ | ||
4036 | #endif | ||
4037 | if (MAYBE_ASSIGNMENT != 0) | 4024 | if (MAYBE_ASSIGNMENT != 0) |
4038 | dest.o_assignment = MAYBE_ASSIGNMENT; | 4025 | dest.o_assignment = MAYBE_ASSIGNMENT; |
4039 | initialize_context(&ctx); | 4026 | initialize_context(&ctx); |
@@ -4140,7 +4127,27 @@ static struct pipe *parse_stream(char **pstring, | |||
4140 | if (IS_NULL_CMD(ctx.command) | 4127 | if (IS_NULL_CMD(ctx.command) |
4141 | && dest.length == 0 && !dest.has_quoted_part | 4128 | && dest.length == 0 && !dest.has_quoted_part |
4142 | ) { | 4129 | ) { |
4143 | continue; | 4130 | /* This newline can be ignored. But... |
4131 | * Without check #1, interactive shell | ||
4132 | * ignores even bare <newline>, | ||
4133 | * and shows the continuation prompt: | ||
4134 | * ps1_prompt$ <enter> | ||
4135 | * ps2> _ <=== wrong, should be ps1 | ||
4136 | * Without check #2, "cmd & <newline>" | ||
4137 | * is similarly mistreated. | ||
4138 | * (BTW, this makes "cmd & cmd" | ||
4139 | * and "cmd && cmd" non-orthogonal. | ||
4140 | * Really, ask yourself, why | ||
4141 | * "cmd && <newline>" doesn't start | ||
4142 | * cmd but waits for more input? | ||
4143 | * No reason...) | ||
4144 | */ | ||
4145 | struct pipe *pi = ctx.list_head; | ||
4146 | if (pi->num_cmds != 0 /* check #1 */ | ||
4147 | && pi->followup != PIPE_BG /* check #2 */ | ||
4148 | ) { | ||
4149 | continue; | ||
4150 | } | ||
4144 | } | 4151 | } |
4145 | /* Treat newline as a command separator. */ | 4152 | /* Treat newline as a command separator. */ |
4146 | done_pipe(&ctx, PIPE_SEQ); | 4153 | done_pipe(&ctx, PIPE_SEQ); |
@@ -4519,7 +4526,6 @@ static struct pipe *parse_stream(char **pstring, | |||
4519 | } | 4526 | } |
4520 | /* Discard cached input, force prompt */ | 4527 | /* Discard cached input, force prompt */ |
4521 | input->p = NULL; | 4528 | input->p = NULL; |
4522 | IF_HUSH_INTERACTIVE(input->promptme = 1;) | ||
4523 | goto reset; | 4529 | goto reset; |
4524 | } | 4530 | } |
4525 | } | 4531 | } |
@@ -5519,6 +5525,10 @@ static void parse_and_run_stream(struct in_str *inp, int end_trigger) | |||
5519 | while (1) { | 5525 | while (1) { |
5520 | struct pipe *pipe_list; | 5526 | struct pipe *pipe_list; |
5521 | 5527 | ||
5528 | #if ENABLE_HUSH_INTERACTIVE | ||
5529 | if (end_trigger == ';') | ||
5530 | inp->promptmode = 0; /* PS1 */ | ||
5531 | #endif | ||
5522 | pipe_list = parse_stream(NULL, inp, end_trigger); | 5532 | pipe_list = parse_stream(NULL, inp, end_trigger); |
5523 | if (!pipe_list) { /* EOF */ | 5533 | if (!pipe_list) { /* EOF */ |
5524 | if (empty) | 5534 | if (empty) |
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index fb7309538..24cab3b6c 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -512,6 +512,11 @@ static NOINLINE int create_socket(void) | |||
512 | int sock_fd; | 512 | int sock_fd; |
513 | char *dev_log_name; | 513 | char *dev_log_name; |
514 | 514 | ||
515 | #if ENABLE_FEATURE_SYSTEMD | ||
516 | if (sd_listen_fds() == 1) | ||
517 | return SD_LISTEN_FDS_START; | ||
518 | #endif | ||
519 | |||
515 | memset(&sunx, 0, sizeof(sunx)); | 520 | memset(&sunx, 0, sizeof(sunx)); |
516 | sunx.sun_family = AF_UNIX; | 521 | sunx.sun_family = AF_UNIX; |
517 | 522 | ||
diff --git a/util-linux/Config.src b/util-linux/Config.src index dbf2b0d85..941a47f90 100644 --- a/util-linux/Config.src +++ b/util-linux/Config.src | |||
@@ -361,7 +361,6 @@ config FEATURE_HWCLOCK_ADJTIME_FHS | |||
361 | config IPCRM | 361 | config IPCRM |
362 | bool "ipcrm" | 362 | bool "ipcrm" |
363 | default y | 363 | default y |
364 | select FEATURE_SUID | ||
365 | help | 364 | help |
366 | The ipcrm utility allows the removal of System V interprocess | 365 | The ipcrm utility allows the removal of System V interprocess |
367 | communication (IPC) objects and the associated data structures | 366 | communication (IPC) objects and the associated data structures |
@@ -371,7 +370,6 @@ config IPCS | |||
371 | bool "ipcs" | 370 | bool "ipcs" |
372 | default y | 371 | default y |
373 | depends on PLATFORM_LINUX | 372 | depends on PLATFORM_LINUX |
374 | select FEATURE_SUID | ||
375 | help | 373 | help |
376 | The ipcs utility is used to provide information on the currently | 374 | The ipcs utility is used to provide information on the currently |
377 | allocated System V interprocess (IPC) objects in the system. | 375 | allocated System V interprocess (IPC) objects in the system. |
diff --git a/util-linux/blockdev.c b/util-linux/blockdev.c index c61116df9..c2fcaee88 100644 --- a/util-linux/blockdev.c +++ b/util-linux/blockdev.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * Licensed under GPLv2, see file LICENSE in this source tree. | 6 | * Licensed under GPLv2, see file LICENSE in this source tree. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | //applet:IF_BLOCKDEV(APPLET(blockdev, _BB_DIR_SBIN, _BB_SUID_DROP)) | 9 | //applet:IF_BLOCKDEV(APPLET(blockdev, BB_DIR_SBIN, BB_SUID_DROP)) |
10 | 10 | ||
11 | //kbuild:lib-$(CONFIG_BLOCKDEV) += blockdev.o | 11 | //kbuild:lib-$(CONFIG_BLOCKDEV) += blockdev.o |
12 | 12 | ||
diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index 922dd0578..54e97e5bb 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c | |||
@@ -223,12 +223,63 @@ static void from_sys_clock(const char **pp_rtcname, int utc) | |||
223 | close(rtc); | 223 | close(rtc); |
224 | } | 224 | } |
225 | 225 | ||
226 | /* | ||
227 | * At system boot, kernel may set system time from RTC, | ||
228 | * but it knows nothing about timezones. If RTC is in local time, | ||
229 | * then system time is wrong - it is offset by timezone. | ||
230 | * This option corrects system time if RTC is in local time, | ||
231 | * and (always) sets in-kernel timezone. | ||
232 | * | ||
233 | * This is an alternate option to --hctosys that does not read the | ||
234 | * hardware clock. | ||
235 | */ | ||
236 | static void set_system_clock_timezone(int utc) | ||
237 | { | ||
238 | struct timeval tv; | ||
239 | struct tm *broken; | ||
240 | struct timezone tz; | ||
241 | |||
242 | gettimeofday(&tv, NULL); | ||
243 | broken = localtime(&tv.tv_sec); | ||
244 | tz.tz_minuteswest = timezone / 60; | ||
245 | if (broken->tm_isdst) | ||
246 | tz.tz_minuteswest -= 60; | ||
247 | tz.tz_dsttime = 0; | ||
248 | gettimeofday(&tv, NULL); | ||
249 | if (!utc) | ||
250 | tv.tv_sec += tz.tz_minuteswest * 60; | ||
251 | if (settimeofday(&tv, &tz)) | ||
252 | bb_perror_msg_and_die("settimeofday"); | ||
253 | } | ||
254 | |||
255 | //usage:#define hwclock_trivial_usage | ||
256 | //usage: IF_FEATURE_HWCLOCK_LONG_OPTIONS( | ||
257 | //usage: "[-r|--show] [-s|--hctosys] [-w|--systohc] [-t|--systz]" | ||
258 | //usage: " [-l|--localtime] [-u|--utc]" | ||
259 | //usage: " [-f|--rtc FILE]" | ||
260 | //usage: ) | ||
261 | //usage: IF_NOT_FEATURE_HWCLOCK_LONG_OPTIONS( | ||
262 | //usage: "[-r] [-s] [-w] [-t] [-l] [-u] [-f FILE]" | ||
263 | //usage: ) | ||
264 | //usage:#define hwclock_full_usage "\n\n" | ||
265 | //usage: "Query and set hardware clock (RTC)\n" | ||
266 | //usage: "\nOptions:" | ||
267 | //usage: "\n -r Show hardware clock time" | ||
268 | //usage: "\n -s Set system time from hardware clock" | ||
269 | //usage: "\n -w Set hardware clock from system time" | ||
270 | //usage: "\n -t Set in-kernel timezone, correct system time" | ||
271 | //usage: "\n if hardware clock is in local time" | ||
272 | //usage: "\n -u Hardware clock is in UTC" | ||
273 | //usage: "\n -l Hardware clock is in local time" | ||
274 | //usage: "\n -f FILE Use specified device (e.g. /dev/rtc2)" | ||
275 | |||
226 | #define HWCLOCK_OPT_LOCALTIME 0x01 | 276 | #define HWCLOCK_OPT_LOCALTIME 0x01 |
227 | #define HWCLOCK_OPT_UTC 0x02 | 277 | #define HWCLOCK_OPT_UTC 0x02 |
228 | #define HWCLOCK_OPT_SHOW 0x04 | 278 | #define HWCLOCK_OPT_SHOW 0x04 |
229 | #define HWCLOCK_OPT_HCTOSYS 0x08 | 279 | #define HWCLOCK_OPT_HCTOSYS 0x08 |
230 | #define HWCLOCK_OPT_SYSTOHC 0x10 | 280 | #define HWCLOCK_OPT_SYSTOHC 0x10 |
231 | #define HWCLOCK_OPT_RTCFILE 0x20 | 281 | #define HWCLOCK_OPT_SYSTZ 0x20 |
282 | #define HWCLOCK_OPT_RTCFILE 0x40 | ||
232 | 283 | ||
233 | int hwclock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 284 | int hwclock_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
234 | int hwclock_main(int argc UNUSED_PARAM, char **argv) | 285 | int hwclock_main(int argc UNUSED_PARAM, char **argv) |
@@ -239,17 +290,18 @@ int hwclock_main(int argc UNUSED_PARAM, char **argv) | |||
239 | 290 | ||
240 | #if ENABLE_FEATURE_HWCLOCK_LONG_OPTIONS | 291 | #if ENABLE_FEATURE_HWCLOCK_LONG_OPTIONS |
241 | static const char hwclock_longopts[] ALIGN1 = | 292 | static const char hwclock_longopts[] ALIGN1 = |
242 | "localtime\0" No_argument "l" | 293 | "localtime\0" No_argument "l" /* short opt is non-standard */ |
243 | "utc\0" No_argument "u" | 294 | "utc\0" No_argument "u" |
244 | "show\0" No_argument "r" | 295 | "show\0" No_argument "r" |
245 | "hctosys\0" No_argument "s" | 296 | "hctosys\0" No_argument "s" |
246 | "systohc\0" No_argument "w" | 297 | "systohc\0" No_argument "w" |
247 | "file\0" Required_argument "f" | 298 | "systz\0" No_argument "t" /* short opt is non-standard */ |
299 | "rtc\0" Required_argument "f" | ||
248 | ; | 300 | ; |
249 | applet_long_options = hwclock_longopts; | 301 | applet_long_options = hwclock_longopts; |
250 | #endif | 302 | #endif |
251 | opt_complementary = "r--ws:w--rs:s--wr:l--u:u--l"; | 303 | opt_complementary = "r--wst:w--rst:s--wrt:t--rsw:l--u:u--l"; |
252 | opt = getopt32(argv, "lurswf:", &rtcname); | 304 | opt = getopt32(argv, "lurswtf:", &rtcname); |
253 | 305 | ||
254 | /* If -u or -l wasn't given check if we are using utc */ | 306 | /* If -u or -l wasn't given check if we are using utc */ |
255 | if (opt & (HWCLOCK_OPT_UTC | HWCLOCK_OPT_LOCALTIME)) | 307 | if (opt & (HWCLOCK_OPT_UTC | HWCLOCK_OPT_LOCALTIME)) |
@@ -261,6 +313,8 @@ int hwclock_main(int argc UNUSED_PARAM, char **argv) | |||
261 | to_sys_clock(&rtcname, utc); | 313 | to_sys_clock(&rtcname, utc); |
262 | else if (opt & HWCLOCK_OPT_SYSTOHC) | 314 | else if (opt & HWCLOCK_OPT_SYSTOHC) |
263 | from_sys_clock(&rtcname, utc); | 315 | from_sys_clock(&rtcname, utc); |
316 | else if (opt & HWCLOCK_OPT_SYSTZ) | ||
317 | set_system_clock_timezone(utc); | ||
264 | else | 318 | else |
265 | /* default HWCLOCK_OPT_SHOW */ | 319 | /* default HWCLOCK_OPT_SHOW */ |
266 | show_clock(&rtcname, utc); | 320 | show_clock(&rtcname, utc); |
diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c index 53537fcd9..2e9662b2b 100644 --- a/util-linux/mkswap.c +++ b/util-linux/mkswap.c | |||
@@ -15,7 +15,7 @@ static void mkswap_selinux_setcontext(int fd, const char *path) | |||
15 | if (!is_selinux_enabled()) | 15 | if (!is_selinux_enabled()) |
16 | return; | 16 | return; |
17 | 17 | ||
18 | xfstat(fd, &stbuf, argv[0]); | 18 | xfstat(fd, &stbuf, path); |
19 | if (S_ISREG(stbuf.st_mode)) { | 19 | if (S_ISREG(stbuf.st_mode)) { |
20 | security_context_t newcon; | 20 | security_context_t newcon; |
21 | security_context_t oldcon = NULL; | 21 | security_context_t oldcon = NULL; |
diff --git a/util-linux/rev.c b/util-linux/rev.c index e1e004437..3c1b22f09 100644 --- a/util-linux/rev.c +++ b/util-linux/rev.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * Licensed under GPLv2, see file LICENSE in this source tree. | 6 | * Licensed under GPLv2, see file LICENSE in this source tree. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | //applet:IF_REV(APPLET(rev, _BB_DIR_BIN, _BB_SUID_DROP)) | 9 | //applet:IF_REV(APPLET(rev, BB_DIR_BIN, BB_SUID_DROP)) |
10 | 10 | ||
11 | //kbuild:lib-$(CONFIG_REV) += rev.o | 11 | //kbuild:lib-$(CONFIG_REV) += rev.o |
12 | 12 | ||