From: Sami Kerola Date: Sun, 14 Dec 2014 23:20:01 +0000 (+0000) Subject: chsh: allow user to set shell to /bin/sh if none is set X-Git-Tag: v2.26-rc1~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f64979233f9093bfa1a628eac163ee025e9ab1a4;p=thirdparty%2Futil-linux.git chsh: allow user to set shell to /bin/sh if none is set Earlier setting a /bin/sh was impossible for users that had nothing set as shell, as that was seen as no change. Signed-off-by: Sami Kerola --- diff --git a/login-utils/chsh.c b/login-utils/chsh.c index a31641565f..0112fa45d1 100644 --- a/login-utils/chsh.c +++ b/login-utils/chsh.c @@ -252,6 +252,7 @@ static int check_shell(const char *shell) int main(int argc, char **argv) { char *oldshell; + int nullshell = 0; const uid_t uid = getuid(); struct sinfo info = { 0 }; struct passwd *pw; @@ -302,8 +303,10 @@ int main(int argc, char **argv) #endif oldshell = pw->pw_shell; - if (oldshell == NULL || *oldshell == '\0') + if (oldshell == NULL || *oldshell == '\0') { oldshell = _PATH_BSHELL; /* default */ + nullshell = 1; + } /* reality check */ #ifdef HAVE_LIBUSER @@ -339,7 +342,7 @@ int main(int argc, char **argv) if (check_shell(info.shell) < 0) return EXIT_FAILURE; - if (strcmp(oldshell, info.shell) == 0) + if (!nullshell && strcmp(oldshell, info.shell) == 0) errx(EXIT_SUCCESS, _("Shell not changed.")); #ifdef HAVE_LIBUSER