diff options
author | Denys Vlasenko | 2017-07-07 19:08:56 +0200 |
---|---|---|
committer | Denys Vlasenko | 2017-07-07 19:08:56 +0200 |
commit | 69a5ec9dccfd183cdf6bee7b994336670755cd47 (patch) | |
tree | f6fa85ffa67173d5d78a64836b47accab94fc36b /libbb | |
parent | b0c0b6d5ba4b15069a1e4ce6750c0ef2e93579e1 (diff) | |
download | busybox-69a5ec9dccfd183cdf6bee7b994336670755cd47.zip busybox-69a5ec9dccfd183cdf6bee7b994336670755cd47.tar.gz |
main: fix the case where user has "halt" as login shell. Closes 9986
halt::0:0::/:/sbin/halt
function old new delta
run_applet_and_exit 748 751 +3
run_applet_no_and_exit 467 459 -8
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/appletlib.c | 10 | ||||
-rw-r--r-- | libbb/vfork_daemon_rexec.c | 2 |
2 files changed, 8 insertions, 4 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 2dea2b4..df65849 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -877,13 +877,17 @@ static int busybox_main(char **argv) # endif # if NUM_APPLETS > 0 -void FAST_FUNC run_applet_no_and_exit(int applet_no, char **argv) +void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **argv) { int argc = string_array_len(argv); /* Reinit some shared global data */ xfunc_error_retval = EXIT_FAILURE; - applet_name = bb_get_last_path_component_nostrip(argv[0]); + /* + * We do not use argv[0]: do not want to repeat massaging of + * "-/sbin/halt" -> "halt", for example. + */ + applet_name = name; /* Special case. POSIX says "test --help" * should be no different from e.g. "test --foo". @@ -927,7 +931,7 @@ static NORETURN void run_applet_and_exit(const char *name, char **argv) { int applet = find_applet_by_name(name); if (applet >= 0) - run_applet_no_and_exit(applet, argv); + run_applet_no_and_exit(applet, name, argv); } # endif diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c index 2695f99..576534e 100644 --- a/libbb/vfork_daemon_rexec.c +++ b/libbb/vfork_daemon_rexec.c @@ -180,7 +180,7 @@ int FAST_FUNC spawn_and_wait(char **argv) * as of yet (and that should probably always stay true). */ /* xfunc_error_retval and applet_name are init by: */ - run_applet_no_and_exit(a, argv); + run_applet_no_and_exit(a, argv[0], argv); } # endif } |