Use sudo_basename() instead of doing the equivalent manually.

This commit is contained in:
Todd C. Miller
2021-02-10 15:14:08 -07:00
parent 41fa461fe1
commit 0663ffbc3f
15 changed files with 38 additions and 101 deletions

View File

@@ -57,18 +57,13 @@ cmnd_allowed(char *cmnd, size_t cmnd_size, const char *runchroot,
debug_return_bool(true); /* nothing to check */
/* We compare the base names to avoid excessive stat()ing. */
if ((cmnd_base = strrchr(cmnd, '/')) == NULL)
debug_return_bool(false); /* can't happen */
cmnd_base++;
cmnd_base = sudo_basename(cmnd);
for (al = allowlist; *al != NULL; al++) {
const char *base, *path = *al;
struct stat sb;
if ((base = strrchr(path, '/')) == NULL)
continue; /* XXX - warn? */
base++;
base = sudo_basename(path);
if (strcmp(cmnd_base, base) != 0)
continue;