1 diff -urpN busybox-1.12.1/coreutils/env.c busybox-1.12.1-standalone/coreutils/env.c
2 --- busybox-1.12.1/coreutils/env.c 2008-09-28 20:04:18.000000000 +0200
3 +++ busybox-1.12.1-standalone/coreutils/env.c 2008-10-20 10:21:54.000000000 +0200
5 * - use xfunc_error_retval
8 +/* This is a NOEXEC applet. Be very careful! */
12 #if ENABLE_FEATURE_ENV_LONG_OPTIONS
13 @@ -119,5 +121,3 @@ int env_main(int argc UNUSED_PARAM, char
14 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
19 diff -urpN busybox-1.12.1/include/applets.h busybox-1.12.1-standalone/include/applets.h
20 --- busybox-1.12.1/include/applets.h 2008-09-28 20:04:26.000000000 +0200
21 +++ busybox-1.12.1-standalone/include/applets.h 2008-10-20 10:21:54.000000000 +0200
22 @@ -136,7 +136,7 @@ USE_ECHO(APPLET_NOFORK(echo, echo, _BB_D
23 USE_ED(APPLET(ed, _BB_DIR_BIN, _BB_SUID_NEVER))
24 USE_FEATURE_GREP_EGREP_ALIAS(APPLET_ODDNAME(egrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER, egrep))
25 USE_EJECT(APPLET(eject, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
26 -USE_ENV(APPLET(env, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
27 +USE_ENV(APPLET_NOEXEC(env, env, _BB_DIR_USR_BIN, _BB_SUID_NEVER, env))
28 USE_ENVDIR(APPLET_ODDNAME(envdir, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, envdir))
29 USE_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, envuidgid))
30 USE_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, _BB_DIR_USR_BIN, _BB_SUID_NEVER, ether_wake))
31 @@ -171,7 +171,7 @@ USE_GREP(APPLET(grep, _BB_DIR_BIN, _BB_S
32 USE_GUNZIP(APPLET(gunzip, _BB_DIR_BIN, _BB_SUID_NEVER))
33 USE_GZIP(APPLET(gzip, _BB_DIR_BIN, _BB_SUID_NEVER))
34 USE_HALT(APPLET(halt, _BB_DIR_SBIN, _BB_SUID_NEVER))
35 -USE_HD(APPLET_ODDNAME(hd, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hd))
36 +USE_HD(APPLET_NOEXEC(hd, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hd))
37 USE_HDPARM(APPLET(hdparm, _BB_DIR_SBIN, _BB_SUID_NEVER))
38 USE_HEAD(APPLET(head, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
39 USE_HEXDUMP(APPLET_NOEXEC(hexdump, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hexdump))
40 diff -urpN busybox-1.12.1/libbb/getopt32.c busybox-1.12.1-standalone/libbb/getopt32.c
41 --- busybox-1.12.1/libbb/getopt32.c 2008-09-28 20:04:20.000000000 +0200
42 +++ busybox-1.12.1-standalone/libbb/getopt32.c 2008-10-20 10:21:34.000000000 +0200
43 @@ -515,28 +515,6 @@ getopt32(char **argv, const char *applet
47 - /* In case getopt32 was already called:
48 - * reset the libc getopt() function, which keeps internal state.
50 - * BSD-derived getopt() functions require that optind be set to 1 in
51 - * order to reset getopt() state. This used to be generally accepted
52 - * way of resetting getopt(). However, glibc's getopt()
53 - * has additional getopt() state beyond optind, and requires that
54 - * optind be set to zero to reset its state. So the unfortunate state of
55 - * affairs is that BSD-derived versions of getopt() misbehave if
56 - * optind is set to 0 in order to reset getopt(), and glibc's getopt()
57 - * will core dump if optind is set 1 in order to reset getopt().
59 - * More modern versions of BSD require that optreset be set to 1 in
60 - * order to reset getopt(). Sigh. Standards, anyone?
64 -#else /* BSD style */
68 - /* optarg = NULL; opterr = 0; optopt = 0; - do we need this?? */
71 /* Note: just "getopt() <= 0" will not work well for
72 diff -urpN busybox-1.12.1/libbb/vfork_daemon_rexec.c busybox-1.12.1-standalone/libbb/vfork_daemon_rexec.c
73 --- busybox-1.12.1/libbb/vfork_daemon_rexec.c 2008-09-28 20:04:20.000000000 +0200
74 +++ busybox-1.12.1-standalone/libbb/vfork_daemon_rexec.c 2008-10-20 10:21:34.000000000 +0200
75 @@ -125,6 +125,7 @@ int FAST_FUNC run_nofork_applet_prime(st
78 applet_name = APPLET_NAME(applet_no);
80 xfunc_error_retval = EXIT_FAILURE;
82 /* Special flag for xfunc_die(). If xfunc will "die"
83 @@ -132,7 +133,30 @@ int FAST_FUNC run_nofork_applet_prime(st
84 * die_sleep and longjmp here instead. */
87 - /* option_mask32 = 0; - not needed */
88 + /* In case getopt() or getopt32() was already called:
89 + * reset the libc getopt() function, which keeps internal state.
91 + * BSD-derived getopt() functions require that optind be set to 1 in
92 + * order to reset getopt() state. This used to be generally accepted
93 + * way of resetting getopt(). However, glibc's getopt()
94 + * has additional getopt() state beyond optind, and requires that
95 + * optind be set to zero to reset its state. So the unfortunate state of
96 + * affairs is that BSD-derived versions of getopt() misbehave if
97 + * optind is set to 0 in order to reset getopt(), and glibc's getopt()
98 + * will core dump if optind is set 1 in order to reset getopt().
100 + * More modern versions of BSD require that optreset be set to 1 in
101 + * order to reset getopt(). Sigh. Standards, anyone?
105 +#else /* BSD style */
107 + /* optreset = 1; */
109 + /* optarg = NULL; opterr = 1; optopt = 63; - do we need this too? */
110 + /* (values above are what they initialized to in glibc and uclibc) */
111 + /* option_mask32 = 0; - not needed, no applet depends on it being 0 */
115 @@ -161,8 +185,16 @@ int FAST_FUNC run_nofork_applet_prime(st
119 - /* Restoring globals */
120 + /* Restoring some globals */
121 restore_nofork_data(old);
123 + /* Other globals can be simply reset to defaults */
126 +#else /* BSD style */
130 return rc & 0xff; /* don't confuse people with "exitcodes" >255 */
133 diff -urpN busybox-1.12.1/shell/ash.c busybox-1.12.1-standalone/shell/ash.c
134 --- busybox-1.12.1/shell/ash.c 2008-09-28 20:04:18.000000000 +0200
135 +++ busybox-1.12.1-standalone/shell/ash.c 2008-10-20 10:21:54.000000000 +0200
136 @@ -6964,8 +6964,11 @@ tryexec(USE_FEATURE_SH_STANDALONE(int ap
138 #if ENABLE_FEATURE_SH_STANDALONE
139 if (applet_no >= 0) {
140 - if (APPLET_IS_NOEXEC(applet_no))
141 + if (APPLET_IS_NOEXEC(applet_no)) {
144 run_applet_no_and_exit(applet_no, argv);
146 /* re-exec ourselves with the new arguments */
147 execve(bb_busybox_exec_path, argv, envp);
148 /* If they called chroot or otherwise made the binary no longer
149 @@ -12014,7 +12017,7 @@ exportcmd(int argc UNUSED_PARAM, char **
153 - int flag = argv[0][0] == 'r'? VREADONLY : VEXPORT;
154 + int flag = argv[0][0] == 'r' ? VREADONLY : VEXPORT;
156 if (nextopt("p") != 'p') {
158 diff -urpN busybox-1.12.1/util-linux/getopt.c busybox-1.12.1-standalone/util-linux/getopt.c
159 --- busybox-1.12.1/util-linux/getopt.c 2008-09-28 20:04:30.000000000 +0200
160 +++ busybox-1.12.1-standalone/util-linux/getopt.c 2008-10-20 10:21:34.000000000 +0200
161 @@ -142,7 +142,8 @@ static const char *normalize(const char
162 * Other settings are found in global variables.
164 #if !ENABLE_GETOPT_LONG
165 -#define generate_output(argv,argc,optstr,longopts) generate_output(argv,argc,optstr)
166 +#define generate_output(argv,argc,optstr,longopts) \
167 + generate_output(argv,argc,optstr)
169 static int generate_output(char **argv, int argc, const char *optstr, const struct option *longopts)
171 @@ -156,14 +157,6 @@ static int generate_output(char **argv,
172 if (quiet_errors) /* No error reporting from getopt(3) */
175 - /* Reset getopt(3) (see libbb/getopt32.c for long rant) */
178 -#else /* BSD style */
180 - /* optreset = 1; */
185 #if ENABLE_GETOPT_LONG