diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-02-06 01:20:12 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-02-06 01:20:12 +0000 |
commit | 1d76f439da81d3a05f0e0fdde3f81ec56fb20836 (patch) | |
tree | f3e2e2185d092f87843fe4bbc9d1098185a5bdbd | |
parent | cc24419e98853aede7c652edb3c1c79a9865bdda (diff) | |
download | busybox-w32-1d76f439da81d3a05f0e0fdde3f81ec56fb20836.tar.gz busybox-w32-1d76f439da81d3a05f0e0fdde3f81ec56fb20836.tar.bz2 busybox-w32-1d76f439da81d3a05f0e0fdde3f81ec56fb20836.zip |
EXEC_PREFER_APPLETS support by Gabriel L. Somlo <somlo@cmu.edu>
-rw-r--r-- | archival/tar.c | 2 | ||||
-rw-r--r-- | console-tools/openvt.c | 2 | ||||
-rw-r--r-- | coreutils/chroot.c | 2 | ||||
-rw-r--r-- | coreutils/env.c | 2 | ||||
-rw-r--r-- | coreutils/install.c | 2 | ||||
-rw-r--r-- | coreutils/nice.c | 2 | ||||
-rw-r--r-- | coreutils/nohup.c | 2 | ||||
-rw-r--r-- | e2fsprogs/fsck.c | 2 | ||||
-rw-r--r-- | findutils/xargs.c | 2 | ||||
-rw-r--r-- | include/libbb.h | 9 | ||||
-rw-r--r-- | libbb/execable.c | 10 | ||||
-rw-r--r-- | loginutils/adduser.c | 2 | ||||
-rw-r--r-- | loginutils/login.c | 2 | ||||
-rw-r--r-- | miscutils/devfsd.c | 2 | ||||
-rw-r--r-- | miscutils/setsid.c | 2 | ||||
-rw-r--r-- | miscutils/taskset.c | 2 | ||||
-rw-r--r-- | miscutils/time.c | 2 | ||||
-rw-r--r-- | networking/ifupdown.c | 2 | ||||
-rw-r--r-- | networking/nc.c | 2 | ||||
-rw-r--r-- | runit/chpst.c | 10 | ||||
-rw-r--r-- | runit/runsvdir.c | 2 | ||||
-rw-r--r-- | util-linux/setarch.c | 2 |
22 files changed, 39 insertions, 28 deletions
diff --git a/archival/tar.c b/archival/tar.c index 48c4f3f8c..d8e36749e 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -529,7 +529,7 @@ static int writeTarFile(const int tar_fd, const int verboseFlag, | |||
529 | close(gzipStatusPipe[0]); | 529 | close(gzipStatusPipe[0]); |
530 | fcntl(gzipStatusPipe[1], F_SETFD, FD_CLOEXEC); /* close on exec shows success */ | 530 | fcntl(gzipStatusPipe[1], F_SETFD, FD_CLOEXEC); /* close on exec shows success */ |
531 | 531 | ||
532 | execlp(zip_exec, zip_exec, "-f", NULL); | 532 | BB_EXECLP(zip_exec, zip_exec, "-f", NULL); |
533 | vfork_exec_errno = errno; | 533 | vfork_exec_errno = errno; |
534 | 534 | ||
535 | close(gzipStatusPipe[1]); | 535 | close(gzipStatusPipe[1]); |
diff --git a/console-tools/openvt.c b/console-tools/openvt.c index 9296219bd..eb9f49fe2 100644 --- a/console-tools/openvt.c +++ b/console-tools/openvt.c | |||
@@ -36,7 +36,7 @@ int openvt_main(int argc, char **argv) | |||
36 | dup2(fd, STDERR_FILENO); | 36 | dup2(fd, STDERR_FILENO); |
37 | while (fd > 2) close(fd--); | 37 | while (fd > 2) close(fd--); |
38 | 38 | ||
39 | execvp(argv[2], &argv[2]); | 39 | BB_EXECVP(argv[2], &argv[2]); |
40 | _exit(1); | 40 | _exit(1); |
41 | } | 41 | } |
42 | return EXIT_SUCCESS; | 42 | return EXIT_SUCCESS; |
diff --git a/coreutils/chroot.c b/coreutils/chroot.c index 16c743fef..fcd70f21a 100644 --- a/coreutils/chroot.c +++ b/coreutils/chroot.c | |||
@@ -33,6 +33,6 @@ int chroot_main(int argc, char **argv) | |||
33 | argv[1] = (char *) "-i"; | 33 | argv[1] = (char *) "-i"; |
34 | } | 34 | } |
35 | 35 | ||
36 | execvp(*argv, argv); | 36 | BB_EXECVP(*argv, argv); |
37 | bb_perror_msg_and_die("cannot execute %s", *argv); | 37 | bb_perror_msg_and_die("cannot execute %s", *argv); |
38 | } | 38 | } |
diff --git a/coreutils/env.c b/coreutils/env.c index 04279f3e0..7be0c63a5 100644 --- a/coreutils/env.c +++ b/coreutils/env.c | |||
@@ -81,7 +81,7 @@ int env_main(int argc, char** argv) | |||
81 | } | 81 | } |
82 | 82 | ||
83 | if (*argv) { | 83 | if (*argv) { |
84 | execvp(*argv, argv); | 84 | BB_EXECVP(*argv, argv); |
85 | /* SUSv3-mandated exit codes. */ | 85 | /* SUSv3-mandated exit codes. */ |
86 | xfunc_error_retval = (errno == ENOENT) ? 127 : 126; | 86 | xfunc_error_retval = (errno == ENOENT) ? 127 : 126; |
87 | bb_perror_msg_and_die("%s", *argv); | 87 | bb_perror_msg_and_die("%s", *argv); |
diff --git a/coreutils/install.c b/coreutils/install.c index dd73fb693..c105addc5 100644 --- a/coreutils/install.c +++ b/coreutils/install.c | |||
@@ -126,7 +126,7 @@ int install_main(int argc, char **argv) | |||
126 | ret = EXIT_FAILURE; | 126 | ret = EXIT_FAILURE; |
127 | } | 127 | } |
128 | if (flags & OPT_STRIP) { | 128 | if (flags & OPT_STRIP) { |
129 | if (execlp("strip", "strip", dest, NULL) == -1) { | 129 | if (BB_EXECLP("strip", "strip", dest, NULL) == -1) { |
130 | bb_perror_msg("strip"); | 130 | bb_perror_msg("strip"); |
131 | ret = EXIT_FAILURE; | 131 | ret = EXIT_FAILURE; |
132 | } | 132 | } |
diff --git a/coreutils/nice.c b/coreutils/nice.c index b7bff6a52..328531528 100644 --- a/coreutils/nice.c +++ b/coreutils/nice.c | |||
@@ -47,7 +47,7 @@ int nice_main(int argc, char **argv) | |||
47 | } | 47 | } |
48 | } | 48 | } |
49 | 49 | ||
50 | execvp(*argv, argv); /* Now exec the desired program. */ | 50 | BB_EXECVP(*argv, argv); /* Now exec the desired program. */ |
51 | 51 | ||
52 | /* The exec failed... */ | 52 | /* The exec failed... */ |
53 | xfunc_error_retval = (errno == ENOENT) ? 127 : 126; /* SUSv3 */ | 53 | xfunc_error_retval = (errno == ENOENT) ? 127 : 126; /* SUSv3 */ |
diff --git a/coreutils/nohup.c b/coreutils/nohup.c index a9944b7f4..6a6c70e13 100644 --- a/coreutils/nohup.c +++ b/coreutils/nohup.c | |||
@@ -53,7 +53,7 @@ int nohup_main(int argc, char **argv) | |||
53 | close(nullfd); | 53 | close(nullfd); |
54 | signal(SIGHUP, SIG_IGN); | 54 | signal(SIGHUP, SIG_IGN); |
55 | 55 | ||
56 | execvp(argv[1], argv+1); | 56 | BB_EXECVP(argv[1], argv+1); |
57 | if (ENABLE_FEATURE_CLEAN_UP && home) | 57 | if (ENABLE_FEATURE_CLEAN_UP && home) |
58 | free((char*)nohupout); | 58 | free((char*)nohupout); |
59 | bb_perror_msg_and_die("%s", argv[1]); | 59 | bb_perror_msg_and_die("%s", argv[1]); |
diff --git a/e2fsprogs/fsck.c b/e2fsprogs/fsck.c index 9ec31d2a3..ad22fcd7a 100644 --- a/e2fsprogs/fsck.c +++ b/e2fsprogs/fsck.c | |||
@@ -677,7 +677,7 @@ static void execute(const char *type, const char *device, const char *mntpt, | |||
677 | * Use "fsck -s" to avoid... */ | 677 | * Use "fsck -s" to avoid... */ |
678 | close(0); | 678 | close(0); |
679 | } | 679 | } |
680 | execvp(argv[0], argv); | 680 | BB_EXECVP(argv[0], argv); |
681 | bb_perror_msg_and_die("%s", argv[0]); | 681 | bb_perror_msg_and_die("%s", argv[0]); |
682 | } | 682 | } |
683 | } | 683 | } |
diff --git a/findutils/xargs.c b/findutils/xargs.c index c2060f804..44dbcdad0 100644 --- a/findutils/xargs.c +++ b/findutils/xargs.c | |||
@@ -60,7 +60,7 @@ static int xargs_exec(char *const *args) | |||
60 | 60 | ||
61 | if (p == 0) { | 61 | if (p == 0) { |
62 | /* vfork -- child */ | 62 | /* vfork -- child */ |
63 | execvp(args[0], args); | 63 | BB_EXECVP(args[0], args); |
64 | exec_errno = errno; /* set error to shared stack */ | 64 | exec_errno = errno; /* set error to shared stack */ |
65 | _exit(1); | 65 | _exit(1); |
66 | } | 66 | } |
diff --git a/include/libbb.h b/include/libbb.h index 7342f89f6..babb39ba9 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -562,12 +562,13 @@ char *find_execable(const char *filename); | |||
562 | int exists_execable(const char *filename); | 562 | int exists_execable(const char *filename); |
563 | 563 | ||
564 | #ifdef ENABLE_FEATURE_EXEC_PREFER_APPLETS | 564 | #ifdef ENABLE_FEATURE_EXEC_PREFER_APPLETS |
565 | #define BB_EXECVP(prog,cmd) \ | 565 | int bb_execvp(const char *file, char *const argv[]); |
566 | execvp((find_applet_by_name(prog)) ? CONFIG_BUSYBOX_EXEC_PATH : prog, cmd) | 566 | #define BB_EXECVP(prog,cmd) bb_execvp(prog,cmd) |
567 | #define BB_EXECLP(prog,cmd,...) \ | 567 | #define BB_EXECLP(prog,cmd,...) \ |
568 | execlp((find_applet_by_name(prog)) ? CONFIG_BUSYBOX_EXEC_PATH : prog, cmd, __VA_ARGS__) | 568 | execlp((find_applet_by_name(prog)) ? CONFIG_BUSYBOX_EXEC_PATH : prog, \ |
569 | cmd, __VA_ARGS__) | ||
569 | #else | 570 | #else |
570 | #define BB_EXECVP(prog,cmd) execvp(prog,cmd) | 571 | #define BB_EXECVP(prog,cmd) execvp(prog,cmd) |
571 | #define BB_EXECLP(prog,cmd,...) execlp(prog,cmd, __VA_ARGS__) | 572 | #define BB_EXECLP(prog,cmd,...) execlp(prog,cmd, __VA_ARGS__) |
572 | #endif | 573 | #endif |
573 | 574 | ||
diff --git a/libbb/execable.c b/libbb/execable.c index 817c06736..601c7539e 100644 --- a/libbb/execable.c +++ b/libbb/execable.c | |||
@@ -59,3 +59,13 @@ int exists_execable(const char *filename) | |||
59 | } | 59 | } |
60 | return 0; | 60 | return 0; |
61 | } | 61 | } |
62 | |||
63 | #ifdef ENABLE_FEATURE_EXEC_PREFER_APPLETS | ||
64 | /* just like the real execvp, but try to launch an applet named 'file' first | ||
65 | */ | ||
66 | int bb_execvp(const char *file, char *const argv[]) | ||
67 | { | ||
68 | return execvp(find_applet_by_name(file) ? CONFIG_BUSYBOX_EXEC_PATH : file, | ||
69 | argv); | ||
70 | } | ||
71 | #endif | ||
diff --git a/loginutils/adduser.c b/loginutils/adduser.c index 8193aea82..b6d0c62ea 100644 --- a/loginutils/adduser.c +++ b/loginutils/adduser.c | |||
@@ -80,7 +80,7 @@ static void passwd_wrapper(const char *login) ATTRIBUTE_NORETURN; | |||
80 | static void passwd_wrapper(const char *login) | 80 | static void passwd_wrapper(const char *login) |
81 | { | 81 | { |
82 | static const char prog[] = "passwd"; | 82 | static const char prog[] = "passwd"; |
83 | execlp(prog, prog, login, NULL); | 83 | BB_EXECLP(prog, prog, login, NULL); |
84 | bb_error_msg_and_die("failed to execute '%s', you must set the password for '%s' manually", prog, login); | 84 | bb_error_msg_and_die("failed to execute '%s', you must set the password for '%s' manually", prog, login); |
85 | } | 85 | } |
86 | 86 | ||
diff --git a/loginutils/login.c b/loginutils/login.c index a19191b8c..830df0a7f 100644 --- a/loginutils/login.c +++ b/loginutils/login.c | |||
@@ -357,7 +357,7 @@ auth_failed: | |||
357 | setenv("LOGIN_UID", utoa(pw->pw_uid), 1); | 357 | setenv("LOGIN_UID", utoa(pw->pw_uid), 1); |
358 | setenv("LOGIN_GID", utoa(pw->pw_gid), 1); | 358 | setenv("LOGIN_GID", utoa(pw->pw_gid), 1); |
359 | setenv("LOGIN_SHELL", pw->pw_shell, 1); | 359 | setenv("LOGIN_SHELL", pw->pw_shell, 1); |
360 | execvp(script, t_argv); | 360 | BB_EXECVP(script, t_argv); |
361 | exit(1); | 361 | exit(1); |
362 | default: /* parent */ | 362 | default: /* parent */ |
363 | wait(NULL); | 363 | wait(NULL); |
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c index 69c698781..96c172cb8 100644 --- a/miscutils/devfsd.c +++ b/miscutils/devfsd.c | |||
@@ -378,7 +378,7 @@ static void fork_and_execute(int die, char *arg0, char **arg ) | |||
378 | /* Child : if arg0 != NULL do execvp */ | 378 | /* Child : if arg0 != NULL do execvp */ |
379 | if(arg0 != NULL ) | 379 | if(arg0 != NULL ) |
380 | { | 380 | { |
381 | execvp (arg0, arg); | 381 | BB_EXECVP(arg0, arg); |
382 | msg_logger_and_die(LOG_ERR, "execvp"); | 382 | msg_logger_and_die(LOG_ERR, "execvp"); |
383 | } | 383 | } |
384 | } | 384 | } |
diff --git a/miscutils/setsid.c b/miscutils/setsid.c index b4d5ced46..6db07be5f 100644 --- a/miscutils/setsid.c +++ b/miscutils/setsid.c | |||
@@ -36,7 +36,7 @@ int setsid_main(int argc, char *argv[]) | |||
36 | 36 | ||
37 | setsid(); /* no error possible */ | 37 | setsid(); /* no error possible */ |
38 | 38 | ||
39 | execvp(argv[1], argv + 1); | 39 | BB_EXECVP(argv[1], argv + 1); |
40 | 40 | ||
41 | bb_perror_msg_and_die("%s", argv[1]); | 41 | bb_perror_msg_and_die("%s", argv[1]); |
42 | } | 42 | } |
diff --git a/miscutils/taskset.c b/miscutils/taskset.c index cf6a8be99..b3bf4902e 100644 --- a/miscutils/taskset.c +++ b/miscutils/taskset.c | |||
@@ -91,7 +91,7 @@ int taskset_main(int argc, char** argv) | |||
91 | goto print_aff; | 91 | goto print_aff; |
92 | } | 92 | } |
93 | ++argv; | 93 | ++argv; |
94 | execvp(*argv, argv); | 94 | BB_EXECVP(*argv, argv); |
95 | bb_perror_msg_and_die("%s", *argv); | 95 | bb_perror_msg_and_die("%s", *argv); |
96 | } | 96 | } |
97 | #undef OPT_p | 97 | #undef OPT_p |
diff --git a/miscutils/time.c b/miscutils/time.c index 56f1d4ab8..a45919502 100644 --- a/miscutils/time.c +++ b/miscutils/time.c | |||
@@ -410,7 +410,7 @@ static void run_command(char *const *cmd, resource_t * resp) | |||
410 | else if (pid == 0) { /* If child. */ | 410 | else if (pid == 0) { /* If child. */ |
411 | /* Don't cast execvp arguments; that causes errors on some systems, | 411 | /* Don't cast execvp arguments; that causes errors on some systems, |
412 | versus merely warnings if the cast is left off. */ | 412 | versus merely warnings if the cast is left off. */ |
413 | execvp(cmd[0], cmd); | 413 | BB_EXECVP(cmd[0], cmd); |
414 | bb_error_msg("cannot run %s", cmd[0]); | 414 | bb_error_msg("cannot run %s", cmd[0]); |
415 | _exit(errno == ENOENT ? 127 : 126); | 415 | _exit(errno == ENOENT ? 127 : 126); |
416 | } | 416 | } |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index ce3b9bab7..ccebecd95 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -1004,7 +1004,7 @@ static int popen2(FILE **in, FILE **out, char *command, ...) | |||
1004 | close(infd[1]); | 1004 | close(infd[1]); |
1005 | close(outfd[0]); | 1005 | close(outfd[0]); |
1006 | close(outfd[1]); | 1006 | close(outfd[1]); |
1007 | execvp(command, argv); | 1007 | BB_EXECVP(command, argv); |
1008 | exit(127); | 1008 | exit(127); |
1009 | default: /* parent */ | 1009 | default: /* parent */ |
1010 | *in = fdopen(infd[1], "w"); | 1010 | *in = fdopen(infd[1], "w"); |
diff --git a/networking/nc.c b/networking/nc.c index c1e881162..1bdecaf5e 100644 --- a/networking/nc.c +++ b/networking/nc.c | |||
@@ -149,7 +149,7 @@ int nc_main(int argc, char **argv) | |||
149 | } | 149 | } |
150 | dup2(0, 1); | 150 | dup2(0, 1); |
151 | dup2(0, 2); | 151 | dup2(0, 2); |
152 | USE_NC_EXTRA(execvp(execparam[0], execparam);) | 152 | USE_NC_EXTRA(BB_EXECVP(execparam[0], execparam);) |
153 | /* Don't print stuff or it will go over the wire.... */ | 153 | /* Don't print stuff or it will go over the wire.... */ |
154 | _exit(127); | 154 | _exit(127); |
155 | } | 155 | } |
diff --git a/runit/chpst.c b/runit/chpst.c index 053051d1d..7b907845f 100644 --- a/runit/chpst.c +++ b/runit/chpst.c | |||
@@ -310,7 +310,7 @@ int chpst_main(int argc, char **argv) | |||
310 | if (OPT_nostdin) close(0); | 310 | if (OPT_nostdin) close(0); |
311 | if (OPT_nostdout) close(1); | 311 | if (OPT_nostdout) close(1); |
312 | if (OPT_nostderr) close(2); | 312 | if (OPT_nostderr) close(2); |
313 | execvp(argv[0], argv); | 313 | BB_EXECVP(argv[0], argv); |
314 | bb_perror_msg_and_die("exec %s", argv[0]); | 314 | bb_perror_msg_and_die("exec %s", argv[0]); |
315 | } | 315 | } |
316 | 316 | ||
@@ -322,7 +322,7 @@ static void setuidgid(int argc, char **argv) | |||
322 | if (!account) bb_show_usage(); | 322 | if (!account) bb_show_usage(); |
323 | if (!*++argv) bb_show_usage(); | 323 | if (!*++argv) bb_show_usage(); |
324 | suidgid((char*)account); | 324 | suidgid((char*)account); |
325 | execvp(argv[0], argv); | 325 | BB_EXECVP(argv[0], argv); |
326 | bb_perror_msg_and_die("exec %s", argv[0]); | 326 | bb_perror_msg_and_die("exec %s", argv[0]); |
327 | } | 327 | } |
328 | 328 | ||
@@ -334,7 +334,7 @@ static void envuidgid(int argc, char **argv) | |||
334 | if (!account) bb_show_usage(); | 334 | if (!account) bb_show_usage(); |
335 | if (!*++argv) bb_show_usage(); | 335 | if (!*++argv) bb_show_usage(); |
336 | euidgid((char*)account); | 336 | euidgid((char*)account); |
337 | execvp(argv[0], argv); | 337 | BB_EXECVP(argv[0], argv); |
338 | bb_perror_msg_and_die("exec %s", argv[0]); | 338 | bb_perror_msg_and_die("exec %s", argv[0]); |
339 | } | 339 | } |
340 | 340 | ||
@@ -346,7 +346,7 @@ static void envdir(int argc, char **argv) | |||
346 | if (!dir) bb_show_usage(); | 346 | if (!dir) bb_show_usage(); |
347 | if (!*++argv) bb_show_usage(); | 347 | if (!*++argv) bb_show_usage(); |
348 | edir(dir); | 348 | edir(dir); |
349 | execvp(argv[0], argv); | 349 | BB_EXECVP(argv[0], argv); |
350 | bb_perror_msg_and_die("exec %s", argv[0]); | 350 | bb_perror_msg_and_die("exec %s", argv[0]); |
351 | } | 351 | } |
352 | 352 | ||
@@ -369,6 +369,6 @@ static void softlimit(int argc, char **argv) | |||
369 | argv += optind; | 369 | argv += optind; |
370 | if (!argv[0]) bb_show_usage(); | 370 | if (!argv[0]) bb_show_usage(); |
371 | slimit(); | 371 | slimit(); |
372 | execvp(argv[0], argv); | 372 | BB_EXECVP(argv[0], argv); |
373 | bb_perror_msg_and_die("exec %s", argv[0]); | 373 | bb_perror_msg_and_die("exec %s", argv[0]); |
374 | } | 374 | } |
diff --git a/runit/runsvdir.c b/runit/runsvdir.c index d9053ad6a..2d2b5db31 100644 --- a/runit/runsvdir.c +++ b/runit/runsvdir.c | |||
@@ -73,7 +73,7 @@ static void runsv(int no, const char *name) | |||
73 | sig_uncatch(SIGHUP); | 73 | sig_uncatch(SIGHUP); |
74 | sig_uncatch(SIGTERM); | 74 | sig_uncatch(SIGTERM); |
75 | if (pgrp) setsid(); | 75 | if (pgrp) setsid(); |
76 | execvp(prog[0], prog); | 76 | BB_EXECVP(prog[0], prog); |
77 | //pathexec_run(*prog, prog, (char* const*)environ); | 77 | //pathexec_run(*prog, prog, (char* const*)environ); |
78 | fatal2_cannot("start runsv ", name); | 78 | fatal2_cannot("start runsv ", name); |
79 | } | 79 | } |
diff --git a/util-linux/setarch.c b/util-linux/setarch.c index 8f4e308d4..a7a45ec4d 100644 --- a/util-linux/setarch.c +++ b/util-linux/setarch.c | |||
@@ -46,7 +46,7 @@ retry: | |||
46 | if (personality(pers) >= 0) { | 46 | if (personality(pers) >= 0) { |
47 | 47 | ||
48 | /* Try to execute the program */ | 48 | /* Try to execute the program */ |
49 | execvp(argv[0], argv); | 49 | BB_EXECVP(argv[0], argv); |
50 | } | 50 | } |
51 | 51 | ||
52 | bb_perror_msg_and_die("%s", argv[0]); | 52 | bb_perror_msg_and_die("%s", argv[0]); |