Merge pull request #187 from jubalh/useradd-s

useradd: check for valid shell argument
This commit is contained in:
Serge Hallyn 2019-11-11 18:10:56 -06:00 committed by GitHub
commit e97df9b1ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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