Deal with user_stat being NULL as it is for visudo and testsudoers.
This commit is contained in:
10
match.c
10
match.c
@@ -328,8 +328,9 @@ command_matches(sudoers_cmnd, sudoers_args)
|
|||||||
if (strcmp(user_base, base) != 0 ||
|
if (strcmp(user_base, base) != 0 ||
|
||||||
stat(*ap, &sudoers_stat) == -1)
|
stat(*ap, &sudoers_stat) == -1)
|
||||||
continue;
|
continue;
|
||||||
if (user_stat->st_dev == sudoers_stat.st_dev &&
|
if (user_stat == NULL ||
|
||||||
user_stat->st_ino == sudoers_stat.st_ino) {
|
(user_stat->st_dev == sudoers_stat.st_dev &&
|
||||||
|
user_stat->st_ino == sudoers_stat.st_ino)) {
|
||||||
if (safe_cmnd)
|
if (safe_cmnd)
|
||||||
free(safe_cmnd);
|
free(safe_cmnd);
|
||||||
safe_cmnd = estrdup(*ap);
|
safe_cmnd = estrdup(*ap);
|
||||||
@@ -373,8 +374,9 @@ command_matches(sudoers_cmnd, sudoers_args)
|
|||||||
* b) there are no args on command line and none req by sudoers OR
|
* b) there are no args on command line and none req by sudoers OR
|
||||||
* c) there are args in sudoers and on command line and they match
|
* c) there are args in sudoers and on command line and they match
|
||||||
*/
|
*/
|
||||||
if (user_stat->st_dev != sudoers_stat.st_dev ||
|
if (user_stat != NULL &&
|
||||||
user_stat->st_ino != sudoers_stat.st_ino)
|
(user_stat->st_dev != sudoers_stat.st_dev ||
|
||||||
|
user_stat->st_ino != sudoers_stat.st_ino))
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
if (!sudoers_args ||
|
if (!sudoers_args ||
|
||||||
(!user_args && sudoers_args && !strcmp("\"\"", sudoers_args)) ||
|
(!user_args && sudoers_args && !strcmp("\"\"", sudoers_args)) ||
|
||||||
|
@@ -236,11 +236,12 @@ main(argc, argv)
|
|||||||
rval = cmnd_matches(cs->cmnd);
|
rval = cmnd_matches(cs->cmnd);
|
||||||
if (rval != UNSPEC)
|
if (rval != UNSPEC)
|
||||||
matched = rval;
|
matched = rval;
|
||||||
printf("\tcommand %s\n", rval == ALLOW ? "allowed" :
|
printf("\tcmnd %s\n", rval == ALLOW ? "allowed" :
|
||||||
rval == DENY ? "denied" : "unmatched");
|
rval == DENY ? "denied" : "unmatched");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
|
puts("\thost unmatched");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user