aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2022-01-13 01:38:47 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2022-01-13 01:38:47 +0100
commit96771ec5f5fb81b479973fbd25af48c5cb83b2bb (patch)
tree9f5e5122d502b67f449e2af5c6d5d390dea90cb9
parent68b402ee51f12f8c3b11638b042f57e025359faf (diff)
downloadbusybox-w32-96771ec5f5fb81b479973fbd25af48c5cb83b2bb.tar.gz
busybox-w32-96771ec5f5fb81b479973fbd25af48c5cb83b2bb.tar.bz2
busybox-w32-96771ec5f5fb81b479973fbd25af48c5cb83b2bb.zip
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.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c
index 2f87c77c0..56b88c086 100644
--- a/loginutils/sulogin.c
+++ b/loginutils/sulogin.c
@@ -20,7 +20,8 @@
20//usage: "[-t N] [TTY]" 20//usage: "[-t N] [TTY]"
21//usage:#define sulogin_full_usage "\n\n" 21//usage:#define sulogin_full_usage "\n\n"
22//usage: "Single user login\n" 22//usage: "Single user login\n"
23//usage: "\n -t N Timeout" 23//usage: "\n -p Start a login shell"
24//usage: "\n -t SEC Timeout"
24 25
25#include "libbb.h" 26#include "libbb.h"
26#include <syslog.h> 27#include <syslog.h>
@@ -30,6 +31,7 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv)
30{ 31{
31 int tsid; 32 int tsid;
32 int timeout = 0; 33 int timeout = 0;
34 unsigned opts;
33 struct passwd *pwd; 35 struct passwd *pwd;
34 const char *shell; 36 const char *shell;
35 37
@@ -44,7 +46,7 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv)
44 logmode = LOGMODE_BOTH; 46 logmode = LOGMODE_BOTH;
45 openlog(applet_name, 0, LOG_AUTH); 47 openlog(applet_name, 0, LOG_AUTH);
46 48
47 getopt32(argv, "t:+", &timeout); 49 opts = getopt32(argv, "pt:+", &timeout);
48 argv += optind; 50 argv += optind;
49 51
50 if (argv[0]) { 52 if (argv[0]) {
@@ -64,8 +66,8 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv)
64 int r; 66 int r;
65 67
66 r = ask_and_check_password_extended(pwd, timeout, 68 r = ask_and_check_password_extended(pwd, timeout,
67 "Give root password for system maintenance\n" 69 "Give root password for maintenance\n"
68 "(or type Control-D for normal startup):" 70 "(or type Ctrl-D to continue): "
69 ); 71 );
70 if (r < 0) { 72 if (r < 0) {
71 /* ^D, ^C, timeout, or read error */ 73 /* ^D, ^C, timeout, or read error */
@@ -79,7 +81,8 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv)
79 bb_simple_info_msg("Login incorrect"); 81 bb_simple_info_msg("Login incorrect");
80 } 82 }
81 83
82 bb_simple_info_msg("starting shell for system maintenance"); 84 /* util-linux 2.36.1 compat: no message */
85 /*bb_simple_info_msg("starting shell for system maintenance");*/
83 86
84 IF_SELINUX(renew_current_security_context()); 87 IF_SELINUX(renew_current_security_context());
85 88
@@ -116,6 +119,6 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv)
116 */ 119 */
117 /*signal(SIGINT, SIG_DFL);*/ 120 /*signal(SIGINT, SIG_DFL);*/
118 121
119 /* Exec login shell with no additional parameters. Never returns. */ 122 /* Exec shell with no additional parameters. Never returns. */
120 exec_login_shell(shell); 123 exec_shell(shell, /* -p? then shell is login:*/(opts & 1), NULL);
121} 124}