diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | coreutils/basename.c | 2 | ||||
-rw-r--r-- | coreutils/env.c | 4 | ||||
-rw-r--r-- | editors/vi.c | 16 | ||||
-rw-r--r-- | findutils/grep.c | 14 | ||||
-rw-r--r-- | include/applets.h | 4 | ||||
-rw-r--r-- | libbb/getopt32.c | 22 | ||||
-rw-r--r-- | libbb/lineedit.c | 3 | ||||
-rw-r--r-- | libbb/setup_environment.c | 14 | ||||
-rw-r--r-- | libbb/vfork_daemon_rexec.c | 36 | ||||
-rw-r--r-- | modutils/modprobe.c | 8 | ||||
-rw-r--r-- | shell/ash.c | 7 | ||||
-rw-r--r-- | util-linux/getopt.c | 11 |
13 files changed, 78 insertions, 65 deletions
@@ -1,6 +1,6 @@ | |||
1 | VERSION = 1 | 1 | VERSION = 1 |
2 | PATCHLEVEL = 12 | 2 | PATCHLEVEL = 12 |
3 | SUBLEVEL = 1 | 3 | SUBLEVEL = 2 |
4 | EXTRAVERSION = | 4 | EXTRAVERSION = |
5 | NAME = Unnamed | 5 | NAME = Unnamed |
6 | 6 | ||
diff --git a/coreutils/basename.c b/coreutils/basename.c index a3085ede3..8a05e92e5 100644 --- a/coreutils/basename.c +++ b/coreutils/basename.c | |||
@@ -48,5 +48,5 @@ int basename_main(int argc, char **argv) | |||
48 | 48 | ||
49 | /* puts(s) will do, but we can do without stdio this way: */ | 49 | /* puts(s) will do, but we can do without stdio this way: */ |
50 | s[m++] = '\n'; | 50 | s[m++] = '\n'; |
51 | return full_write(STDOUT_FILENO, s, m) == (ssize_t)m; | 51 | return full_write(STDOUT_FILENO, s, m) != (ssize_t)m; |
52 | } | 52 | } |
diff --git a/coreutils/env.c b/coreutils/env.c index 66199e8d6..2f8c8b71d 100644 --- a/coreutils/env.c +++ b/coreutils/env.c | |||
@@ -29,6 +29,8 @@ | |||
29 | * - use xfunc_error_retval | 29 | * - use xfunc_error_retval |
30 | */ | 30 | */ |
31 | 31 | ||
32 | /* This is a NOEXEC applet. Be very careful! */ | ||
33 | |||
32 | #include "libbb.h" | 34 | #include "libbb.h" |
33 | 35 | ||
34 | #if ENABLE_FEATURE_ENV_LONG_OPTIONS | 36 | #if ENABLE_FEATURE_ENV_LONG_OPTIONS |
@@ -119,5 +121,3 @@ int env_main(int argc UNUSED_PARAM, char **argv) | |||
119 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 121 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
120 | * SUCH DAMAGE. | 122 | * SUCH DAMAGE. |
121 | */ | 123 | */ |
122 | |||
123 | |||
diff --git a/editors/vi.c b/editors/vi.c index 02bdbb37b..4accfdbb1 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -291,6 +291,8 @@ struct globals { | |||
291 | #define INIT_G() do { \ | 291 | #define INIT_G() do { \ |
292 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ | 292 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
293 | last_file_modified = -1; \ | 293 | last_file_modified = -1; \ |
294 | /* "" but has space for 2 chars */ \ | ||
295 | USE_FEATURE_VI_SEARCH(last_search_pattern = xzalloc(2);) \ | ||
294 | } while (0) | 296 | } while (0) |
295 | 297 | ||
296 | 298 | ||
@@ -2974,7 +2976,7 @@ static void do_cmd(char c) | |||
2974 | const char *msg = msg; // for compiler | 2976 | const char *msg = msg; // for compiler |
2975 | char c1, *p, *q, *save_dot; | 2977 | char c1, *p, *q, *save_dot; |
2976 | char buf[12]; | 2978 | char buf[12]; |
2977 | int dir = dir; // for compiler | 2979 | int dir; |
2978 | int cnt, i, j; | 2980 | int cnt, i, j; |
2979 | 2981 | ||
2980 | // c1 = c; // quiet the compiler | 2982 | // c1 = c; // quiet the compiler |
@@ -3316,7 +3318,7 @@ static void do_cmd(char c) | |||
3316 | q = get_input_line(buf); // get input line- use "status line" | 3318 | q = get_input_line(buf); // get input line- use "status line" |
3317 | if (q[0] && !q[1]) { | 3319 | if (q[0] && !q[1]) { |
3318 | if (last_search_pattern[0]) | 3320 | if (last_search_pattern[0]) |
3319 | last_search_pattern[0] = c; | 3321 | last_search_pattern[0] = c; |
3320 | goto dc3; // if no pat re-use old pat | 3322 | goto dc3; // if no pat re-use old pat |
3321 | } | 3323 | } |
3322 | if (q[0]) { // strlen(q) > 1: new pat- save it and find | 3324 | if (q[0]) { // strlen(q) > 1: new pat- save it and find |
@@ -3346,14 +3348,8 @@ static void do_cmd(char c) | |||
3346 | do_cmd(c); | 3348 | do_cmd(c); |
3347 | } // repeat cnt | 3349 | } // repeat cnt |
3348 | dc3: | 3350 | dc3: |
3349 | if (last_search_pattern == 0) { | 3351 | dir = FORWARD; // assume FORWARD search |
3350 | msg = "No previous regular expression"; | 3352 | p = dot + 1; |
3351 | goto dc2; | ||
3352 | } | ||
3353 | if (last_search_pattern[0] == '/') { | ||
3354 | dir = FORWARD; // assume FORWARD search | ||
3355 | p = dot + 1; | ||
3356 | } | ||
3357 | if (last_search_pattern[0] == '?') { | 3353 | if (last_search_pattern[0] == '?') { |
3358 | dir = BACK; | 3354 | dir = BACK; |
3359 | p = dot - 1; | 3355 | p = dot - 1; |
diff --git a/findutils/grep.c b/findutils/grep.c index 9d38ef912..73e74f4b3 100644 --- a/findutils/grep.c +++ b/findutils/grep.c | |||
@@ -363,12 +363,22 @@ static int grep_file(FILE *file) | |||
363 | * (unless -v: -Fov doesnt print anything at all) */ | 363 | * (unless -v: -Fov doesnt print anything at all) */ |
364 | if (found) | 364 | if (found) |
365 | print_line(gl->pattern, strlen(gl->pattern), linenum, ':'); | 365 | print_line(gl->pattern, strlen(gl->pattern), linenum, ':'); |
366 | } else { | 366 | } else while (1) { |
367 | char old = line[gl->matched_range.rm_eo]; | ||
367 | line[gl->matched_range.rm_eo] = '\0'; | 368 | line[gl->matched_range.rm_eo] = '\0'; |
368 | print_line(line + gl->matched_range.rm_so, | 369 | print_line(line + gl->matched_range.rm_so, |
369 | gl->matched_range.rm_eo - gl->matched_range.rm_so, | 370 | gl->matched_range.rm_eo - gl->matched_range.rm_so, |
370 | linenum, ':'); | 371 | linenum, ':'); |
371 | } | 372 | line[gl->matched_range.rm_eo] = old; |
373 | #if !ENABLE_EXTRA_COMPAT | ||
374 | break; | ||
375 | #else | ||
376 | if (re_search(&gl->compiled_regex, line, line_len, | ||
377 | gl->matched_range.rm_eo, line_len - gl->matched_range.rm_eo, | ||
378 | &gl->matched_range) < 0) | ||
379 | break; | ||
380 | #endif | ||
381 | } | ||
372 | } else { | 382 | } else { |
373 | print_line(line, line_len, linenum, ':'); | 383 | print_line(line, line_len, linenum, ':'); |
374 | } | 384 | } |
diff --git a/include/applets.h b/include/applets.h index 46135dccb..0c9930d45 100644 --- a/include/applets.h +++ b/include/applets.h | |||
@@ -136,7 +136,7 @@ USE_ECHO(APPLET_NOFORK(echo, echo, _BB_DIR_BIN, _BB_SUID_NEVER, echo)) | |||
136 | USE_ED(APPLET(ed, _BB_DIR_BIN, _BB_SUID_NEVER)) | 136 | USE_ED(APPLET(ed, _BB_DIR_BIN, _BB_SUID_NEVER)) |
137 | USE_FEATURE_GREP_EGREP_ALIAS(APPLET_ODDNAME(egrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER, egrep)) | 137 | USE_FEATURE_GREP_EGREP_ALIAS(APPLET_ODDNAME(egrep, grep, _BB_DIR_BIN, _BB_SUID_NEVER, egrep)) |
138 | USE_EJECT(APPLET(eject, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 138 | USE_EJECT(APPLET(eject, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
139 | USE_ENV(APPLET(env, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 139 | USE_ENV(APPLET_NOEXEC(env, env, _BB_DIR_USR_BIN, _BB_SUID_NEVER, env)) |
140 | USE_ENVDIR(APPLET_ODDNAME(envdir, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, envdir)) | 140 | USE_ENVDIR(APPLET_ODDNAME(envdir, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, envdir)) |
141 | USE_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, envuidgid)) | 141 | USE_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, _BB_DIR_USR_BIN, _BB_SUID_NEVER, envuidgid)) |
142 | USE_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, _BB_DIR_USR_BIN, _BB_SUID_NEVER, ether_wake)) | 142 | USE_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, _BB_DIR_USR_BIN, _BB_SUID_NEVER, ether_wake)) |
@@ -171,7 +171,7 @@ USE_GREP(APPLET(grep, _BB_DIR_BIN, _BB_SUID_NEVER)) | |||
171 | USE_GUNZIP(APPLET(gunzip, _BB_DIR_BIN, _BB_SUID_NEVER)) | 171 | USE_GUNZIP(APPLET(gunzip, _BB_DIR_BIN, _BB_SUID_NEVER)) |
172 | USE_GZIP(APPLET(gzip, _BB_DIR_BIN, _BB_SUID_NEVER)) | 172 | USE_GZIP(APPLET(gzip, _BB_DIR_BIN, _BB_SUID_NEVER)) |
173 | USE_HALT(APPLET(halt, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 173 | USE_HALT(APPLET(halt, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
174 | USE_HD(APPLET_ODDNAME(hd, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hd)) | 174 | USE_HD(APPLET_NOEXEC(hd, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hd)) |
175 | USE_HDPARM(APPLET(hdparm, _BB_DIR_SBIN, _BB_SUID_NEVER)) | 175 | USE_HDPARM(APPLET(hdparm, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
176 | USE_HEAD(APPLET(head, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) | 176 | USE_HEAD(APPLET(head, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
177 | USE_HEXDUMP(APPLET_NOEXEC(hexdump, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hexdump)) | 177 | USE_HEXDUMP(APPLET_NOEXEC(hexdump, hexdump, _BB_DIR_USR_BIN, _BB_SUID_NEVER, hexdump)) |
diff --git a/libbb/getopt32.c b/libbb/getopt32.c index 8fb99b6cc..ee85181cd 100644 --- a/libbb/getopt32.c +++ b/libbb/getopt32.c | |||
@@ -515,28 +515,6 @@ getopt32(char **argv, const char *applet_opts, ...) | |||
515 | } | 515 | } |
516 | } | 516 | } |
517 | 517 | ||
518 | /* In case getopt32 was already called: | ||
519 | * reset the libc getopt() function, which keeps internal state. | ||
520 | * | ||
521 | * BSD-derived getopt() functions require that optind be set to 1 in | ||
522 | * order to reset getopt() state. This used to be generally accepted | ||
523 | * way of resetting getopt(). However, glibc's getopt() | ||
524 | * has additional getopt() state beyond optind, and requires that | ||
525 | * optind be set to zero to reset its state. So the unfortunate state of | ||
526 | * affairs is that BSD-derived versions of getopt() misbehave if | ||
527 | * optind is set to 0 in order to reset getopt(), and glibc's getopt() | ||
528 | * will core dump if optind is set 1 in order to reset getopt(). | ||
529 | * | ||
530 | * More modern versions of BSD require that optreset be set to 1 in | ||
531 | * order to reset getopt(). Sigh. Standards, anyone? | ||
532 | */ | ||
533 | #ifdef __GLIBC__ | ||
534 | optind = 0; | ||
535 | #else /* BSD style */ | ||
536 | optind = 1; | ||
537 | /* optreset = 1; */ | ||
538 | #endif | ||
539 | /* optarg = NULL; opterr = 0; optopt = 0; - do we need this?? */ | ||
540 | pargv = NULL; | 518 | pargv = NULL; |
541 | 519 | ||
542 | /* Note: just "getopt() <= 0" will not work well for | 520 | /* Note: just "getopt() <= 0" will not work well for |
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index c2c3ea996..1f21866ca 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -1415,7 +1415,8 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li | |||
1415 | if ((state->flags & SAVE_HISTORY) && state->hist_file) | 1415 | if ((state->flags & SAVE_HISTORY) && state->hist_file) |
1416 | load_history(state->hist_file); | 1416 | load_history(state->hist_file); |
1417 | #endif | 1417 | #endif |
1418 | state->cur_history = state->cnt_history; | 1418 | if (state->flags & DO_HISTORY) |
1419 | state->cur_history = state->cnt_history; | ||
1419 | 1420 | ||
1420 | /* prepare before init handlers */ | 1421 | /* prepare before init handlers */ |
1421 | cmdedit_y = 0; /* quasireal y, not true if line > xt*yt */ | 1422 | cmdedit_y = 0; /* quasireal y, not true if line > xt*yt */ |
diff --git a/libbb/setup_environment.c b/libbb/setup_environment.c index 04e333fed..78318ce62 100644 --- a/libbb/setup_environment.c +++ b/libbb/setup_environment.c | |||
@@ -32,16 +32,16 @@ | |||
32 | 32 | ||
33 | void FAST_FUNC setup_environment(const char *shell, int clear_env, int change_env, const struct passwd *pw) | 33 | void FAST_FUNC setup_environment(const char *shell, int clear_env, int change_env, const struct passwd *pw) |
34 | { | 34 | { |
35 | /* Change the current working directory to be the home directory | ||
36 | * of the user */ | ||
37 | if (chdir(pw->pw_dir)) { | ||
38 | xchdir("/"); | ||
39 | bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir); | ||
40 | } | ||
41 | |||
35 | if (clear_env) { | 42 | if (clear_env) { |
36 | const char *term; | 43 | const char *term; |
37 | 44 | ||
38 | /* Change the current working directory to be the home directory | ||
39 | * of the user */ | ||
40 | if (chdir(pw->pw_dir)) { | ||
41 | xchdir("/"); | ||
42 | bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir); | ||
43 | } | ||
44 | |||
45 | /* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH. | 45 | /* Leave TERM unchanged. Set HOME, SHELL, USER, LOGNAME, PATH. |
46 | Unset all other environment variables. */ | 46 | Unset all other environment variables. */ |
47 | term = getenv("TERM"); | 47 | term = getenv("TERM"); |
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c index da0dc03e5..17b373cd1 100644 --- a/libbb/vfork_daemon_rexec.c +++ b/libbb/vfork_daemon_rexec.c | |||
@@ -125,6 +125,7 @@ int FAST_FUNC run_nofork_applet_prime(struct nofork_save_area *old, int applet_n | |||
125 | int rc, argc; | 125 | int rc, argc; |
126 | 126 | ||
127 | applet_name = APPLET_NAME(applet_no); | 127 | applet_name = APPLET_NAME(applet_no); |
128 | |||
128 | xfunc_error_retval = EXIT_FAILURE; | 129 | xfunc_error_retval = EXIT_FAILURE; |
129 | 130 | ||
130 | /* Special flag for xfunc_die(). If xfunc will "die" | 131 | /* Special flag for xfunc_die(). If xfunc will "die" |
@@ -132,7 +133,30 @@ int FAST_FUNC run_nofork_applet_prime(struct nofork_save_area *old, int applet_n | |||
132 | * die_sleep and longjmp here instead. */ | 133 | * die_sleep and longjmp here instead. */ |
133 | die_sleep = -1; | 134 | die_sleep = -1; |
134 | 135 | ||
135 | /* option_mask32 = 0; - not needed */ | 136 | /* In case getopt() or getopt32() was already called: |
137 | * reset the libc getopt() function, which keeps internal state. | ||
138 | * | ||
139 | * BSD-derived getopt() functions require that optind be set to 1 in | ||
140 | * order to reset getopt() state. This used to be generally accepted | ||
141 | * way of resetting getopt(). However, glibc's getopt() | ||
142 | * has additional getopt() state beyond optind, and requires that | ||
143 | * optind be set to zero to reset its state. So the unfortunate state of | ||
144 | * affairs is that BSD-derived versions of getopt() misbehave if | ||
145 | * optind is set to 0 in order to reset getopt(), and glibc's getopt() | ||
146 | * will core dump if optind is set 1 in order to reset getopt(). | ||
147 | * | ||
148 | * More modern versions of BSD require that optreset be set to 1 in | ||
149 | * order to reset getopt(). Sigh. Standards, anyone? | ||
150 | */ | ||
151 | #ifdef __GLIBC__ | ||
152 | optind = 0; | ||
153 | #else /* BSD style */ | ||
154 | optind = 1; | ||
155 | /* optreset = 1; */ | ||
156 | #endif | ||
157 | /* optarg = NULL; opterr = 1; optopt = 63; - do we need this too? */ | ||
158 | /* (values above are what they initialized to in glibc and uclibc) */ | ||
159 | /* option_mask32 = 0; - not needed, no applet depends on it being 0 */ | ||
136 | 160 | ||
137 | argc = 1; | 161 | argc = 1; |
138 | while (argv[argc]) | 162 | while (argv[argc]) |
@@ -161,8 +185,16 @@ int FAST_FUNC run_nofork_applet_prime(struct nofork_save_area *old, int applet_n | |||
161 | rc = 0; | 185 | rc = 0; |
162 | } | 186 | } |
163 | 187 | ||
164 | /* Restoring globals */ | 188 | /* Restoring some globals */ |
165 | restore_nofork_data(old); | 189 | restore_nofork_data(old); |
190 | |||
191 | /* Other globals can be simply reset to defaults */ | ||
192 | #ifdef __GLIBC__ | ||
193 | optind = 0; | ||
194 | #else /* BSD style */ | ||
195 | optind = 1; | ||
196 | #endif | ||
197 | |||
166 | return rc & 0xff; /* don't confuse people with "exitcodes" >255 */ | 198 | return rc & 0xff; /* don't confuse people with "exitcodes" >255 */ |
167 | } | 199 | } |
168 | 200 | ||
diff --git a/modutils/modprobe.c b/modutils/modprobe.c index 412e71d16..8bbc2397c 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c | |||
@@ -263,9 +263,9 @@ static int FAST_FUNC include_conf_dir_act(const char *filename UNUSED_PARAM, | |||
263 | return TRUE; | 263 | return TRUE; |
264 | } | 264 | } |
265 | 265 | ||
266 | static int include_conf_recursive(struct include_conf_t *conf, const char *filename) | 266 | static int include_conf_recursive(struct include_conf_t *conf, const char *filename, int flags) |
267 | { | 267 | { |
268 | return recursive_action(filename, ACTION_RECURSE, | 268 | return recursive_action(filename, ACTION_RECURSE | flags, |
269 | include_conf_file_act, | 269 | include_conf_file_act, |
270 | include_conf_dir_act, | 270 | include_conf_dir_act, |
271 | conf, 1); | 271 | conf, 1); |
@@ -362,7 +362,7 @@ static int FAST_FUNC include_conf_file_act(const char *filename, | |||
362 | char *includefile; | 362 | char *includefile; |
363 | 363 | ||
364 | includefile = skip_whitespace(line_buffer + 8); | 364 | includefile = skip_whitespace(line_buffer + 8); |
365 | include_conf_recursive(conf, includefile); | 365 | include_conf_recursive(conf, includefile, 0); |
366 | } else if (ENABLE_FEATURE_MODPROBE_BLACKLIST && | 366 | } else if (ENABLE_FEATURE_MODPROBE_BLACKLIST && |
367 | (is_conf_command(line_buffer, "blacklist"))) { | 367 | (is_conf_command(line_buffer, "blacklist"))) { |
368 | char *mod; | 368 | char *mod; |
@@ -559,7 +559,7 @@ static struct dep_t *build_dep(void) | |||
559 | if (ENABLE_FEATURE_2_6_MODULES) { | 559 | if (ENABLE_FEATURE_2_6_MODULES) { |
560 | if (include_conf_file(&conf, "/etc/modprobe.conf")) | 560 | if (include_conf_file(&conf, "/etc/modprobe.conf")) |
561 | r = TRUE; | 561 | r = TRUE; |
562 | if (include_conf_recursive(&conf, "/etc/modprobe.d")) | 562 | if (include_conf_recursive(&conf, "/etc/modprobe.d", ACTION_QUIET)) |
563 | r = TRUE; | 563 | r = TRUE; |
564 | } | 564 | } |
565 | if (ENABLE_FEATURE_2_4_MODULES && !r) | 565 | if (ENABLE_FEATURE_2_4_MODULES && !r) |
diff --git a/shell/ash.c b/shell/ash.c index d63acc2c8..492c77edd 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -6964,8 +6964,11 @@ tryexec(USE_FEATURE_SH_STANDALONE(int applet_no,) char *cmd, char **argv, char * | |||
6964 | 6964 | ||
6965 | #if ENABLE_FEATURE_SH_STANDALONE | 6965 | #if ENABLE_FEATURE_SH_STANDALONE |
6966 | if (applet_no >= 0) { | 6966 | if (applet_no >= 0) { |
6967 | if (APPLET_IS_NOEXEC(applet_no)) | 6967 | if (APPLET_IS_NOEXEC(applet_no)) { |
6968 | while (*envp) | ||
6969 | putenv(*envp++); | ||
6968 | run_applet_no_and_exit(applet_no, argv); | 6970 | run_applet_no_and_exit(applet_no, argv); |
6971 | } | ||
6969 | /* re-exec ourselves with the new arguments */ | 6972 | /* re-exec ourselves with the new arguments */ |
6970 | execve(bb_busybox_exec_path, argv, envp); | 6973 | execve(bb_busybox_exec_path, argv, envp); |
6971 | /* If they called chroot or otherwise made the binary no longer | 6974 | /* If they called chroot or otherwise made the binary no longer |
@@ -12014,7 +12017,7 @@ exportcmd(int argc UNUSED_PARAM, char **argv) | |||
12014 | char *name; | 12017 | char *name; |
12015 | const char *p; | 12018 | const char *p; |
12016 | char **aptr; | 12019 | char **aptr; |
12017 | int flag = argv[0][0] == 'r'? VREADONLY : VEXPORT; | 12020 | int flag = argv[0][0] == 'r' ? VREADONLY : VEXPORT; |
12018 | 12021 | ||
12019 | if (nextopt("p") != 'p') { | 12022 | if (nextopt("p") != 'p') { |
12020 | aptr = argptr; | 12023 | aptr = argptr; |
diff --git a/util-linux/getopt.c b/util-linux/getopt.c index 402630385..8b5e46c7b 100644 --- a/util-linux/getopt.c +++ b/util-linux/getopt.c | |||
@@ -142,7 +142,8 @@ static const char *normalize(const char *arg) | |||
142 | * Other settings are found in global variables. | 142 | * Other settings are found in global variables. |
143 | */ | 143 | */ |
144 | #if !ENABLE_GETOPT_LONG | 144 | #if !ENABLE_GETOPT_LONG |
145 | #define generate_output(argv,argc,optstr,longopts) generate_output(argv,argc,optstr) | 145 | #define generate_output(argv,argc,optstr,longopts) \ |
146 | generate_output(argv,argc,optstr) | ||
146 | #endif | 147 | #endif |
147 | static int generate_output(char **argv, int argc, const char *optstr, const struct option *longopts) | 148 | static int generate_output(char **argv, int argc, const char *optstr, const struct option *longopts) |
148 | { | 149 | { |
@@ -156,14 +157,6 @@ static int generate_output(char **argv, int argc, const char *optstr, const stru | |||
156 | if (quiet_errors) /* No error reporting from getopt(3) */ | 157 | if (quiet_errors) /* No error reporting from getopt(3) */ |
157 | opterr = 0; | 158 | opterr = 0; |
158 | 159 | ||
159 | /* Reset getopt(3) (see libbb/getopt32.c for long rant) */ | ||
160 | #ifdef __GLIBC__ | ||
161 | optind = 0; | ||
162 | #else /* BSD style */ | ||
163 | optind = 1; | ||
164 | /* optreset = 1; */ | ||
165 | #endif | ||
166 | |||
167 | while (1) { | 160 | while (1) { |
168 | opt = | 161 | opt = |
169 | #if ENABLE_GETOPT_LONG | 162 | #if ENABLE_GETOPT_LONG |