summaryrefslogtreecommitdiffstats
path: root/login-utils/chsh.c
diff options
context:
space:
mode:
authorKarel Zak2012-12-12 10:48:01 +0100
committerKarel Zak2012-12-12 10:48:01 +0100
commit36f9133dd2ee442b16d257c0d5d4027a7b72fea0 (patch)
treee1217a1904d1401d33f7283d75fc660a828dd821 /login-utils/chsh.c
parentchfn: always use return rather than exit() in main (diff)
downloadkernel-qcow2-util-linux-36f9133dd2ee442b16d257c0d5d4027a7b72fea0.tar.gz
kernel-qcow2-util-linux-36f9133dd2ee442b16d257c0d5d4027a7b72fea0.tar.xz
kernel-qcow2-util-linux-36f9133dd2ee442b16d257c0d5d4027a7b72fea0.zip
chsh: use return rather than exit in main, clean up man page
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils/chsh.c')
-rw-r--r--login-utils/chsh.c17
1 files changed, 8 insertions, 9 deletions
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;
}