aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-03-30 17:27:32 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2016-03-30 17:27:32 +0200
commit32c08acba3d938ec2fa4f9d2ff8160bbe05a20cb (patch)
tree9fd750c4bf521a9d59fd2973348ebbefc24c5fe7
parent8ac6effb029f1fe4f620e061c1b62c4721f41491 (diff)
downloadbusybox-w32-32c08acba3d938ec2fa4f9d2ff8160bbe05a20cb.tar.gz
busybox-w32-32c08acba3d938ec2fa4f9d2ff8160bbe05a20cb.tar.bz2
busybox-w32-32c08acba3d938ec2fa4f9d2ff8160bbe05a20cb.zip
sulogin: remove suid paranoia code, explain why it's not necessary
function old new delta sulogin_main 325 270 -55 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--loginutils/sulogin.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c
index d2ac1f65d..33f078ae7 100644
--- a/loginutils/sulogin.c
+++ b/loginutils/sulogin.c
@@ -32,6 +32,14 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv)
32 struct passwd *pwd; 32 struct passwd *pwd;
33 const char *shell; 33 const char *shell;
34 34
35 /* Note: sulogin is not a suid app. It is meant to be run by init
36 * for single user / emergency mode. init starts it as root.
37 * Normal users (potentially malisious ones) can only run it under
38 * their UID, therefore no paranoia here is warranted:
39 * $LD_LIBRARY_PATH in env, TTY = /dev/sda
40 * are no more dangerous here than in e.g. cp applet.
41 */
42
35 logmode = LOGMODE_BOTH; 43 logmode = LOGMODE_BOTH;
36 openlog(applet_name, 0, LOG_AUTH); 44 openlog(applet_name, 0, LOG_AUTH);
37 45
@@ -47,18 +55,9 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv)
47 dup(0); 55 dup(0);
48 } 56 }
49 57
50 /* Malicious use like "sulogin /dev/sda"? */
51 if (!isatty(0) || !isatty(1) || !isatty(2)) {
52 logmode = LOGMODE_SYSLOG;
53 bb_error_msg_and_die("not a tty");
54 }
55
56 /* Clear dangerous stuff, set PATH */
57 sanitize_env_if_suid();
58
59 pwd = getpwuid(0); 58 pwd = getpwuid(0);
60 if (!pwd) { 59 if (!pwd) {
61 goto auth_error; 60 bb_error_msg_and_die("no password entry for root");
62 } 61 }
63 62
64 while (1) { 63 while (1) {
@@ -92,7 +91,4 @@ int sulogin_main(int argc UNUSED_PARAM, char **argv)
92 91
93 /* Exec login shell with no additional parameters. Never returns. */ 92 /* Exec login shell with no additional parameters. Never returns. */
94 run_shell(shell, 1, NULL, NULL); 93 run_shell(shell, 1, NULL, NULL);
95
96 auth_error:
97 bb_error_msg_and_die("no password entry for root");
98} 94}