diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-19 00:20:20 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-19 00:20:20 +0000 |
commit | 15b213ef5a0834eb06a0183ab839ac883d829d5a (patch) | |
tree | 46b4cf5e6ce90c66b6794bf23b69705fbcb8d1e6 /loginutils/su.c | |
parent | 908d6b7054fbe793636d75d50d4af73ad9627c3b (diff) | |
download | busybox-w32-15b213ef5a0834eb06a0183ab839ac883d829d5a.tar.gz busybox-w32-15b213ef5a0834eb06a0183ab839ac883d829d5a.tar.bz2 busybox-w32-15b213ef5a0834eb06a0183ab839ac883d829d5a.zip |
su: make /etc/shells check configurable
ash: missing ';'
Diffstat (limited to 'loginutils/su.c')
-rw-r--r-- | loginutils/su.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/loginutils/su.c b/loginutils/su.c index 046457b6f..25b85920a 100644 --- a/loginutils/su.c +++ b/loginutils/su.c | |||
@@ -10,7 +10,7 @@ | |||
10 | 10 | ||
11 | int su_main(int argc, char **argv) | 11 | int su_main(int argc, char **argv) |
12 | { | 12 | { |
13 | unsigned long flags; | 13 | unsigned flags; |
14 | char *opt_shell = 0; | 14 | char *opt_shell = 0; |
15 | char *opt_command = 0; | 15 | char *opt_command = 0; |
16 | char *opt_username = "root"; | 16 | char *opt_username = "root"; |
@@ -49,19 +49,23 @@ int su_main(int argc, char **argv) | |||
49 | } | 49 | } |
50 | 50 | ||
51 | pw = getpwnam(opt_username); | 51 | pw = getpwnam(opt_username); |
52 | if (!pw) bb_error_msg_and_die("unknown id: %s", opt_username); | 52 | if (!pw) |
53 | bb_error_msg_and_die("unknown id: %s", opt_username); | ||
53 | 54 | ||
54 | /* Make sure pw->pw_shell is non-NULL. It may be NULL when NEW_USER | 55 | /* Make sure pw->pw_shell is non-NULL. It may be NULL when NEW_USER |
55 | is a username that is retrieved via NIS (YP), but that doesn't have | 56 | is a username that is retrieved via NIS (YP), but that doesn't have |
56 | a default shell listed. */ | 57 | a default shell listed. */ |
57 | if (!pw->pw_shell || !pw->pw_shell[0]) pw->pw_shell = (char *)DEFAULT_SHELL; | 58 | if (!pw->pw_shell || !pw->pw_shell[0]) |
59 | pw->pw_shell = (char *)DEFAULT_SHELL; | ||
58 | 60 | ||
59 | if ((cur_uid == 0) || correct_password(pw)) { | 61 | if ((cur_uid == 0) || correct_password(pw)) { |
60 | if (ENABLE_SU_SYSLOG) | 62 | if (ENABLE_SU_SYSLOG) |
61 | syslog(LOG_NOTICE, "+ %s %s:%s", tty, old_user, opt_username); | 63 | syslog(LOG_NOTICE, "%c %s %s:%s", |
64 | '+', tty, old_user, opt_username); | ||
62 | } else { | 65 | } else { |
63 | if (ENABLE_SU_SYSLOG) | 66 | if (ENABLE_SU_SYSLOG) |
64 | syslog(LOG_NOTICE, "- %s %s:%s", tty, old_user, opt_username); | 67 | syslog(LOG_NOTICE, "%c %s %s:%s", |
68 | '-', tty, old_user, opt_username); | ||
65 | bb_error_msg_and_die("incorrect password"); | 69 | bb_error_msg_and_die("incorrect password"); |
66 | } | 70 | } |
67 | 71 | ||
@@ -70,8 +74,10 @@ int su_main(int argc, char **argv) | |||
70 | free(old_user); | 74 | free(old_user); |
71 | } | 75 | } |
72 | 76 | ||
73 | if (!opt_shell && (flags & SU_OPT_mp)) opt_shell = getenv("SHELL"); | 77 | if (!opt_shell && (flags & SU_OPT_mp)) |
78 | opt_shell = getenv("SHELL"); | ||
74 | 79 | ||
80 | #if ENABLE_FEATURE_SU_CHECKS_SHELLS | ||
75 | if (opt_shell && cur_uid && restricted_shell(pw->pw_shell)) { | 81 | if (opt_shell && cur_uid && restricted_shell(pw->pw_shell)) { |
76 | /* The user being su'd to has a nonstandard shell, and so is | 82 | /* The user being su'd to has a nonstandard shell, and so is |
77 | probably a uucp account or has restricted access. Don't | 83 | probably a uucp account or has restricted access. Don't |
@@ -80,8 +86,9 @@ int su_main(int argc, char **argv) | |||
80 | bb_error_msg("using restricted shell"); | 86 | bb_error_msg("using restricted shell"); |
81 | opt_shell = 0; | 87 | opt_shell = 0; |
82 | } | 88 | } |
83 | 89 | #endif | |
84 | if (!opt_shell) opt_shell = pw->pw_shell; | 90 | if (!opt_shell) |
91 | opt_shell = pw->pw_shell; | ||
85 | 92 | ||
86 | change_identity(pw); | 93 | change_identity(pw); |
87 | setup_environment(opt_shell, flags & SU_OPT_l, !(flags & SU_OPT_mp), pw); | 94 | setup_environment(opt_shell, flags & SU_OPT_l, !(flags & SU_OPT_mp), pw); |