diff options
author | Denys Vlasenko | 2022-01-13 01:38:47 +0100 |
---|---|---|
committer | Denys Vlasenko | 2022-01-13 01:38:47 +0100 |
commit | 96771ec5f5fb81b479973fbd25af48c5cb83b2bb (patch) | |
tree | 9f5e5122d502b67f449e2af5c6d5d390dea90cb9 | |
parent | 68b402ee51f12f8c3b11638b042f57e025359faf (diff) | |
download | busybox-96771ec5f5fb81b479973fbd25af48c5cb83b2bb.zip busybox-96771ec5f5fb81b479973fbd25af48c5cb83b2bb.tar.gz |
sulogin: start _login_ shell only with -p
Also, shorten/eliminate messages to be closer to util-linux.
function old new delta
packed_usage 34233 34238 +5
sulogin_main 340 341 +1
.rodata 104380 104327 -53
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 6/-53) Total: -47 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | loginutils/sulogin.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c index 2f87c77..56b88c0 100644 --- a/loginutils/sulogin.c +++ b/loginutils/sulogin.c @@ -20,7 +20,8 @@ //usage: "[-t N] [TTY]" //usage:#define sulogin_full_usage "\n\n" //usage: "Single user login\n" -//usage: "\n -t N Timeout" +//usage: "\n -p Start a login shell" +//usage: "\n -t SEC Timeout" #include "libbb.h" #include <syslog.h> @@ -30,6 +31,7 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv) { int tsid; int timeout = 0; + unsigned opts; struct passwd *pwd; const char *shell; @@ -44,7 +46,7 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv) logmode = LOGMODE_BOTH; openlog(applet_name, 0, LOG_AUTH); - getopt32(argv, "t:+", &timeout); + opts = getopt32(argv, "pt:+", &timeout); argv += optind; if (argv[0]) { @@ -64,8 +66,8 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv) int r; r = ask_and_check_password_extended(pwd, timeout, - "Give root password for system maintenance\n" - "(or type Control-D for normal startup):" + "Give root password for maintenance\n" + "(or type Ctrl-D to continue): " ); if (r < 0) { /* ^D, ^C, timeout, or read error */ @@ -79,7 +81,8 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv) bb_simple_info_msg("Login incorrect"); } - bb_simple_info_msg("starting shell for system maintenance"); + /* util-linux 2.36.1 compat: no message */ + /*bb_simple_info_msg("starting shell for system maintenance");*/ IF_SELINUX(renew_current_security_context()); @@ -116,6 +119,6 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv) */ /*signal(SIGINT, SIG_DFL);*/ - /* Exec login shell with no additional parameters. Never returns. */ - exec_login_shell(shell); + /* Exec shell with no additional parameters. Never returns. */ + exec_shell(shell, /* -p? then shell is login:*/(opts & 1), NULL); } |