From: Chris Hofstaedtler Date: Mon, 17 Feb 2025 23:54:30 +0000 (+0100) Subject: chsh: do not warn about blank shell X-Git-Tag: 4.17.3~1 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=40bb89b6a4feca88d33e06f92502a504fb1c11cc;p=thirdparty%2Fshadow.git chsh: do not warn about blank shell Closes: Reported-by: 積丹尼 Dan Jacobson Signed-off-by: Chris Hofstaedtler Reviewed-by: Alejandro Colomar --- diff --git a/src/chsh.c b/src/chsh.c index 15bfae323..ecd5749ab 100644 --- a/src/chsh.c +++ b/src/chsh.c @@ -555,9 +555,11 @@ int main (int argc, char **argv) fprintf (stderr, _("%s: Invalid entry: %s\n"), Prog, loginsh); fail_exit (1); } - if (loginsh[0] != '/' - || is_restricted_shell (loginsh) - || (access (loginsh, X_OK) != 0)) { + if (!streq(loginsh, "") + && (loginsh[0] != '/' + || is_restricted_shell (loginsh) + || (access (loginsh, X_OK) != 0))) + { if (amroot) { fprintf (stderr, _("%s: Warning: %s is an invalid shell\n"), Prog, loginsh); } else { @@ -567,10 +569,13 @@ int main (int argc, char **argv) } /* Even for root, warn if an invalid shell is specified. */ - if (access (loginsh, F_OK) != 0) { - fprintf (stderr, _("%s: Warning: %s does not exist\n"), Prog, loginsh); - } else if (access (loginsh, X_OK) != 0) { - fprintf (stderr, _("%s: Warning: %s is not executable\n"), Prog, loginsh); + if (!streq(loginsh, "")) { + /* But not if an empty string is given, documented as meaning the default shell */ + if (access (loginsh, F_OK) != 0) { + fprintf (stderr, _("%s: Warning: %s does not exist\n"), Prog, loginsh); + } else if (access (loginsh, X_OK) != 0) { + fprintf (stderr, _("%s: Warning: %s is not executable\n"), Prog, loginsh); + } } update_shell (user, loginsh);