aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-10-14 11:47:02 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-10-14 11:47:02 +0000
commitae43b2061a191ef6e7458a5a4d5b00657b49ebf1 (patch)
tree2474ddafdbd9cd2f2209bf1d2de01e2488d0673e
parenteef90cb04d7bdc07dbd1945dd370fb0d85280ba6 (diff)
downloadbusybox-w32-ae43b2061a191ef6e7458a5a4d5b00657b49ebf1.tar.gz
busybox-w32-ae43b2061a191ef6e7458a5a4d5b00657b49ebf1.tar.bz2
busybox-w32-ae43b2061a191ef6e7458a5a4d5b00657b49ebf1.zip
sulogin: add support for $SUSHELL & $sushell
git-svn-id: svn://busybox.net/trunk/busybox@16380 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--loginutils/adduser.c10
-rw-r--r--loginutils/sulogin.c18
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
109auth_error: 119auth_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}