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 <ferivoz@riseup.net>
This commit is contained in:
Samanta Navarro 2023-05-18 11:58:19 +00:00 committed by Iker Pedrosa
parent 812f934e77
commit 7321ceaf69

View 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);