]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
chsh: do not warn about blank shell
authorChris Hofstaedtler <zeha@debian.org>
Mon, 17 Feb 2025 23:54:30 +0000 (00:54 +0100)
committerAlejandro Colomar <alx@kernel.org>
Fri, 21 Feb 2025 07:27:04 +0000 (08:27 +0100)
Closes: <https://bugs.debian.org/876542>
Reported-by: 積丹尼 Dan Jacobson <jidanni@jidanni.org>
Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
src/chsh.c

index 15bfae32379d2856379b30b1ba887b86cd35a3ab..ecd5749ab053807e728f39e9dc65396f2203c0ae 100644 (file)
@@ -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);