Check whether shell argument given with `-s` is actually present and executable.
And is not a directory.
Fix https://github.com/shadow-maint/shadow/issues/186
const struct group *grp;
bool anyflag = false;
char *cp;
+ struct stat st;
{
/*
if ( ( !VALID (optarg) )
|| ( ('\0' != optarg[0])
&& ('/' != optarg[0])
- && ('*' != optarg[0]) )) {
+ && ('*' != optarg[0]) )
+ || (stat(optarg, &st) != 0)
+ || (S_ISDIR(st.st_mode))
+ || (access(optarg, X_OK != 0))) {
fprintf (stderr,
_("%s: invalid shell '%s'\n"),
Prog, optarg);