From: Samanta Navarro Date: Thu, 18 May 2023 11:58:19 +0000 (+0000) Subject: chsh: Verify that login shell path is absolute X-Git-Tag: 4.14.0-rc1~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7321ceaf69a7028a04056e548d861b291634c2d0;p=thirdparty%2Fshadow.git chsh: Verify that login shell path is absolute 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 --- diff --git a/src/chsh.c b/src/chsh.c index 639ff630f..d6eca6e36 100644 --- a/src/chsh.c +++ b/src/chsh.c @@ -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);