diff options
-rw-r--r-- | login-utils/chsh.1 | 18 | ||||
-rw-r--r-- | login-utils/chsh.c | 17 |
2 files changed, 18 insertions, 17 deletions
diff --git a/login-utils/chsh.1 b/login-utils/chsh.1 index 393ccb70c..d597adc38 100644 --- a/login-utils/chsh.1 +++ b/login-utils/chsh.1 @@ -31,14 +31,6 @@ prompts for one. .B chsh is used to change local entries only. Use ypchsh, lchsh or any other implementation for non-local entries. -.SS VALID SHELLS -.B chsh -will accept the full pathname of any executable file on the system. -However, it will issue a warning if the shell is not listed in the -.I /etc/shells -file. -On the other hand, it can also be configured such that it will -only accept shells listed in this file, unless you are root. .SH OPTIONS .TP .BI "\-s, \-\-shell " shell @@ -54,6 +46,16 @@ Print a usage message and exit. .TP .B "-v, \-\-version" Print version information and exit. +.SH "VALID SHELLS" +.B chsh +will accept the full pathname of any executable file on the system. +However, it will issue a warning if the shell is not listed in the +.I /etc/shells +file. +On the other hand, it can also be configured such that it will +only accept shells listed in this file, unless you are root. +.SH "EXIT STATUS" +Returns 0 if operation was successful, 1 if operation failed or command syntax was not valid. .SH "SEE ALSO" .BR login (1), .BR passwd (5), diff --git a/login-utils/chsh.c b/login-utils/chsh.c index 7d944e19f..6e9325deb 100644 --- a/login-utils/chsh.c +++ b/login-utils/chsh.c @@ -155,22 +155,22 @@ int main(int argc, char **argv) retcode = pam_start("chsh", pw->pw_name, &conv, &pamh); if (pam_fail_check(pamh, retcode)) - exit(EXIT_FAILURE); + return EXIT_FAILURE; retcode = pam_authenticate(pamh, 0); if (pam_fail_check(pamh, retcode)) - exit(EXIT_FAILURE); + return EXIT_FAILURE; retcode = pam_acct_mgmt(pamh, 0); if (retcode == PAM_NEW_AUTHTOK_REQD) retcode = pam_chauthtok(pamh, PAM_CHANGE_EXPIRED_AUTHTOK); if (pam_fail_check(pamh, retcode)) - exit(EXIT_FAILURE); + return EXIT_FAILURE; retcode = pam_setcred(pamh, 0); if (pam_fail_check(pamh, retcode)) - exit(EXIT_FAILURE); + return EXIT_FAILURE; pam_end(pamh, 0); /* no need to establish a session; this isn't a @@ -190,11 +190,10 @@ int main(int argc, char **argv) if (strcmp(oldshell, shell) == 0) errx(EXIT_SUCCESS, _("Shell not changed.")); pw->pw_shell = shell; - if (setpwnam(pw) < 0) { - warn(_("setpwnam failed\n" - "Shell *NOT* changed. Try again later.")); - return EXIT_FAILURE; - } + if (setpwnam(pw) < 0) + err(EXIT_FAILURE, _("setpwnam failed\n" + "Shell *NOT* changed. Try again later.")); + printf(_("Shell changed.\n")); return EXIT_SUCCESS; } |