diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-02-26 10:01:18 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-02-26 10:01:18 +0100 |
commit | 26ffe81188a5555824bc86b1953517f7ba4524a9 (patch) | |
tree | 79b05ca36349747f5bf5eee0cfcf87a29db5f233 /loginutils | |
parent | fd686a262fa34b71900b010b4b31d7e2e3f3385c (diff) | |
download | busybox-w32-26ffe81188a5555824bc86b1953517f7ba4524a9.tar.gz busybox-w32-26ffe81188a5555824bc86b1953517f7ba4524a9.tar.bz2 busybox-w32-26ffe81188a5555824bc86b1953517f7ba4524a9.zip |
su: move restricted_shell into su.c (the only user)
function old new delta
su_main 448 468 +20
buffer_fill_and_print 179 196 +17
scriptreplay_main 205 208 +3
localcmd 275 277 +2
hash_find 233 234 +1
devmem_main 469 463 -6
install_main 724 716 -8
setusershell 11 - -11
find_pair 187 169 -18
restricted_shell 49 - -49
------------------------------------------------------------------------------
(add/remove: 0/3 grow/shrink: 5/3 up/down: 43/-92) Total: -49 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'loginutils')
-rw-r--r-- | loginutils/su.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/loginutils/su.c b/loginutils/su.c index 6356631b8..af25655fd 100644 --- a/loginutils/su.c +++ b/loginutils/su.c | |||
@@ -8,6 +8,23 @@ | |||
8 | #include "libbb.h" | 8 | #include "libbb.h" |
9 | #include <syslog.h> | 9 | #include <syslog.h> |
10 | 10 | ||
11 | #if ENABLE_FEATURE_SU_CHECKS_SHELLS | ||
12 | /* Return 1 if SHELL is a restricted shell (one not returned by | ||
13 | getusershell), else 0, meaning it is a standard shell. */ | ||
14 | static int restricted_shell(const char *shell) | ||
15 | { | ||
16 | char *line; | ||
17 | |||
18 | /*setusershell(); - getusershell does it itself*/ | ||
19 | while ((line = getusershell()) != NULL) { | ||
20 | if (/* *line != '#' && */ strcmp(line, shell) == 0) | ||
21 | return 0; | ||
22 | } | ||
23 | endusershell(); | ||
24 | return 1; | ||
25 | } | ||
26 | #endif | ||
27 | |||
11 | #define SU_OPT_mp (3) | 28 | #define SU_OPT_mp (3) |
12 | #define SU_OPT_l (4) | 29 | #define SU_OPT_l (4) |
13 | 30 | ||
@@ -89,7 +106,7 @@ int su_main(int argc UNUSED_PARAM, char **argv) | |||
89 | opt_shell = getenv("SHELL"); | 106 | opt_shell = getenv("SHELL"); |
90 | 107 | ||
91 | #if ENABLE_FEATURE_SU_CHECKS_SHELLS | 108 | #if ENABLE_FEATURE_SU_CHECKS_SHELLS |
92 | if (opt_shell && cur_uid && restricted_shell(pw->pw_shell)) { | 109 | if (opt_shell && cur_uid != 0 && restricted_shell(pw->pw_shell)) { |
93 | /* The user being su'd to has a nonstandard shell, and so is | 110 | /* The user being su'd to has a nonstandard shell, and so is |
94 | probably a uucp account or has restricted access. Don't | 111 | probably a uucp account or has restricted access. Don't |
95 | compromise the account by allowing access with a standard | 112 | compromise the account by allowing access with a standard |