summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-04-10 15:43:37 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-04-10 15:43:37 +0000
commit99912ca733dd960f5589227fd999c86e73c8e894 (patch)
tree9df947fc08884d498cf76a02204d74b121064134
parentff131b980d524a33d8a43cefe65e14f64a43f2da (diff)
downloadbusybox-w32-99912ca733dd960f5589227fd999c86e73c8e894.tar.gz
busybox-w32-99912ca733dd960f5589227fd999c86e73c8e894.tar.bz2
busybox-w32-99912ca733dd960f5589227fd999c86e73c8e894.zip
audit small applets and mark some of them as NOFORK.
Put big scary warnings in relevant places.
-rw-r--r--coreutils/basename.c7
-rw-r--r--coreutils/cat.c8
-rw-r--r--coreutils/chgrp.c3
-rw-r--r--coreutils/chmod.c3
-rw-r--r--coreutils/chown.c3
-rw-r--r--coreutils/chroot.c5
-rw-r--r--coreutils/cp.c3
-rw-r--r--coreutils/cut.c3
-rw-r--r--coreutils/dd.c5
-rw-r--r--coreutils/dirname.c6
-rw-r--r--coreutils/false.c3
-rw-r--r--coreutils/hostid.c6
-rw-r--r--coreutils/length.c13
-rw-r--r--coreutils/ln.c3
-rw-r--r--coreutils/logname.c14
-rw-r--r--coreutils/ls.c5
-rw-r--r--coreutils/mkdir.c8
-rw-r--r--coreutils/mkfifo.c6
-rw-r--r--coreutils/pwd.c7
-rw-r--r--coreutils/rm.c8
-rw-r--r--coreutils/rmdir.c10
-rw-r--r--coreutils/seq.c19
-rw-r--r--coreutils/sleep.c16
-rw-r--r--coreutils/sort.c3
-rw-r--r--coreutils/sync.c4
-rw-r--r--coreutils/test.c7
-rw-r--r--coreutils/true.c3
-rw-r--r--coreutils/tty.c6
-rw-r--r--coreutils/usleep.c5
-rw-r--r--coreutils/whoami.c9
-rw-r--r--coreutils/yes.c17
-rw-r--r--editors/awk.c2
-rw-r--r--findutils/find.c3
-rw-r--r--findutils/xargs.c3
-rw-r--r--include/applets.h38
-rw-r--r--libbb/copyfd.c11
-rw-r--r--libbb/fflush_stdout_and_exit.c4
-rw-r--r--libbb/make_directory.c5
-rw-r--r--libbb/parse_mode.c2
-rw-r--r--libbb/remove_file.c2
-rw-r--r--util-linux/hexdump.c13
41 files changed, 173 insertions, 128 deletions
diff --git a/coreutils/basename.c b/coreutils/basename.c
index 46f7122c8..f4307d6ce 100644
--- a/coreutils/basename.c
+++ b/coreutils/basename.c
@@ -20,11 +20,10 @@
20 * 3) Save some space by using strcmp(). Calling strncmp() here was silly. 20 * 3) Save some space by using strcmp(). Calling strncmp() here was silly.
21 */ 21 */
22 22
23#include <stdlib.h>
24#include <stdio.h>
25#include <string.h>
26#include "busybox.h" 23#include "busybox.h"
27 24
25/* This is a NOFORK applet. Be very careful! */
26
28int basename_main(int argc, char **argv); 27int basename_main(int argc, char **argv);
29int basename_main(int argc, char **argv) 28int basename_main(int argc, char **argv)
30{ 29{
@@ -47,5 +46,5 @@ int basename_main(int argc, char **argv)
47 46
48 puts(s); 47 puts(s);
49 48
50 fflush_stdout_and_exit(EXIT_SUCCESS); 49 return fflush(stdout);
51} 50}
diff --git a/coreutils/cat.c b/coreutils/cat.c
index 7bab325ef..eb141dc79 100644
--- a/coreutils/cat.c
+++ b/coreutils/cat.c
@@ -12,17 +12,23 @@
12 12
13#include "busybox.h" 13#include "busybox.h"
14 14
15/* This is a NOFORK applet. Be very careful! */
16
17
15int bb_cat(char **argv) 18int bb_cat(char **argv)
16{ 19{
17 static const char *const argv_dash[] = { "-", NULL }; 20 static const char *const argv_dash[] = { "-", NULL };
21
18 FILE *f; 22 FILE *f;
19 int retval = EXIT_SUCCESS; 23 int retval = EXIT_SUCCESS;
20 24
21 if (!*argv) argv = (char**) &argv_dash; 25 if (!*argv)
26 argv = (char**) &argv_dash;
22 27
23 do { 28 do {
24 f = fopen_or_warn_stdin(*argv); 29 f = fopen_or_warn_stdin(*argv);
25 if (f) { 30 if (f) {
31 /* This is not an xfunc - never exits */
26 off_t r = bb_copyfd_eof(fileno(f), STDOUT_FILENO); 32 off_t r = bb_copyfd_eof(fileno(f), STDOUT_FILENO);
27 fclose_if_not_stdin(f); 33 fclose_if_not_stdin(f);
28 if (r >= 0) 34 if (r >= 0)
diff --git a/coreutils/chgrp.c b/coreutils/chgrp.c
index cfb8c15b2..48014ecdf 100644
--- a/coreutils/chgrp.c
+++ b/coreutils/chgrp.c
@@ -13,6 +13,9 @@
13 13
14#include "busybox.h" 14#include "busybox.h"
15 15
16/* This is a NOEXEC applet. Be very careful! */
17
18
16int chgrp_main(int argc, char **argv); 19int chgrp_main(int argc, char **argv);
17int chgrp_main(int argc, char **argv) 20int chgrp_main(int argc, char **argv)
18{ 21{
diff --git a/coreutils/chmod.c b/coreutils/chmod.c
index 9a73218a1..aa3625877 100644
--- a/coreutils/chmod.c
+++ b/coreutils/chmod.c
@@ -16,6 +16,9 @@
16 16
17#include "busybox.h" 17#include "busybox.h"
18 18
19/* This is a NOEXEC applet. Be very careful! */
20
21
19#define OPT_RECURSE (option_mask32 & 1) 22#define OPT_RECURSE (option_mask32 & 1)
20#define OPT_VERBOSE (USE_DESKTOP(option_mask32 & 2) SKIP_DESKTOP(0)) 23#define OPT_VERBOSE (USE_DESKTOP(option_mask32 & 2) SKIP_DESKTOP(0))
21#define OPT_CHANGED (USE_DESKTOP(option_mask32 & 4) SKIP_DESKTOP(0)) 24#define OPT_CHANGED (USE_DESKTOP(option_mask32 & 4) SKIP_DESKTOP(0))
diff --git a/coreutils/chown.c b/coreutils/chown.c
index e64a39c3e..71ba81247 100644
--- a/coreutils/chown.c
+++ b/coreutils/chown.c
@@ -13,6 +13,9 @@
13 13
14#include "busybox.h" 14#include "busybox.h"
15 15
16/* This is a NOEXEC applet. Be very careful! */
17
18
16#define OPT_STR ("Rh" USE_DESKTOP("vcfLHP")) 19#define OPT_STR ("Rh" USE_DESKTOP("vcfLHP"))
17#define BIT_RECURSE 1 20#define BIT_RECURSE 1
18#define OPT_RECURSE (option_mask32 & 1) 21#define OPT_RECURSE (option_mask32 & 1)
diff --git a/coreutils/chroot.c b/coreutils/chroot.c
index fcd70f21a..874ee917e 100644
--- a/coreutils/chroot.c
+++ b/coreutils/chroot.c
@@ -27,8 +27,9 @@ int chroot_main(int argc, char **argv)
27 ++argv; 27 ++argv;
28 if (argc == 2) { 28 if (argc == 2) {
29 argv -= 2; 29 argv -= 2;
30 if (!(*argv = getenv("SHELL"))) { 30 argv[0] = getenv("SHELL");
31 *argv = (char *) DEFAULT_SHELL; 31 if (!argv[0]) {
32 argv[0] = (char *) DEFAULT_SHELL;
32 } 33 }
33 argv[1] = (char *) "-i"; 34 argv[1] = (char *) "-i";
34 } 35 }
diff --git a/coreutils/cp.c b/coreutils/cp.c
index a80e0d286..8c0937971 100644
--- a/coreutils/cp.c
+++ b/coreutils/cp.c
@@ -18,6 +18,9 @@
18#include "busybox.h" 18#include "busybox.h"
19#include "libcoreutils/coreutils.h" 19#include "libcoreutils/coreutils.h"
20 20
21/* This is a NOEXEC applet. Be very careful! */
22
23
21int cp_main(int argc, char **argv); 24int cp_main(int argc, char **argv);
22int cp_main(int argc, char **argv) 25int cp_main(int argc, char **argv)
23{ 26{
diff --git a/coreutils/cut.c b/coreutils/cut.c
index 22014fcfb..b9ea3127c 100644
--- a/coreutils/cut.c
+++ b/coreutils/cut.c
@@ -11,6 +11,9 @@
11 11
12#include "busybox.h" 12#include "busybox.h"
13 13
14/* This is a NOEXEC applet. Be very careful! */
15
16
14/* option vars */ 17/* option vars */
15static const char optstring[] = "b:c:f:d:sn"; 18static const char optstring[] = "b:c:f:d:sn";
16#define CUT_OPT_BYTE_FLGS (1<<0) 19#define CUT_OPT_BYTE_FLGS (1<<0)
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 4507b5e0c..34a325ea6 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -8,8 +8,11 @@
8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
9 */ 9 */
10 10
11#include "busybox.h"
12#include <signal.h> /* For FEATURE_DD_SIGNAL_HANDLING */ 11#include <signal.h> /* For FEATURE_DD_SIGNAL_HANDLING */
12#include "busybox.h"
13
14/* This is a NOEXEC applet. Be very careful! */
15
13 16
14static const struct suffix_mult dd_suffixes[] = { 17static const struct suffix_mult dd_suffixes[] = {
15 { "c", 1 }, 18 { "c", 1 },
diff --git a/coreutils/dirname.c b/coreutils/dirname.c
index 4ecde3147..7c5484bfd 100644
--- a/coreutils/dirname.c
+++ b/coreutils/dirname.c
@@ -10,10 +10,10 @@
10/* BB_AUDIT SUSv3 compliant */ 10/* BB_AUDIT SUSv3 compliant */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/dirname.html */ 11/* http://www.opengroup.org/onlinepubs/007904975/utilities/dirname.html */
12 12
13#include <stdio.h>
14#include <stdlib.h>
15#include "busybox.h" 13#include "busybox.h"
16 14
15/* This is a NOFORK applet. Be very careful! */
16
17int dirname_main(int argc, char **argv); 17int dirname_main(int argc, char **argv);
18int dirname_main(int argc, char **argv) 18int dirname_main(int argc, char **argv)
19{ 19{
@@ -23,5 +23,5 @@ int dirname_main(int argc, char **argv)
23 23
24 puts(dirname(argv[1])); 24 puts(dirname(argv[1]));
25 25
26 fflush_stdout_and_exit(EXIT_SUCCESS); 26 return fflush(stdout);
27} 27}
diff --git a/coreutils/false.c b/coreutils/false.c
index 2a26e0e28..90d6a0162 100644
--- a/coreutils/false.c
+++ b/coreutils/false.c
@@ -10,9 +10,10 @@
10/* BB_AUDIT SUSv3 compliant */ 10/* BB_AUDIT SUSv3 compliant */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/false.html */ 11/* http://www.opengroup.org/onlinepubs/007904975/utilities/false.html */
12 12
13#include <stdlib.h>
14#include "busybox.h" 13#include "busybox.h"
15 14
15/* This is a NOFORK applet. Be very careful! */
16
16int false_main(int ATTRIBUTE_UNUSED argc, char ATTRIBUTE_UNUSED **argv); 17int false_main(int ATTRIBUTE_UNUSED argc, char ATTRIBUTE_UNUSED **argv);
17int false_main(int ATTRIBUTE_UNUSED argc, char ATTRIBUTE_UNUSED **argv) 18int false_main(int ATTRIBUTE_UNUSED argc, char ATTRIBUTE_UNUSED **argv)
18{ 19{
diff --git a/coreutils/hostid.c b/coreutils/hostid.c
index 51a76c631..e14f6ca57 100644
--- a/coreutils/hostid.c
+++ b/coreutils/hostid.c
@@ -9,10 +9,10 @@
9 9
10/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */ 10/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
11 11
12#include <stdlib.h>
13#include <unistd.h>
14#include "busybox.h" 12#include "busybox.h"
15 13
14/* This is a NOFORK applet. Be very careful! */
15
16int hostid_main(int argc, char ATTRIBUTE_UNUSED **argv); 16int hostid_main(int argc, char ATTRIBUTE_UNUSED **argv);
17int hostid_main(int argc, char ATTRIBUTE_UNUSED **argv) 17int hostid_main(int argc, char ATTRIBUTE_UNUSED **argv)
18{ 18{
@@ -22,5 +22,5 @@ int hostid_main(int argc, char ATTRIBUTE_UNUSED **argv)
22 22
23 printf("%lx\n", gethostid()); 23 printf("%lx\n", gethostid());
24 24
25 fflush_stdout_and_exit(EXIT_SUCCESS); 25 return fflush(stdout);
26} 26}
diff --git a/coreutils/length.c b/coreutils/length.c
index 1dc122cc1..b3a9d4903 100644
--- a/coreutils/length.c
+++ b/coreutils/length.c
@@ -2,19 +2,18 @@
2 2
3/* BB_AUDIT SUSv3 N/A -- Apparently a busybox (obsolete?) extension. */ 3/* BB_AUDIT SUSv3 N/A -- Apparently a busybox (obsolete?) extension. */
4 4
5#include <stdlib.h>
6#include <string.h>
7#include <stdio.h>
8#include "busybox.h" 5#include "busybox.h"
9 6
7/* This is a NOFORK applet. Be very careful! */
8
10int length_main(int argc, char **argv); 9int length_main(int argc, char **argv);
11int length_main(int argc, char **argv) 10int length_main(int argc, char **argv)
12{ 11{
13 if ((argc != 2) || (**(++argv) == '-')) { 12 if ((argc != 2) || (**(++argv) == '-')) {
14 bb_show_usage(); 13 bb_show_usage();
15 } 14 }
16 15
17 printf("%lu\n", (unsigned long)strlen(*argv)); 16 printf("%u\n", (unsigned)strlen(*argv));
18 17
19 fflush_stdout_and_exit(EXIT_SUCCESS); 18 return fflush(stdout);
20} 19}
diff --git a/coreutils/ln.c b/coreutils/ln.c
index 720713475..fd4eacec2 100644
--- a/coreutils/ln.c
+++ b/coreutils/ln.c
@@ -13,6 +13,9 @@
13 13
14#include "busybox.h" 14#include "busybox.h"
15 15
16/* This is a NOEXEC applet. Be very careful! */
17
18
16#define LN_SYMLINK 1 19#define LN_SYMLINK 1
17#define LN_FORCE 2 20#define LN_FORCE 2
18#define LN_NODEREFERENCE 4 21#define LN_NODEREFERENCE 4
diff --git a/coreutils/logname.c b/coreutils/logname.c
index 743e2291c..aba6ce3c6 100644
--- a/coreutils/logname.c
+++ b/coreutils/logname.c
@@ -20,23 +20,23 @@
20 * a diagnostic message and an error return. 20 * a diagnostic message and an error return.
21 */ 21 */
22 22
23#include <stdio.h>
24#include <stdlib.h>
25#include <unistd.h>
26#include "busybox.h" 23#include "busybox.h"
27 24
25/* This is a NOFORK applet. Be very careful! */
26
28int logname_main(int argc, char ATTRIBUTE_UNUSED **argv); 27int logname_main(int argc, char ATTRIBUTE_UNUSED **argv);
29int logname_main(int argc, char ATTRIBUTE_UNUSED **argv) 28int logname_main(int argc, char ATTRIBUTE_UNUSED **argv)
30{ 29{
31 const char *p; 30 char buf[128];
32 31
33 if (argc > 1) { 32 if (argc > 1) {
34 bb_show_usage(); 33 bb_show_usage();
35 } 34 }
36 35
37 if ((p = getlogin()) != NULL) { 36 /* Using _r function - avoid pulling in static buffer from libc */
38 puts(p); 37 if (getlogin_r(buf, sizeof(buf)) == 0) {
39 fflush_stdout_and_exit(EXIT_SUCCESS); 38 puts(buf);
39 return fflush(stdout);
40 } 40 }
41 41
42 bb_perror_msg_and_die("getlogin"); 42 bb_perror_msg_and_die("getlogin");
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 34836ee29..7bbb19d6c 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -29,8 +29,11 @@
29 * 1. requires lstat (BSD) - how do you do it without? 29 * 1. requires lstat (BSD) - how do you do it without?
30 */ 30 */
31 31
32#include "busybox.h"
33#include <getopt.h> 32#include <getopt.h>
33#include "busybox.h"
34
35/* This is a NOEXEC applet. Be very careful! */
36
34 37
35enum { 38enum {
36 39
diff --git a/coreutils/mkdir.c b/coreutils/mkdir.c
index 690e4ab40..5a6c9d077 100644
--- a/coreutils/mkdir.c
+++ b/coreutils/mkdir.c
@@ -19,19 +19,19 @@
19/* Nov 28, 2006 Yoshinori Sato <ysato@users.sourceforge.jp>: Add SELinux Support. 19/* Nov 28, 2006 Yoshinori Sato <ysato@users.sourceforge.jp>: Add SELinux Support.
20 */ 20 */
21 21
22#include <stdlib.h>
23#include <unistd.h>
24#include <getopt.h> /* struct option */ 22#include <getopt.h> /* struct option */
25#include "busybox.h" 23#include "busybox.h"
26 24
25/* This is a NOFORK applet. Be very careful! */
26
27#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS 27#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
28static const struct option mkdir_long_options[] = { 28static const struct option mkdir_long_options[] = {
29 { "mode", 1, NULL, 'm' }, 29 { "mode" , 1, NULL, 'm' },
30 { "parents", 0, NULL, 'p' }, 30 { "parents", 0, NULL, 'p' },
31#if ENABLE_SELINUX 31#if ENABLE_SELINUX
32 { "context", 1, NULL, 'Z' }, 32 { "context", 1, NULL, 'Z' },
33#endif 33#endif
34 { 0, 0, 0, 0 } 34 { NULL, 0, NULL, 0 }
35}; 35};
36#endif 36#endif
37 37
diff --git a/coreutils/mkfifo.c b/coreutils/mkfifo.c
index 6d8aa413e..7dcc50fa9 100644
--- a/coreutils/mkfifo.c
+++ b/coreutils/mkfifo.c
@@ -10,9 +10,6 @@
10/* BB_AUDIT SUSv3 compliant */ 10/* BB_AUDIT SUSv3 compliant */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/mkfifo.html */ 11/* http://www.opengroup.org/onlinepubs/007904975/utilities/mkfifo.html */
12 12
13#include <stdlib.h>
14#include <unistd.h>
15#include <sys/types.h>
16#include "busybox.h" 13#include "busybox.h"
17#include "libcoreutils/coreutils.h" 14#include "libcoreutils/coreutils.h"
18 15
@@ -24,7 +21,8 @@ int mkfifo_main(int argc, char **argv)
24 21
25 mode = getopt_mk_fifo_nod(argc, argv); 22 mode = getopt_mk_fifo_nod(argc, argv);
26 23
27 if (!*(argv += optind)) { 24 argv += optind;
25 if (!*argv) {
28 bb_show_usage(); 26 bb_show_usage();
29 } 27 }
30 28
diff --git a/coreutils/pwd.c b/coreutils/pwd.c
index d96f6a8e5..a93b8f115 100644
--- a/coreutils/pwd.c
+++ b/coreutils/pwd.c
@@ -7,10 +7,10 @@
7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8 */ 8 */
9 9
10#include <stdio.h>
11#include <stdlib.h>
12#include "busybox.h" 10#include "busybox.h"
13 11
12/* This is a NOFORK applet. Be very careful! */
13
14int pwd_main(int argc, char **argv); 14int pwd_main(int argc, char **argv);
15int pwd_main(int argc, char **argv) 15int pwd_main(int argc, char **argv)
16{ 16{
@@ -19,7 +19,8 @@ int pwd_main(int argc, char **argv)
19 buf = xrealloc_getcwd_or_warn(NULL); 19 buf = xrealloc_getcwd_or_warn(NULL);
20 if (buf != NULL) { 20 if (buf != NULL) {
21 puts(buf); 21 puts(buf);
22 fflush_stdout_and_exit(EXIT_SUCCESS); 22 free(buf);
23 return fflush(stdout);
23 } 24 }
24 25
25 return EXIT_FAILURE; 26 return EXIT_FAILURE;
diff --git a/coreutils/rm.c b/coreutils/rm.c
index 1883feed8..6f32e7dc5 100644
--- a/coreutils/rm.c
+++ b/coreutils/rm.c
@@ -15,9 +15,10 @@
15 * Size reduction. 15 * Size reduction.
16 */ 16 */
17 17
18#include <unistd.h>
19#include "busybox.h" 18#include "busybox.h"
20 19
20/* This is a NOFORK applet. Be very careful! */
21
21int rm_main(int argc, char **argv); 22int rm_main(int argc, char **argv);
22int rm_main(int argc, char **argv) 23int rm_main(int argc, char **argv)
23{ 24{
@@ -27,14 +28,15 @@ int rm_main(int argc, char **argv)
27 28
28 opt_complementary = "f-i:i-f"; 29 opt_complementary = "f-i:i-f";
29 opt = getopt32(argc, argv, "fiRr"); 30 opt = getopt32(argc, argv, "fiRr");
31 argv += optind;
30 if(opt & 1) 32 if(opt & 1)
31 flags |= FILEUTILS_FORCE; 33 flags |= FILEUTILS_FORCE;
32 if(opt & 2) 34 if(opt & 2)
33 flags |= FILEUTILS_INTERACTIVE; 35 flags |= FILEUTILS_INTERACTIVE;
34 if(opt & 12) 36 if(opt & 12)
35 flags |= FILEUTILS_RECUR; 37 flags |= FILEUTILS_RECUR;
36 38
37 if (*(argv += optind) != NULL) { 39 if (*argv != NULL) {
38 do { 40 do {
39 const char *base = bb_get_last_path_component(*argv); 41 const char *base = bb_get_last_path_component(*argv);
40 42
diff --git a/coreutils/rmdir.c b/coreutils/rmdir.c
index 8cbd6f1fa..7f3253017 100644
--- a/coreutils/rmdir.c
+++ b/coreutils/rmdir.c
@@ -10,11 +10,12 @@
10/* BB_AUDIT SUSv3 compliant */ 10/* BB_AUDIT SUSv3 compliant */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/rmdir.html */ 11/* http://www.opengroup.org/onlinepubs/007904975/utilities/rmdir.html */
12 12
13#include <stdlib.h>
14#include <unistd.h>
15#include <libgen.h> 13#include <libgen.h>
16#include "busybox.h" 14#include "busybox.h"
17 15
16/* This is a NOFORK applet. Be very careful! */
17
18
18int rmdir_main(int argc, char **argv); 19int rmdir_main(int argc, char **argv);
19int rmdir_main(int argc, char **argv) 20int rmdir_main(int argc, char **argv)
20{ 21{
@@ -24,7 +25,6 @@ int rmdir_main(int argc, char **argv)
24 char *path; 25 char *path;
25 26
26 flags = getopt32(argc, argv, "p"); 27 flags = getopt32(argc, argv, "p");
27
28 argv += optind; 28 argv += optind;
29 29
30 if (!*argv) { 30 if (!*argv) {
@@ -37,7 +37,7 @@ int rmdir_main(int argc, char **argv)
37 /* Record if the first char was a '.' so we can use dirname later. */ 37 /* Record if the first char was a '.' so we can use dirname later. */
38 do_dot = (*path == '.'); 38 do_dot = (*path == '.');
39 39
40 do { 40 while (1) {
41 if (rmdir(path) < 0) { 41 if (rmdir(path) < 0) {
42 bb_perror_msg("'%s'", path); /* Match gnu rmdir msg. */ 42 bb_perror_msg("'%s'", path); /* Match gnu rmdir msg. */
43 status = EXIT_FAILURE; 43 status = EXIT_FAILURE;
@@ -53,7 +53,7 @@ int rmdir_main(int argc, char **argv)
53 } 53 }
54 } 54 }
55 break; 55 break;
56 } while (1); 56 }
57 57
58 } while (*++argv); 58 } while (*++argv);
59 59
diff --git a/coreutils/seq.c b/coreutils/seq.c
index e81a4660a..ef884d6ae 100644
--- a/coreutils/seq.c
+++ b/coreutils/seq.c
@@ -7,21 +7,22 @@
7 * Licensed under the GPL v2, see the file LICENSE in this tarball. 7 * Licensed under the GPL v2, see the file LICENSE in this tarball.
8 */ 8 */
9 9
10#include <stdio.h>
11#include <stdlib.h>
12#include "busybox.h" 10#include "busybox.h"
13 11
12/* This is a NOFORK applet. Be very careful! */
13
14
14int seq_main(int argc, char **argv); 15int seq_main(int argc, char **argv);
15int seq_main(int argc, char **argv) 16int seq_main(int argc, char **argv)
16{ 17{
17 double last, first, increment, i; 18 double last, increment, i;
18 19
19 first = increment = 1; 20 i = increment = 1;
20 switch (argc) { 21 switch (argc) {
21 case 4: 22 case 4:
22 increment = atof(argv[2]); 23 increment = atof(argv[2]);
23 case 3: 24 case 3:
24 first = atof(argv[1]); 25 i = atof(argv[1]);
25 case 2: 26 case 2:
26 last = atof(argv[argc-1]); 27 last = atof(argv[argc-1]);
27 break; 28 break;
@@ -30,12 +31,10 @@ int seq_main(int argc, char **argv)
30 } 31 }
31 32
32 /* You should note that this is pos-5.0.91 semantics, -- FK. */ 33 /* You should note that this is pos-5.0.91 semantics, -- FK. */
33 for (i = first; 34 while ((increment > 0 && i <= last) || (increment < 0 && i >= last)) {
34 (increment > 0 && i <= last) || (increment < 0 && i >=last);
35 i += increment)
36 {
37 printf("%g\n", i); 35 printf("%g\n", i);
36 i += increment;
38 } 37 }
39 38
40 return EXIT_SUCCESS; 39 return fflush(stdout);
41} 40}
diff --git a/coreutils/sleep.c b/coreutils/sleep.c
index b89b0fe9c..592005bab 100644
--- a/coreutils/sleep.c
+++ b/coreutils/sleep.c
@@ -18,12 +18,12 @@
18 * time suffixes for seconds, minutes, hours, and days. 18 * time suffixes for seconds, minutes, hours, and days.
19 */ 19 */
20 20
21#include <stdlib.h>
22#include <limits.h>
23#include <unistd.h>
24#include "busybox.h" 21#include "busybox.h"
25 22
26#ifdef CONFIG_FEATURE_FANCY_SLEEP 23/* This is a NOFORK applet. Be very careful! */
24
25
26#if ENABLE_FEATURE_FANCY_SLEEP
27static const struct suffix_mult sfx[] = { 27static const struct suffix_mult sfx[] = {
28 { "s", 1 }, 28 { "s", 1 },
29 { "m", 60 }, 29 { "m", 60 },
@@ -36,9 +36,9 @@ static const struct suffix_mult sfx[] = {
36int sleep_main(int argc, char **argv); 36int sleep_main(int argc, char **argv);
37int sleep_main(int argc, char **argv) 37int sleep_main(int argc, char **argv)
38{ 38{
39 unsigned int duration; 39 unsigned duration;
40 40
41#ifdef CONFIG_FEATURE_FANCY_SLEEP 41#if ENABLE_FEATURE_FANCY_SLEEP
42 42
43 if (argc < 2) { 43 if (argc < 2) {
44 bb_show_usage(); 44 bb_show_usage();
@@ -50,7 +50,7 @@ int sleep_main(int argc, char **argv)
50 duration += xatoul_range_sfx(*argv, 0, UINT_MAX-duration, sfx); 50 duration += xatoul_range_sfx(*argv, 0, UINT_MAX-duration, sfx);
51 } while (*++argv); 51 } while (*++argv);
52 52
53#else /* CONFIG_FEATURE_FANCY_SLEEP */ 53#else /* FEATURE_FANCY_SLEEP */
54 54
55 if (argc != 2) { 55 if (argc != 2) {
56 bb_show_usage(); 56 bb_show_usage();
@@ -58,7 +58,7 @@ int sleep_main(int argc, char **argv)
58 58
59 duration = xatou(argv[1]); 59 duration = xatou(argv[1]);
60 60
61#endif /* CONFIG_FEATURE_FANCY_SLEEP */ 61#endif /* FEATURE_FANCY_SLEEP */
62 62
63 if (sleep(duration)) { 63 if (sleep(duration)) {
64 bb_perror_nomsg_and_die(); 64 bb_perror_nomsg_and_die();
diff --git a/coreutils/sort.c b/coreutils/sort.c
index dad542964..06a6cbf70 100644
--- a/coreutils/sort.c
+++ b/coreutils/sort.c
@@ -14,6 +14,9 @@
14 14
15#include "busybox.h" 15#include "busybox.h"
16 16
17/* This is a NOEXEC applet. Be very careful! */
18
19
17/* 20/*
18 sort [-m][-o output][-bdfinru][-t char][-k keydef]... [file...] 21 sort [-m][-o output][-bdfinru][-t char][-k keydef]... [file...]
19 sort -c [-bdfinru][-t char][-k keydef][file] 22 sort -c [-bdfinru][-t char][-k keydef][file]
diff --git a/coreutils/sync.c b/coreutils/sync.c
index 536c57a17..e52ab768d 100644
--- a/coreutils/sync.c
+++ b/coreutils/sync.c
@@ -9,10 +9,10 @@
9 9
10/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */ 10/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
11 11
12#include <stdlib.h>
13#include <unistd.h>
14#include "busybox.h" 12#include "busybox.h"
15 13
14/* This is a NOFORK applet. Be very careful! */
15
16int sync_main(int argc, char **argv); 16int sync_main(int argc, char **argv);
17int sync_main(int argc, char **argv) 17int sync_main(int argc, char **argv)
18{ 18{
diff --git a/coreutils/test.c b/coreutils/test.c
index d5babefce..e9b627638 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -21,12 +21,11 @@
21 */ 21 */
22 22
23#include "busybox.h" 23#include "busybox.h"
24#include <unistd.h>
25#include <ctype.h>
26#include <errno.h>
27#include <string.h>
28#include <setjmp.h> 24#include <setjmp.h>
29 25
26/* This is a NOEXEC applet. Be very careful! */
27
28
30/* test(1) accepts the following grammar: 29/* test(1) accepts the following grammar:
31 oexpr ::= aexpr | aexpr "-o" oexpr ; 30 oexpr ::= aexpr | aexpr "-o" oexpr ;
32 aexpr ::= nexpr | nexpr "-a" aexpr ; 31 aexpr ::= nexpr | nexpr "-a" aexpr ;
diff --git a/coreutils/true.c b/coreutils/true.c
index b2f3a9bad..eee621331 100644
--- a/coreutils/true.c
+++ b/coreutils/true.c
@@ -10,9 +10,10 @@
10/* BB_AUDIT SUSv3 compliant */ 10/* BB_AUDIT SUSv3 compliant */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/true.html */ 11/* http://www.opengroup.org/onlinepubs/007904975/utilities/true.html */
12 12
13#include <stdlib.h>
14#include "busybox.h" 13#include "busybox.h"
15 14
15/* This is a NOFORK applet. Be very careful! */
16
16int true_main(int argc, char **argv); 17int true_main(int argc, char **argv);
17int true_main(int argc, char **argv) 18int true_main(int argc, char **argv)
18{ 19{
diff --git a/coreutils/tty.c b/coreutils/tty.c
index c28aa33d7..d4c179fca 100644
--- a/coreutils/tty.c
+++ b/coreutils/tty.c
@@ -10,9 +10,6 @@
10/* BB_AUDIT SUSv3 compliant */ 10/* BB_AUDIT SUSv3 compliant */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/tty.html */ 11/* http://www.opengroup.org/onlinepubs/007904975/utilities/tty.html */
12 12
13#include <stdio.h>
14#include <stdlib.h>
15#include <unistd.h>
16#include "busybox.h" 13#include "busybox.h"
17 14
18int tty_main(int argc, char **argv); 15int tty_main(int argc, char **argv);
@@ -31,7 +28,8 @@ int tty_main(int argc, char **argv)
31 28
32 retval = 0; 29 retval = 0;
33 30
34 if ((s = ttyname(0)) == NULL) { 31 s = ttyname(0);
32 if (s == NULL) {
35 /* According to SUSv3, ttyname can on fail with EBADF or ENOTTY. 33 /* According to SUSv3, ttyname can on fail with EBADF or ENOTTY.
36 * We know the file descriptor is good, so failure means not a tty. */ 34 * We know the file descriptor is good, so failure means not a tty. */
37 s = "not a tty"; 35 s = "not a tty";
diff --git a/coreutils/usleep.c b/coreutils/usleep.c
index 7dd914638..2baf2bc87 100644
--- a/coreutils/usleep.c
+++ b/coreutils/usleep.c
@@ -9,11 +9,10 @@
9 9
10/* BB_AUDIT SUSv3 N/A -- Apparently a busybox extension. */ 10/* BB_AUDIT SUSv3 N/A -- Apparently a busybox extension. */
11 11
12#include <stdlib.h>
13#include <limits.h>
14#include <unistd.h>
15#include "busybox.h" 12#include "busybox.h"
16 13
14/* This is a NOFORK applet. Be very careful! */
15
17int usleep_main(int argc, char **argv); 16int usleep_main(int argc, char **argv);
18int usleep_main(int argc, char **argv) 17int usleep_main(int argc, char **argv)
19{ 18{
diff --git a/coreutils/whoami.c b/coreutils/whoami.c
index 3185817b6..25757f633 100644
--- a/coreutils/whoami.c
+++ b/coreutils/whoami.c
@@ -9,11 +9,10 @@
9 9
10/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */ 10/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
11 11
12#include <stdio.h>
13#include <stdlib.h>
14#include <unistd.h>
15#include "busybox.h" 12#include "busybox.h"
16 13
14/* This is a NOFORK applet. Be very careful! */
15
17int whoami_main(int argc, char **argv); 16int whoami_main(int argc, char **argv);
18int whoami_main(int argc, char **argv) 17int whoami_main(int argc, char **argv)
19{ 18{
@@ -21,6 +20,6 @@ int whoami_main(int argc, char **argv)
21 bb_show_usage(); 20 bb_show_usage();
22 21
23 puts(bb_getpwuid(NULL, geteuid(), -1)); 22 puts(bb_getpwuid(NULL, geteuid(), -1));
24 /* exits on error */ 23
25 fflush_stdout_and_exit(EXIT_SUCCESS); 24 return fflush(stdout);
26} 25}
diff --git a/coreutils/yes.c b/coreutils/yes.c
index 2611c3e82..569764150 100644
--- a/coreutils/yes.c
+++ b/coreutils/yes.c
@@ -16,25 +16,26 @@
16 16
17#include "busybox.h" 17#include "busybox.h"
18 18
19/* This is a NOFORK applet. Be very careful! */
20
19int yes_main(int argc, char **argv); 21int yes_main(int argc, char **argv);
20int yes_main(int argc, char **argv) 22int yes_main(int argc, char **argv)
21{ 23{
22 static const char fmt_str[] = " %s";
23 const char *fmt;
24 char **first_arg; 24 char **first_arg;
25 25
26 *argv = (char*)"y"; 26 argv[0] = (char*)"y";
27 if (argc != 1) { 27 if (argc != 1) {
28 ++argv; 28 ++argv;
29 } 29 }
30 30
31 first_arg = argv; 31 first_arg = argv;
32 do { 32 do {
33 fmt = fmt_str + 1; 33 while (1) {
34 do { 34 fputs(*argv, stdout);
35 printf(fmt, *argv); 35 if (!*++argv)
36 fmt = fmt_str; 36 break;
37 } while (*++argv); 37 putchar(' ');
38 }
38 argv = first_arg; 39 argv = first_arg;
39 } while (putchar('\n') != EOF); 40 } while (putchar('\n') != EOF);
40 41
diff --git a/editors/awk.c b/editors/awk.c
index f331a33fa..1bdb9b924 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -11,6 +11,8 @@
11#include "xregex.h" 11#include "xregex.h"
12#include <math.h> 12#include <math.h>
13 13
14/* This is a NOEXEC applet. Be very careful! */
15
14 16
15#define MAXVARFMT 240 17#define MAXVARFMT 240
16#define MINNVBLOCK 64 18#define MINNVBLOCK 64
diff --git a/findutils/find.c b/findutils/find.c
index 1a1301b38..b77d36dc3 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -48,6 +48,9 @@
48#include <fnmatch.h> 48#include <fnmatch.h>
49#include "busybox.h" 49#include "busybox.h"
50 50
51/* This is a NOEXEC applet. Be very careful! */
52
53
51USE_FEATURE_FIND_XDEV(static dev_t *xdev_dev;) 54USE_FEATURE_FIND_XDEV(static dev_t *xdev_dev;)
52USE_FEATURE_FIND_XDEV(static int xdev_count;) 55USE_FEATURE_FIND_XDEV(static int xdev_count;)
53 56
diff --git a/findutils/xargs.c b/findutils/xargs.c
index b4dd9f876..2b3a5081c 100644
--- a/findutils/xargs.c
+++ b/findutils/xargs.c
@@ -19,6 +19,9 @@
19 19
20#include "busybox.h" 20#include "busybox.h"
21 21
22/* This is a NOEXEC applet. Be very careful! */
23
24
22/* COMPAT: SYSV version defaults size (and has a max value of) to 470. 25/* COMPAT: SYSV version defaults size (and has a max value of) to 470.
23 We try to make it as large as possible. */ 26 We try to make it as large as possible. */
24#if !defined(ARG_MAX) && defined(_SC_ARG_MAX) 27#if !defined(ARG_MAX) && defined(_SC_ARG_MAX)
diff --git a/include/applets.h b/include/applets.h
index ecce32169..b59d33183 100644
--- a/include/applets.h
+++ b/include/applets.h
@@ -76,17 +76,17 @@ USE_ARP(APPLET(arp, _BB_DIR_SBIN, _BB_SUID_NEVER))
76USE_ARPING(APPLET(arping, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 76USE_ARPING(APPLET(arping, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
77USE_ASH(APPLET_NOUSAGE(ash, ash, _BB_DIR_BIN, _BB_SUID_NEVER)) 77USE_ASH(APPLET_NOUSAGE(ash, ash, _BB_DIR_BIN, _BB_SUID_NEVER))
78USE_AWK(APPLET_NOEXEC(awk, awk, _BB_DIR_USR_BIN, _BB_SUID_NEVER, awk)) 78USE_AWK(APPLET_NOEXEC(awk, awk, _BB_DIR_USR_BIN, _BB_SUID_NEVER, awk))
79USE_BASENAME(APPLET(basename, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 79USE_BASENAME(APPLET_NOFORK(basename, basename, _BB_DIR_USR_BIN, _BB_SUID_NEVER, basename))
80USE_BBCONFIG(APPLET(bbconfig, _BB_DIR_BIN, _BB_SUID_NEVER)) 80USE_BBCONFIG(APPLET(bbconfig, _BB_DIR_BIN, _BB_SUID_NEVER))
81//USE_BBSH(APPLET(bbsh, _BB_DIR_BIN, _BB_SUID_NEVER)) 81//USE_BBSH(APPLET(bbsh, _BB_DIR_BIN, _BB_SUID_NEVER))
82USE_BUNZIP2(APPLET(bunzip2, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 82USE_BUNZIP2(APPLET(bunzip2, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
83USE_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, _BB_DIR_USR_BIN, _BB_SUID_NEVER, bzcat)) 83USE_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, _BB_DIR_USR_BIN, _BB_SUID_NEVER, bzcat))
84USE_CAL(APPLET(cal, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 84USE_CAL(APPLET(cal, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
85USE_CAT(APPLET_NOEXEC(cat, cat, _BB_DIR_BIN, _BB_SUID_NEVER, cat)) 85USE_CAT(APPLET_NOFORK(cat, cat, _BB_DIR_BIN, _BB_SUID_NEVER, cat))
86USE_CATV(APPLET(catv, _BB_DIR_BIN, _BB_SUID_NEVER)) 86USE_CATV(APPLET(catv, _BB_DIR_BIN, _BB_SUID_NEVER))
87USE_CHATTR(APPLET(chattr, _BB_DIR_BIN, _BB_SUID_NEVER)) 87USE_CHATTR(APPLET(chattr, _BB_DIR_BIN, _BB_SUID_NEVER))
88USE_CHCON(APPLET(chcon, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 88USE_CHCON(APPLET(chcon, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
89USE_CHGRP(APPLET(chgrp, _BB_DIR_BIN, _BB_SUID_NEVER)) 89USE_CHGRP(APPLET_NOEXEC(chgrp, chgrp, _BB_DIR_BIN, _BB_SUID_NEVER, chgrp))
90USE_CHMOD(APPLET_NOEXEC(chmod, chmod, _BB_DIR_BIN, _BB_SUID_NEVER, chmod)) 90USE_CHMOD(APPLET_NOEXEC(chmod, chmod, _BB_DIR_BIN, _BB_SUID_NEVER, chmod))
91USE_CHOWN(APPLET_NOEXEC(chown, chown, _BB_DIR_BIN, _BB_SUID_NEVER, chown)) 91USE_CHOWN(APPLET_NOEXEC(chown, chown, _BB_DIR_BIN, _BB_SUID_NEVER, chown))
92USE_CHPST(APPLET(chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 92USE_CHPST(APPLET(chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
@@ -112,7 +112,7 @@ USE_DEVFSD(APPLET(devfsd, _BB_DIR_SBIN, _BB_SUID_NEVER))
112USE_DF(APPLET(df, _BB_DIR_BIN, _BB_SUID_NEVER)) 112USE_DF(APPLET(df, _BB_DIR_BIN, _BB_SUID_NEVER))
113USE_APP_DHCPRELAY(APPLET(dhcprelay, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) 113USE_APP_DHCPRELAY(APPLET(dhcprelay, _BB_DIR_USR_SBIN, _BB_SUID_NEVER))
114USE_DIFF(APPLET(diff, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 114USE_DIFF(APPLET(diff, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
115USE_DIRNAME(APPLET(dirname, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 115USE_DIRNAME(APPLET_NOFORK(dirname, dirname, _BB_DIR_USR_BIN, _BB_SUID_NEVER, dirname))
116USE_DMESG(APPLET(dmesg, _BB_DIR_BIN, _BB_SUID_NEVER)) 116USE_DMESG(APPLET(dmesg, _BB_DIR_BIN, _BB_SUID_NEVER))
117USE_DNSD(APPLET(dnsd, _BB_DIR_USR_SBIN, _BB_SUID_ALWAYS)) 117USE_DNSD(APPLET(dnsd, _BB_DIR_USR_SBIN, _BB_SUID_ALWAYS))
118USE_DOS2UNIX(APPLET(dos2unix, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 118USE_DOS2UNIX(APPLET(dos2unix, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
@@ -133,7 +133,7 @@ USE_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER,
133USE_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, _BB_DIR_USR_BIN, _BB_SUID_NEVER, ether_wake)) 133USE_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, _BB_DIR_USR_BIN, _BB_SUID_NEVER, ether_wake))
134USE_EXPR(APPLET(expr, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 134USE_EXPR(APPLET(expr, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
135USE_FAKEIDENTD(APPLET(fakeidentd, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) 135USE_FAKEIDENTD(APPLET(fakeidentd, _BB_DIR_USR_SBIN, _BB_SUID_NEVER))
136USE_FALSE(APPLET(false, _BB_DIR_BIN, _BB_SUID_NEVER)) 136USE_FALSE(APPLET_NOFORK(false, false, _BB_DIR_BIN, _BB_SUID_NEVER, false))
137USE_FBSET(APPLET(fbset, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) 137USE_FBSET(APPLET(fbset, _BB_DIR_USR_SBIN, _BB_SUID_NEVER))
138USE_FDFLUSH(APPLET_ODDNAME(fdflush, freeramdisk, _BB_DIR_BIN, _BB_SUID_NEVER, fdflush)) 138USE_FDFLUSH(APPLET_ODDNAME(fdflush, freeramdisk, _BB_DIR_BIN, _BB_SUID_NEVER, fdflush))
139USE_FDFORMAT(APPLET(fdformat, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 139USE_FDFORMAT(APPLET(fdformat, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
@@ -162,7 +162,7 @@ USE_HALT(APPLET(halt, _BB_DIR_SBIN, _BB_SUID_NEVER))
162USE_HDPARM(APPLET(hdparm, _BB_DIR_SBIN, _BB_SUID_NEVER)) 162USE_HDPARM(APPLET(hdparm, _BB_DIR_SBIN, _BB_SUID_NEVER))
163USE_HEAD(APPLET(head, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 163USE_HEAD(APPLET(head, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
164USE_HEXDUMP(APPLET_NOEXEC(hexdump, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hexdump)) 164USE_HEXDUMP(APPLET_NOEXEC(hexdump, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hexdump))
165USE_HOSTID(APPLET(hostid, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 165USE_HOSTID(APPLET_NOFORK(hostid, hostid, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hostid))
166USE_HOSTNAME(APPLET(hostname, _BB_DIR_BIN, _BB_SUID_NEVER)) 166USE_HOSTNAME(APPLET(hostname, _BB_DIR_BIN, _BB_SUID_NEVER))
167USE_HTTPD(APPLET(httpd, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) 167USE_HTTPD(APPLET(httpd, _BB_DIR_USR_SBIN, _BB_SUID_NEVER))
168USE_HUSH(APPLET_NOUSAGE(hush, hush, _BB_DIR_BIN, _BB_SUID_NEVER)) 168USE_HUSH(APPLET_NOUSAGE(hush, hush, _BB_DIR_BIN, _BB_SUID_NEVER))
@@ -190,7 +190,7 @@ USE_KILLALL5(APPLET_ODDNAME(killall5, kill, _BB_DIR_USR_BIN, _BB_SUID_NEVER, kil
190USE_KLOGD(APPLET(klogd, _BB_DIR_SBIN, _BB_SUID_NEVER)) 190USE_KLOGD(APPLET(klogd, _BB_DIR_SBIN, _BB_SUID_NEVER))
191USE_LASH(APPLET(lash, _BB_DIR_BIN, _BB_SUID_NEVER)) 191USE_LASH(APPLET(lash, _BB_DIR_BIN, _BB_SUID_NEVER))
192USE_LAST(APPLET(last, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 192USE_LAST(APPLET(last, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
193USE_LENGTH(APPLET(length, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 193USE_LENGTH(APPLET_NOFORK(length, length, _BB_DIR_USR_BIN, _BB_SUID_NEVER, length))
194USE_LESS(APPLET(less, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 194USE_LESS(APPLET(less, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
195USE_SETARCH(APPLET_NOUSAGE(linux32, setarch, _BB_DIR_BIN, _BB_SUID_NEVER)) 195USE_SETARCH(APPLET_NOUSAGE(linux32, setarch, _BB_DIR_BIN, _BB_SUID_NEVER))
196USE_SETARCH(APPLET_NOUSAGE(linux64, setarch, _BB_DIR_BIN, _BB_SUID_NEVER)) 196USE_SETARCH(APPLET_NOUSAGE(linux64, setarch, _BB_DIR_BIN, _BB_SUID_NEVER))
@@ -201,7 +201,7 @@ USE_LOADFONT(APPLET(loadfont, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
201USE_LOADKMAP(APPLET(loadkmap, _BB_DIR_SBIN, _BB_SUID_NEVER)) 201USE_LOADKMAP(APPLET(loadkmap, _BB_DIR_SBIN, _BB_SUID_NEVER))
202USE_LOGGER(APPLET(logger, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 202USE_LOGGER(APPLET(logger, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
203USE_LOGIN(APPLET(login, _BB_DIR_BIN, _BB_SUID_ALWAYS)) 203USE_LOGIN(APPLET(login, _BB_DIR_BIN, _BB_SUID_ALWAYS))
204USE_LOGNAME(APPLET(logname, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 204USE_LOGNAME(APPLET_NOFORK(logname, logname, _BB_DIR_USR_BIN, _BB_SUID_NEVER, logname))
205USE_LOGREAD(APPLET(logread, _BB_DIR_SBIN, _BB_SUID_NEVER)) 205USE_LOGREAD(APPLET(logread, _BB_DIR_SBIN, _BB_SUID_NEVER))
206USE_LOSETUP(APPLET(losetup, _BB_DIR_SBIN, _BB_SUID_NEVER)) 206USE_LOSETUP(APPLET(losetup, _BB_DIR_SBIN, _BB_SUID_NEVER))
207USE_LS(APPLET_NOEXEC(ls, ls, _BB_DIR_BIN, _BB_SUID_NEVER, ls)) 207USE_LS(APPLET_NOEXEC(ls, ls, _BB_DIR_BIN, _BB_SUID_NEVER, ls))
@@ -213,7 +213,7 @@ USE_MAKEDEVS(APPLET(makedevs, _BB_DIR_SBIN, _BB_SUID_NEVER))
213USE_MD5SUM(APPLET_ODDNAME(md5sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER, md5sum)) 213USE_MD5SUM(APPLET_ODDNAME(md5sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER, md5sum))
214USE_MDEV(APPLET(mdev, _BB_DIR_SBIN, _BB_SUID_NEVER)) 214USE_MDEV(APPLET(mdev, _BB_DIR_SBIN, _BB_SUID_NEVER))
215USE_MESG(APPLET(mesg, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 215USE_MESG(APPLET(mesg, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
216USE_MKDIR(APPLET_NOEXEC(mkdir, mkdir, _BB_DIR_BIN, _BB_SUID_NEVER, mkdir)) 216USE_MKDIR(APPLET_NOFORK(mkdir, mkdir, _BB_DIR_BIN, _BB_SUID_NEVER, mkdir))
217//USE_MKE2FS(APPLET(mke2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) 217//USE_MKE2FS(APPLET(mke2fs, _BB_DIR_SBIN, _BB_SUID_NEVER))
218USE_MKFIFO(APPLET(mkfifo, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 218USE_MKFIFO(APPLET(mkfifo, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
219//USE_MKE2FS(APPLET_NOUSAGE(mkfs.ext2, mke2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) 219//USE_MKE2FS(APPLET_NOUSAGE(mkfs.ext2, mke2fs, _BB_DIR_SBIN, _BB_SUID_NEVER))
@@ -249,7 +249,7 @@ USE_HALT(APPLET_ODDNAME(poweroff, halt, _BB_DIR_SBIN, _BB_SUID_NEVER, poweroff))
249USE_PRINTENV(APPLET(printenv, _BB_DIR_BIN, _BB_SUID_NEVER)) 249USE_PRINTENV(APPLET(printenv, _BB_DIR_BIN, _BB_SUID_NEVER))
250USE_PRINTF(APPLET(printf, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 250USE_PRINTF(APPLET(printf, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
251USE_PS(APPLET(ps, _BB_DIR_BIN, _BB_SUID_NEVER)) 251USE_PS(APPLET(ps, _BB_DIR_BIN, _BB_SUID_NEVER))
252USE_PWD(APPLET(pwd, _BB_DIR_BIN, _BB_SUID_NEVER)) 252USE_PWD(APPLET_NOFORK(pwd, pwd, _BB_DIR_BIN, _BB_SUID_NEVER, pwd))
253USE_RAIDAUTORUN(APPLET(raidautorun, _BB_DIR_SBIN, _BB_SUID_NEVER)) 253USE_RAIDAUTORUN(APPLET(raidautorun, _BB_DIR_SBIN, _BB_SUID_NEVER))
254USE_RDATE(APPLET(rdate, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) 254USE_RDATE(APPLET(rdate, _BB_DIR_USR_SBIN, _BB_SUID_NEVER))
255USE_READAHEAD(APPLET(readahead, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 255USE_READAHEAD(APPLET(readahead, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
@@ -260,8 +260,8 @@ USE_HALT(APPLET_ODDNAME(reboot, halt, _BB_DIR_SBIN, _BB_SUID_NEVER, reboot))
260USE_RENICE(APPLET(renice, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 260USE_RENICE(APPLET(renice, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
261USE_RESET(APPLET(reset, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 261USE_RESET(APPLET(reset, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
262USE_RESIZE(APPLET(resize, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 262USE_RESIZE(APPLET(resize, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
263USE_RM(APPLET_NOEXEC(rm, rm, _BB_DIR_BIN, _BB_SUID_NEVER, rm)) 263USE_RM(APPLET_NOFORK(rm, rm, _BB_DIR_BIN, _BB_SUID_NEVER, rm))
264USE_RMDIR(APPLET(rmdir, _BB_DIR_BIN, _BB_SUID_NEVER)) 264USE_RMDIR(APPLET_NOFORK(rmdir, rmdir, _BB_DIR_BIN, _BB_SUID_NEVER, rmdir))
265USE_RMMOD(APPLET(rmmod, _BB_DIR_SBIN, _BB_SUID_NEVER)) 265USE_RMMOD(APPLET(rmmod, _BB_DIR_SBIN, _BB_SUID_NEVER))
266USE_ROUTE(APPLET(route, _BB_DIR_SBIN, _BB_SUID_NEVER)) 266USE_ROUTE(APPLET(route, _BB_DIR_SBIN, _BB_SUID_NEVER))
267USE_RPM(APPLET(rpm, _BB_DIR_BIN, _BB_SUID_NEVER)) 267USE_RPM(APPLET(rpm, _BB_DIR_BIN, _BB_SUID_NEVER))
@@ -274,7 +274,7 @@ USE_RUNSVDIR(APPLET(runsvdir, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
274USE_RX(APPLET(rx, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 274USE_RX(APPLET(rx, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
275USE_SELINUXENABLED(APPLET(selinuxenabled, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) 275USE_SELINUXENABLED(APPLET(selinuxenabled, _BB_DIR_USR_SBIN, _BB_SUID_NEVER))
276USE_SED(APPLET(sed, _BB_DIR_BIN, _BB_SUID_NEVER)) 276USE_SED(APPLET(sed, _BB_DIR_BIN, _BB_SUID_NEVER))
277USE_SEQ(APPLET(seq, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 277USE_SEQ(APPLET_NOFORK(seq, seq, _BB_DIR_USR_BIN, _BB_SUID_NEVER, seq))
278USE_SETARCH(APPLET(setarch, _BB_DIR_BIN, _BB_SUID_NEVER)) 278USE_SETARCH(APPLET(setarch, _BB_DIR_BIN, _BB_SUID_NEVER))
279USE_SETCONSOLE(APPLET(setconsole, _BB_DIR_SBIN, _BB_SUID_NEVER)) 279USE_SETCONSOLE(APPLET(setconsole, _BB_DIR_SBIN, _BB_SUID_NEVER))
280USE_SETENFORCE(APPLET(setenforce, _BB_DIR_USR_SBIN, _BB_SUID_NEVER)) 280USE_SETENFORCE(APPLET(setenforce, _BB_DIR_USR_SBIN, _BB_SUID_NEVER))
@@ -287,7 +287,7 @@ USE_FEATURE_SH_IS_HUSH(APPLET_NOUSAGE(sh, hush, _BB_DIR_BIN, _BB_SUID_NEVER))
287USE_FEATURE_SH_IS_LASH(APPLET_NOUSAGE(sh, lash, _BB_DIR_BIN, _BB_SUID_NEVER)) 287USE_FEATURE_SH_IS_LASH(APPLET_NOUSAGE(sh, lash, _BB_DIR_BIN, _BB_SUID_NEVER))
288USE_FEATURE_SH_IS_MSH(APPLET_NOUSAGE(sh, msh, _BB_DIR_BIN, _BB_SUID_NEVER)) 288USE_FEATURE_SH_IS_MSH(APPLET_NOUSAGE(sh, msh, _BB_DIR_BIN, _BB_SUID_NEVER))
289USE_SHA1SUM(APPLET_ODDNAME(sha1sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER, sha1sum)) 289USE_SHA1SUM(APPLET_ODDNAME(sha1sum, md5_sha1_sum, _BB_DIR_USR_BIN, _BB_SUID_NEVER, sha1sum))
290USE_SLEEP(APPLET(sleep, _BB_DIR_BIN, _BB_SUID_NEVER)) 290USE_SLEEP(APPLET_NOFORK(sleep, sleep, _BB_DIR_BIN, _BB_SUID_NEVER, sleep))
291USE_SOFTLIMIT(APPLET_ODDNAME(softlimit, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, softlimit)) 291USE_SOFTLIMIT(APPLET_ODDNAME(softlimit, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, softlimit))
292USE_SORT(APPLET_NOEXEC(sort, sort, _BB_DIR_USR_BIN, _BB_SUID_NEVER, sort)) 292USE_SORT(APPLET_NOEXEC(sort, sort, _BB_DIR_USR_BIN, _BB_SUID_NEVER, sort))
293USE_SPLIT(APPLET(split, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 293USE_SPLIT(APPLET(split, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
@@ -303,7 +303,7 @@ USE_SVLOGD(APPLET(svlogd, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
303USE_SWAPONOFF(APPLET_ODDNAME(swapoff, swap_on_off, _BB_DIR_SBIN, _BB_SUID_NEVER,swapoff)) 303USE_SWAPONOFF(APPLET_ODDNAME(swapoff, swap_on_off, _BB_DIR_SBIN, _BB_SUID_NEVER,swapoff))
304USE_SWAPONOFF(APPLET_ODDNAME(swapon, swap_on_off, _BB_DIR_SBIN, _BB_SUID_NEVER, swapon)) 304USE_SWAPONOFF(APPLET_ODDNAME(swapon, swap_on_off, _BB_DIR_SBIN, _BB_SUID_NEVER, swapon))
305USE_SWITCH_ROOT(APPLET(switch_root, _BB_DIR_SBIN, _BB_SUID_NEVER)) 305USE_SWITCH_ROOT(APPLET(switch_root, _BB_DIR_SBIN, _BB_SUID_NEVER))
306USE_SYNC(APPLET(sync, _BB_DIR_BIN, _BB_SUID_NEVER)) 306USE_SYNC(APPLET_NOFORK(sync, sync, _BB_DIR_BIN, _BB_SUID_NEVER, sync))
307USE_BB_SYSCTL(APPLET(sysctl, _BB_DIR_SBIN, _BB_SUID_NEVER)) 307USE_BB_SYSCTL(APPLET(sysctl, _BB_DIR_SBIN, _BB_SUID_NEVER))
308USE_SYSLOGD(APPLET(syslogd, _BB_DIR_SBIN, _BB_SUID_NEVER)) 308USE_SYSLOGD(APPLET(syslogd, _BB_DIR_SBIN, _BB_SUID_NEVER))
309USE_TAIL(APPLET(tail, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 309USE_TAIL(APPLET(tail, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
@@ -322,7 +322,7 @@ USE_TOP(APPLET(top, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
322USE_TOUCH(APPLET_NOFORK(touch, touch, _BB_DIR_BIN, _BB_SUID_NEVER, touch)) 322USE_TOUCH(APPLET_NOFORK(touch, touch, _BB_DIR_BIN, _BB_SUID_NEVER, touch))
323USE_TR(APPLET(tr, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 323USE_TR(APPLET(tr, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
324USE_TRACEROUTE(APPLET(traceroute, _BB_DIR_USR_BIN, _BB_SUID_MAYBE)) 324USE_TRACEROUTE(APPLET(traceroute, _BB_DIR_USR_BIN, _BB_SUID_MAYBE))
325USE_TRUE(APPLET(true, _BB_DIR_BIN, _BB_SUID_NEVER)) 325USE_TRUE(APPLET_NOFORK(true, true, _BB_DIR_BIN, _BB_SUID_NEVER, true))
326USE_TTY(APPLET(tty, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 326USE_TTY(APPLET(tty, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
327//USE_TUNE2FS(APPLET(tune2fs, _BB_DIR_SBIN, _BB_SUID_NEVER)) 327//USE_TUNE2FS(APPLET(tune2fs, _BB_DIR_SBIN, _BB_SUID_NEVER))
328USE_APP_UDHCPC(APPLET(udhcpc, _BB_DIR_SBIN, _BB_SUID_NEVER)) 328USE_APP_UDHCPC(APPLET(udhcpc, _BB_DIR_SBIN, _BB_SUID_NEVER))
@@ -336,7 +336,7 @@ USE_UNIX2DOS(APPLET_ODDNAME(unix2dos, dos2unix, _BB_DIR_USR_BIN, _BB_SUID_NEVER,
336USE_UNLZMA(APPLET(unlzma, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 336USE_UNLZMA(APPLET(unlzma, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
337USE_UNZIP(APPLET(unzip, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 337USE_UNZIP(APPLET(unzip, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
338USE_UPTIME(APPLET(uptime, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 338USE_UPTIME(APPLET(uptime, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
339USE_USLEEP(APPLET(usleep, _BB_DIR_BIN, _BB_SUID_NEVER)) 339USE_USLEEP(APPLET_NOFORK(usleep, usleep, _BB_DIR_BIN, _BB_SUID_NEVER, usleep))
340USE_UUDECODE(APPLET(uudecode, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 340USE_UUDECODE(APPLET(uudecode, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
341USE_UUENCODE(APPLET(uuencode, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 341USE_UUENCODE(APPLET(uuencode, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
342USE_VCONFIG(APPLET(vconfig, _BB_DIR_SBIN, _BB_SUID_NEVER)) 342USE_VCONFIG(APPLET(vconfig, _BB_DIR_SBIN, _BB_SUID_NEVER))
@@ -348,9 +348,9 @@ USE_WC(APPLET(wc, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
348USE_WGET(APPLET(wget, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 348USE_WGET(APPLET(wget, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
349USE_WHICH(APPLET(which, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 349USE_WHICH(APPLET(which, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
350USE_WHO(APPLET(who, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 350USE_WHO(APPLET(who, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
351USE_WHOAMI(APPLET(whoami, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 351USE_WHOAMI(APPLET_NOFORK(whoami, whoami, _BB_DIR_USR_BIN, _BB_SUID_NEVER, whoami))
352USE_XARGS(APPLET_NOEXEC(xargs, xargs, _BB_DIR_USR_BIN, _BB_SUID_NEVER, xargs)) 352USE_XARGS(APPLET_NOEXEC(xargs, xargs, _BB_DIR_USR_BIN, _BB_SUID_NEVER, xargs))
353USE_YES(APPLET(yes, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) 353USE_YES(APPLET_NOFORK(yes, yes, _BB_DIR_USR_BIN, _BB_SUID_NEVER, yes))
354USE_GUNZIP(APPLET_ODDNAME(zcat, gunzip, _BB_DIR_BIN, _BB_SUID_NEVER, zcat)) 354USE_GUNZIP(APPLET_ODDNAME(zcat, gunzip, _BB_DIR_BIN, _BB_SUID_NEVER, zcat))
355USE_ZCIP(APPLET(zcip, _BB_DIR_SBIN, _BB_SUID_NEVER)) 355USE_ZCIP(APPLET(zcip, _BB_DIR_SBIN, _BB_SUID_NEVER))
356 356
diff --git a/libbb/copyfd.c b/libbb/copyfd.c
index 805b80187..e0596d5f6 100644
--- a/libbb/copyfd.c
+++ b/libbb/copyfd.c
@@ -7,19 +7,15 @@
7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
8 */ 8 */
9 9
10#include <errno.h>
11#include <stdlib.h>
12#include <string.h>
13#include <unistd.h>
14
15#include "libbb.h" 10#include "libbb.h"
16 11
17
18#if BUFSIZ < 4096 12#if BUFSIZ < 4096
19#undef BUFSIZ 13#undef BUFSIZ
20#define BUFSIZ 4096 14#define BUFSIZ 4096
21#endif 15#endif
22 16
17/* Used by NOFORK applets (e.g. cat) - must be very careful
18 * when calling xfuncs, allocating memory, with signals, termios, etc... */
23 19
24static off_t bb_full_fd_action(int src_fd, int dst_fd, off_t size) 20static off_t bb_full_fd_action(int src_fd, int dst_fd, off_t size)
25{ 21{
@@ -27,7 +23,8 @@ static off_t bb_full_fd_action(int src_fd, int dst_fd, off_t size)
27 off_t total = 0; 23 off_t total = 0;
28 RESERVE_CONFIG_BUFFER(buffer, BUFSIZ); 24 RESERVE_CONFIG_BUFFER(buffer, BUFSIZ);
29 25
30 if (src_fd < 0) goto out; 26 if (src_fd < 0)
27 goto out;
31 28
32 if (!size) { 29 if (!size) {
33 size = BUFSIZ; 30 size = BUFSIZ;
diff --git a/libbb/fflush_stdout_and_exit.c b/libbb/fflush_stdout_and_exit.c
index 6f44770c6..ae68222b4 100644
--- a/libbb/fflush_stdout_and_exit.c
+++ b/libbb/fflush_stdout_and_exit.c
@@ -13,6 +13,10 @@
13 13
14#include "libbb.h" 14#include "libbb.h"
15 15
16// TODO: make it safe to call from NOFORK applets
17// Currently, it can exit(0). Even if it is made to do longjmp trick
18// (see sleep_and_die internals), zero cannot be passed thru this way!
19
16void fflush_stdout_and_exit(int retval) 20void fflush_stdout_and_exit(int retval)
17{ 21{
18 if (fflush(stdout)) 22 if (fflush(stdout))
diff --git a/libbb/make_directory.c b/libbb/make_directory.c
index fbec4e20e..d540ad133 100644
--- a/libbb/make_directory.c
+++ b/libbb/make_directory.c
@@ -22,11 +22,10 @@
22 * val. Otherwise, pass -1 to get default permissions. 22 * val. Otherwise, pass -1 to get default permissions.
23 */ 23 */
24 24
25#include <errno.h>
26#include <unistd.h>
27#include <sys/stat.h>
28#include "libbb.h" 25#include "libbb.h"
29 26
27/* This function is used from NOFORK applets. It must not allocate anything */
28
30int bb_make_directory (char *path, long mode, int flags) 29int bb_make_directory (char *path, long mode, int flags)
31{ 30{
32 mode_t mask; 31 mode_t mask;
diff --git a/libbb/parse_mode.c b/libbb/parse_mode.c
index 3ab4eb6fc..a31bd4bfd 100644
--- a/libbb/parse_mode.c
+++ b/libbb/parse_mode.c
@@ -11,6 +11,8 @@
11 11
12#include "libbb.h" 12#include "libbb.h"
13 13
14/* This function is used from NOFORK applets. It must not allocate anything */
15
14#define FILEMODEBITS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) 16#define FILEMODEBITS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
15 17
16int bb_parse_mode(const char *s, mode_t *current_mode) 18int bb_parse_mode(const char *s, mode_t *current_mode)
diff --git a/libbb/remove_file.c b/libbb/remove_file.c
index 3aaaef8c7..3edc91dae 100644
--- a/libbb/remove_file.c
+++ b/libbb/remove_file.c
@@ -9,6 +9,8 @@
9 9
10#include "libbb.h" 10#include "libbb.h"
11 11
12/* Used from NOFORK applets. Must not allocate anything */
13
12int remove_file(const char *path, int flags) 14int remove_file(const char *path, int flags)
13{ 15{
14 struct stat path_stat; 16 struct stat path_stat;
diff --git a/util-linux/hexdump.c b/util-linux/hexdump.c
index cddd185e2..85a449038 100644
--- a/util-linux/hexdump.c
+++ b/util-linux/hexdump.c
@@ -9,10 +9,13 @@
9 * Licensed under GPLv2 or later, see file License in this tarball for details. 9 * Licensed under GPLv2 or later, see file License in this tarball for details.
10 */ 10 */
11 11
12#include "busybox.h"
13#include <getopt.h> 12#include <getopt.h>
13#include "busybox.h"
14#include "dump.h" 14#include "dump.h"
15 15
16/* This is a NOEXEC applet. Be very careful! */
17
18
16static void bb_dump_addfile(char *name) 19static void bb_dump_addfile(char *name)
17{ 20{
18 char *p; 21 char *p;
@@ -45,10 +48,10 @@ static const char add_first[] = "\"%07.7_Ax\n\"";
45static const char hexdump_opts[] = "bcdoxCe:f:n:s:v"; 48static const char hexdump_opts[] = "bcdoxCe:f:n:s:v";
46 49
47static const struct suffix_mult suffixes[] = { 50static const struct suffix_mult suffixes[] = {
48 {"b", 512 }, 51 { "b", 512 },
49 {"k", 1024 }, 52 { "k", 1024 },
50 {"m", 1024*1024 }, 53 { "m", 1024*1024 },
51 {NULL, 0 } 54 { NULL, 0 }
52}; 55};
53 56
54int hexdump_main(int argc, char **argv); 57int hexdump_main(int argc, char **argv);