]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
chsh: use return rather than exit in main, clean up man page
authorKarel Zak <kzak@redhat.com>
Wed, 12 Dec 2012 09:48:01 +0000 (10:48 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 12 Dec 2012 09:48:01 +0000 (10:48 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/chsh.1
login-utils/chsh.c

index 393ccb70c52d414cfed420832453a4967a60936b..d597adc38e3de9afcf7369a42b45cd91ad5d3b86 100644 (file)
@@ -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),
index 7d944e19f058da303433bdeb69a51c9dd5903a85..6e9325deb6d447b93e138805f49e5aaf6560a350 100644 (file)
@@ -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;
 }