summaryrefslogtreecommitdiffstats
path: root/login-utils
diff options
context:
space:
mode:
authorKarel Zak2007-08-14 12:04:09 +0200
committerKarel Zak2007-08-14 12:04:09 +0200
commite93a1aae2f1d7f419d8b1ec7ffd40a458a1b06af (patch)
tree36b532a9b5f6318174d68516d0f99199c47f4d9b /login-utils
parentmore: fix underlining for multibyte chars (diff)
downloadkernel-qcow2-util-linux-e93a1aae2f1d7f419d8b1ec7ffd40a458a1b06af.tar.gz
kernel-qcow2-util-linux-e93a1aae2f1d7f419d8b1ec7ffd40a458a1b06af.tar.xz
kernel-qcow2-util-linux-e93a1aae2f1d7f419d8b1ec7ffd40a458a1b06af.zip
chsh: don't use empty shell field in /etc/passwd
chsh(1) uses empty shell setting (pw->pw_shell="") as a synonym for /bin/sh. This convention is silly and unnecessary. (The vsftpd server will not run if the shell assigned to user "ftp" is a null string -- according to bug rh#103004). Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils')
-rw-r--r--login-utils/chsh.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/login-utils/chsh.c b/login-utils/chsh.c
index add7c4395..15733a2c1 100644
--- a/login-utils/chsh.c
+++ b/login-utils/chsh.c
@@ -150,7 +150,8 @@ main (int argc, char *argv[]) {
#endif
oldshell = pw->pw_shell;
- if (!oldshell[0]) oldshell = _PATH_BSHELL;
+ if (oldshell == NULL || *oldshell == '\0')
+ oldshell = _PATH_BSHELL; /* default */
/* reality check */
if (uid != 0 && uid != pw->pw_uid) {
@@ -219,7 +220,6 @@ main (int argc, char *argv[]) {
printf (_("Shell not changed.\n"));
return 0;
}
- if (!strcmp(shell, _PATH_BSHELL)) shell = "";
pw->pw_shell = shell;
if (setpwnam (pw) < 0) {
perror ("setpwnam");
@@ -333,6 +333,9 @@ static int
check_shell (char *shell) {
int i, c;
+ if (!shell)
+ return (-1);
+
if (*shell != '/') {
printf (_("%s: shell must be a full path name.\n"), whoami);
return (-1);