libbb: make BB_EXECVP/LP try to exec real binary if there's no /proc/self/exe
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
099e528919
commit
c71b469f5d
@ -867,14 +867,16 @@ int exists_execable(const char *filename) FAST_FUNC;
|
|||||||
* but it may exec busybox and call applet instead of searching PATH.
|
* but it may exec busybox and call applet instead of searching PATH.
|
||||||
*/
|
*/
|
||||||
#if ENABLE_FEATURE_PREFER_APPLETS
|
#if ENABLE_FEATURE_PREFER_APPLETS
|
||||||
int bb_execvp(const char *file, char *const argv[]) FAST_FUNC;
|
int BB_EXECVP(const char *file, char *const argv[]) FAST_FUNC;
|
||||||
#define BB_EXECVP(prog,cmd) bb_execvp(prog,cmd)
|
|
||||||
#define BB_EXECLP(prog,cmd,...) \
|
#define BB_EXECLP(prog,cmd,...) \
|
||||||
execlp((find_applet_by_name(prog) >= 0) ? CONFIG_BUSYBOX_EXEC_PATH : prog, \
|
do { \
|
||||||
cmd, __VA_ARGS__)
|
if (find_applet_by_name(prog) >= 0) \
|
||||||
|
execlp(bb_busybox_exec_path, cmd, __VA_ARGS__); \
|
||||||
|
execlp(prog, cmd, __VA_ARGS__); \
|
||||||
|
} while (0)
|
||||||
#else
|
#else
|
||||||
#define BB_EXECVP(prog,cmd) execvp(prog,cmd)
|
#define BB_EXECVP(prog,cmd) execvp(prog,cmd)
|
||||||
#define BB_EXECLP(prog,cmd,...) execlp(prog,cmd, __VA_ARGS__)
|
#define BB_EXECLP(prog,cmd,...) execlp(prog,cmd,__VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
int BB_EXECVP_or_die(char **argv) NORETURN FAST_FUNC;
|
int BB_EXECVP_or_die(char **argv) NORETURN FAST_FUNC;
|
||||||
|
|
||||||
|
@ -68,12 +68,12 @@ int FAST_FUNC exists_execable(const char *filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_FEATURE_PREFER_APPLETS
|
#if ENABLE_FEATURE_PREFER_APPLETS
|
||||||
/* just like the real execvp, but try to launch an applet named 'file' first
|
/* just like the real execvp, but try to launch an applet named 'file' first */
|
||||||
*/
|
int FAST_FUNC BB_EXECVP(const char *file, char *const argv[])
|
||||||
int FAST_FUNC bb_execvp(const char *file, char *const argv[])
|
|
||||||
{
|
{
|
||||||
return execvp(find_applet_by_name(file) >= 0 ? bb_busybox_exec_path : file,
|
if (find_applet_by_name(file) >= 0)
|
||||||
argv);
|
execvp(bb_busybox_exec_path, argv);
|
||||||
|
return execvp(file, argv);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -182,17 +182,17 @@ int FAST_FUNC spawn_and_wait(char **argv)
|
|||||||
int a = find_applet_by_name(argv[0]);
|
int a = find_applet_by_name(argv[0]);
|
||||||
|
|
||||||
if (a >= 0 && (APPLET_IS_NOFORK(a)
|
if (a >= 0 && (APPLET_IS_NOFORK(a)
|
||||||
#if BB_MMU
|
# if BB_MMU
|
||||||
|| APPLET_IS_NOEXEC(a) /* NOEXEC trick needs fork() */
|
|| APPLET_IS_NOEXEC(a) /* NOEXEC trick needs fork() */
|
||||||
#endif
|
# endif
|
||||||
)) {
|
)) {
|
||||||
#if BB_MMU
|
# if BB_MMU
|
||||||
if (APPLET_IS_NOFORK(a))
|
if (APPLET_IS_NOFORK(a))
|
||||||
#endif
|
# endif
|
||||||
{
|
{
|
||||||
return run_nofork_applet(a, argv);
|
return run_nofork_applet(a, argv);
|
||||||
}
|
}
|
||||||
#if BB_MMU
|
# if BB_MMU
|
||||||
/* MMU only */
|
/* MMU only */
|
||||||
/* a->noexec is true */
|
/* a->noexec is true */
|
||||||
rc = fork();
|
rc = fork();
|
||||||
@ -201,7 +201,7 @@ int FAST_FUNC spawn_and_wait(char **argv)
|
|||||||
/* child */
|
/* child */
|
||||||
xfunc_error_retval = EXIT_FAILURE;
|
xfunc_error_retval = EXIT_FAILURE;
|
||||||
run_applet_no_and_exit(a, argv);
|
run_applet_no_and_exit(a, argv);
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
#endif /* FEATURE_PREFER_APPLETS */
|
#endif /* FEATURE_PREFER_APPLETS */
|
||||||
rc = spawn(argv);
|
rc = spawn(argv);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user