summaryrefslogtreecommitdiffstats
path: root/login-utils/chsh.c
diff options
context:
space:
mode:
authorKarel Zak2013-02-13 13:44:34 +0100
committerKarel Zak2013-02-13 13:44:34 +0100
commitd86918b6eb854de38a6e02b81466fcc0419cef98 (patch)
treecd3c94684bbe241411918306bbfb76b2af7d9cc8 /login-utils/chsh.c
parentlibmount: correctly propagate ambivalent blkid probing results (diff)
downloadkernel-qcow2-util-linux-d86918b6eb854de38a6e02b81466fcc0419cef98.tar.gz
kernel-qcow2-util-linux-d86918b6eb854de38a6e02b81466fcc0419cef98.tar.xz
kernel-qcow2-util-linux-d86918b6eb854de38a6e02b81466fcc0419cef98.zip
chsh-chfn: fix bugs, improve compilation
* rename --disable-require-password to --disable-chsh-chfn-password * is_local() is really unnecessary when linked with libuser * fix set_value_libuser() returns codes * fix chfn.c, there is no 'pw', but oldf.pw * don't link with PAM when--disable-chsh-chfn-password Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils/chsh.c')
-rw-r--r--login-utils/chsh.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/login-utils/chsh.c b/login-utils/chsh.c
index 66800ca94..e14efe088 100644
--- a/login-utils/chsh.c
+++ b/login-utils/chsh.c
@@ -52,7 +52,7 @@
#ifdef HAVE_LIBUSER
# include <libuser/user.h>
# include "libuser.h"
-#else
+#elif CHFN_CHSH_PASSWORD
# include "auth.h"
#endif
@@ -110,8 +110,10 @@ int main(int argc, char **argv)
info.username);
}
+#ifndef HAVE_LIBUSER
if (!(is_local(pw->pw_name)))
errx(EXIT_FAILURE, _("can only change local entries."));
+#endif
#ifdef HAVE_LIBSELINUX
if (is_selinux_enabled() > 0) {
@@ -160,12 +162,11 @@ int main(int argc, char **argv)
printf(_("Changing shell for %s.\n"), pw->pw_name);
-#ifndef HAVE_LIBUSER
+#if !defined(HAVE_LIBUSER) && defined(CHFN_CHSH_PASSWORD)
if(!auth_pam("chsh", uid, pw->pw_name)) {
return EXIT_FAILURE;
}
#endif
-
if (!shell) {
shell = prompt(_("New shell"), oldshell);
if (!shell)
@@ -179,7 +180,9 @@ int main(int argc, char **argv)
errx(EXIT_SUCCESS, _("Shell not changed."));
#ifdef HAVE_LIBUSER
- set_value_libuser("chsh", pw->pw_name, uid, LU_LOGINSHELL, shell);
+ if (set_value_libuser("chsh", pw->pw_name, uid,
+ LU_LOGINSHELL, shell) < 0)
+ errx(EXIT_FAILURE, _("Shell *NOT* changed. Try again later."));
#else
pw->pw_shell = shell;
if (setpwnam(pw) < 0)