From e93a1aae2f1d7f419d8b1ec7ffd40a458a1b06af Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 14 Aug 2007 12:04:09 +0200 Subject: [PATCH] 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 --- login-utils/chsh.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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); -- 2.39.5