.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
.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),
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
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;
}