Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/loginutils/su.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/loginutils/su.c
r2725 r3232 8 8 #include "libbb.h" 9 9 #include <syslog.h> 10 11 //usage:#define su_trivial_usage 12 //usage: "[OPTIONS] [-] [USER]" 13 //usage:#define su_full_usage "\n\n" 14 //usage: "Run shell under USER (by default, root)\n" 15 //usage: "\n -,-l Clear environment, run shell as login shell" 16 //usage: "\n -p,-m Do not set new $HOME, $SHELL, $USER, $LOGNAME" 17 //usage: "\n -c CMD Command to pass to 'sh -c'" 18 //usage: "\n -s SH Shell to use instead of user's default" 10 19 11 20 #if ENABLE_FEATURE_SU_CHECKS_SHELLS … … 43 52 uid_t cur_uid = getuid(); 44 53 const char *tty; 54 #if ENABLE_FEATURE_UTMP 45 55 char user_buf[64]; 56 #endif 46 57 const char *old_user; 47 58 … … 103 114 } 104 115 105 /* Make sure pw->pw_shell is non-NULL. It may be NULL when NEW_USER106 * is a username that is retrieved via NIS (YP), that doesn't have107 * a default shell listed. */108 if (!pw->pw_shell || !pw->pw_shell[0])109 pw->pw_shell = (char *)DEFAULT_SHELL;110 111 116 #if ENABLE_FEATURE_SU_CHECKS_SHELLS 112 if (opt_shell && cur_uid != 0 && restricted_shell(pw->pw_shell)) {117 if (opt_shell && cur_uid != 0 && pw->pw_shell && restricted_shell(pw->pw_shell)) { 113 118 /* The user being su'd to has a nonstandard shell, and so is 114 119 * probably a uucp account or has restricted access. Don't … … 116 121 * shell. */ 117 122 bb_error_msg("using restricted shell"); 118 opt_shell = NULL; 123 opt_shell = NULL; /* ignore -s PROG */ 119 124 } 120 125 /* else: user can run whatever he wants via "su -s PROG USER". … … 127 132 setup_environment(opt_shell, 128 133 ((flags & SU_OPT_l) / SU_OPT_l * SETUP_ENV_CLEARENV) 129 + (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV), 134 + (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV) 135 + (!(flags & SU_OPT_l) * SETUP_ENV_NO_CHDIR), 130 136 pw); 131 137 IF_SELINUX(set_current_security_context(NULL);)
Note:
See TracChangeset
for help on using the changeset viewer.