From: Karel Zak Date: Tue, 14 Aug 2007 10:04:09 +0000 (+0200) Subject: chsh: don't use empty shell field in /etc/passwd X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e93a1aae2f1d7f419d8b1ec7ffd40a458a1b06af;p=util-linux 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 --- diff --git a/login-utils/chsh.c b/login-utils/chsh.c index add7c439..15733a2c 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);