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

@@ -209,10 +209,7 @@ main(int argc, char *argv[])
} else {
user_name = *argv++;
user_cmnd = *argv++;
if ((p = strrchr(user_cmnd, '/')) != NULL)
user_base = p + 1;
else
user_base = user_cmnd;
user_base = sudo_basename(user_cmnd);
argc -= 2;
}
if ((sudo_user.pw = sudo_getpwnam(user_name)) == NULL)
@@ -447,12 +444,8 @@ open_sudoers(const char *file, bool doedit, bool *keepopen)
const char *base;
debug_decl(open_sudoers, SUDOERS_DEBUG_UTIL);
base = strrchr(file, '/');
if (base != NULL)
base++;
else
base = file;
/* Report errors using the basename for consistent test output. */
base = sudo_basename(file);
switch (sudo_secure_file(file, sudoers_uid, sudoers_gid, &sb)) {
case SUDO_PATH_SECURE:
fp = fopen(file, "r");