diff options
-rw-r--r-- | loginutils/adduser.c | 10 | ||||
-rw-r--r-- | loginutils/sulogin.c | 18 |
2 files changed, 19 insertions, 9 deletions
diff --git a/loginutils/adduser.c b/loginutils/adduser.c index 8101b20b4..a99f47d68 100644 --- a/loginutils/adduser.c +++ b/loginutils/adduser.c | |||
@@ -114,11 +114,11 @@ static int adduser(struct passwd *p, unsigned long flags) | |||
114 | file = xfopen(bb_path_shadow_file, "a"); | 114 | file = xfopen(bb_path_shadow_file, "a"); |
115 | fseek(file, 0, SEEK_END); | 115 | fseek(file, 0, SEEK_END); |
116 | fprintf(file, "%s:!:%ld:%d:%d:%d:::\n", | 116 | fprintf(file, "%s:!:%ld:%d:%d:%d:::\n", |
117 | p->pw_name, /* username */ | 117 | p->pw_name, /* username */ |
118 | time(NULL) / 86400, /* sp->sp_lstchg */ | 118 | time(NULL) / 86400, /* sp->sp_lstchg */ |
119 | 0, /* sp->sp_min */ | 119 | 0, /* sp->sp_min */ |
120 | 99999, /* sp->sp_max */ | 120 | 99999, /* sp->sp_max */ |
121 | 7); /* sp->sp_warn */ | 121 | 7); /* sp->sp_warn */ |
122 | fclose(file); | 122 | fclose(file); |
123 | #endif | 123 | #endif |
124 | 124 | ||
diff --git a/loginutils/sulogin.c b/loginutils/sulogin.c index 679439544..c07264e7b 100644 --- a/loginutils/sulogin.c +++ b/loginutils/sulogin.c | |||
@@ -42,6 +42,7 @@ int sulogin_main(int argc, char **argv) | |||
42 | const char * const *p; | 42 | const char * const *p; |
43 | struct passwd *pwd; | 43 | struct passwd *pwd; |
44 | struct spwd *spwd; | 44 | struct spwd *spwd; |
45 | const char *shell; | ||
45 | 46 | ||
46 | logmode = LOGMODE_BOTH; | 47 | logmode = LOGMODE_BOTH; |
47 | openlog(applet_name, 0, LOG_AUTH); | 48 | openlog(applet_name, 0, LOG_AUTH); |
@@ -69,12 +70,14 @@ int sulogin_main(int argc, char **argv) | |||
69 | 70 | ||
70 | signal(SIGALRM, catchalarm); | 71 | signal(SIGALRM, catchalarm); |
71 | 72 | ||
72 | if (!(pwd = getpwuid(0))) { | 73 | pwd = getpwuid(0); |
74 | if (!pwd) { | ||
73 | goto auth_error; | 75 | goto auth_error; |
74 | } | 76 | } |
75 | 77 | ||
76 | if (ENABLE_FEATURE_SHADOWPASSWDS) { | 78 | if (ENABLE_FEATURE_SHADOWPASSWDS) { |
77 | if (!(spwd = getspnam(pwd->pw_name))) { | 79 | spwd = getspnam(pwd->pw_name); |
80 | if (!spwd) { | ||
78 | goto auth_error; | 81 | goto auth_error; |
79 | } | 82 | } |
80 | pwd->pw_passwd = spwd->sp_pwdp; | 83 | pwd->pw_passwd = spwd->sp_pwdp; |
@@ -103,9 +106,16 @@ int sulogin_main(int argc, char **argv) | |||
103 | 106 | ||
104 | USE_SELINUX(renew_current_security_context()); | 107 | USE_SELINUX(renew_current_security_context()); |
105 | 108 | ||
106 | run_shell(pwd->pw_shell, 1, 0, 0); | 109 | shell = getenv("SUSHELL"); |
110 | if (!shell) shell = getenv("sushell"); | ||
111 | if (!shell) { | ||
112 | shell = "/bin/sh"; | ||
113 | if (pwd->pw_shell[0]) | ||
114 | shell = pwd->pw_shell; | ||
115 | } | ||
116 | run_shell(shell, 1, 0, 0); | ||
107 | /* never returns */ | 117 | /* never returns */ |
108 | 118 | ||
109 | auth_error: | 119 | auth_error: |
110 | bb_error_msg_and_die("no password entry for `root'"); | 120 | bb_error_msg_and_die("no password entry for 'root'"); |
111 | } | 121 | } |