]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
chsh: Verify that login shell path is absolute
authorSamanta Navarro <ferivoz@riseup.net>
Thu, 18 May 2023 11:58:19 +0000 (11:58 +0000)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Thu, 18 May 2023 14:03:41 +0000 (16:03 +0200)
The getusershell implementation of musl returns every line within the
/etc/shells file, which even includes comments. Only consider absolute
paths for login shells.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
src/chsh.c

index 639ff630f1d9aa0da2178414e456235b6f80dd83..d6eca6e36df40c91c9cdf80ac638a1a0ef939491 100644 (file)
@@ -574,7 +574,8 @@ int main (int argc, char **argv)
                fail_exit (1);
        }
        if (   !amroot
-           && (   is_restricted_shell (loginsh)
+           && (   loginsh[0] != '/'
+               || is_restricted_shell (loginsh)
                || (access (loginsh, X_OK) != 0))) {
                fprintf (stderr, _("%s: %s is an invalid shell\n"), Prog, loginsh);
                fail_exit (1);