diff --git a/src/useradd.c b/src/useradd.c index 3e22dbf7..55280549 100644 --- a/src/useradd.c +++ b/src/useradd.c @@ -1101,6 +1101,7 @@ static void process_flags (int argc, char **argv) const struct group *grp; bool anyflag = false; char *cp; + struct stat st; { /* @@ -1327,7 +1328,10 @@ static void process_flags (int argc, char **argv) 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);