In sudoers_policy_close() call sudoers_cleanup() instead of sudo_user_free().

If we didn't call sudoers_policy_main() due to an early error there
may be more things to clean up.
This commit is contained in:
Todd C. Miller
2021-02-16 10:37:04 -07:00
parent ecdf732adc
commit df91e15b82
2 changed files with 11 additions and 10 deletions

View File

@@ -968,8 +968,8 @@ sudoers_policy_close(int exit_status, int error_code)
/* Free stashed copy of the environment. */
(void)env_init(NULL);
/* Free struct sudo_user. */
sudo_user_free();
/* Free sudoers sources, sudo_user and passwd/group caches. */
sudoers_cleanup();
/* Free error message passed back to front-end, if any. */
free(audit_msg);
@@ -1025,8 +1025,8 @@ sudoers_policy_check(int argc, char * const argv[], char *env_add[],
SET(sudo_mode, MODE_RUN);
if ((sudo_mode & valid_flags) != sudo_mode) {
sudo_warnx(U_("invalid mode flags from sudo front end: 0x%x"),
sudo_mode);
sudo_warnx(U_("%s: invalid mode flags from sudo front end: 0x%x"),
__func__, sudo_mode);
debug_return_int(-1);
}
@@ -1062,8 +1062,8 @@ sudoers_policy_validate(const char **errstr)
SET(sudo_mode, MODE_VALIDATE);
if ((sudo_mode & VALIDATE_VALID_FLAGS) != sudo_mode) {
sudo_warnx(U_("invalid mode flags from sudo front end: 0x%x"),
sudo_mode);
sudo_warnx(U_("%s: invalid mode flags from sudo front end: 0x%x"),
__func__, sudo_mode);
debug_return_int(-1);
}
@@ -1084,8 +1084,8 @@ sudoers_policy_invalidate(int unlinkit)
SET(sudo_mode, MODE_INVALIDATE);
if ((sudo_mode & INVALIDATE_VALID_FLAGS) != sudo_mode) {
sudo_warnx(U_("invalid mode flags from sudo front end: 0x%x"),
sudo_mode);
sudo_warnx(U_("%s: invalid mode flags from sudo front end: 0x%x"),
__func__, sudo_mode);
} else {
timestamp_remove(unlinkit);
}
@@ -1110,8 +1110,8 @@ sudoers_policy_list(int argc, char * const argv[], int verbose,
}
if ((sudo_mode & LIST_VALID_FLAGS) != sudo_mode) {
sudo_warnx(U_("invalid mode flags from sudo front end: 0x%x"),
sudo_mode);
sudo_warnx(U_("%s: invalid mode flags from sudo front end: 0x%x"),
__func__, sudo_mode);
debug_return_int(-1);
}

View File

@@ -1612,6 +1612,7 @@ sudoers_cleanup(void)
nss->close(nss);
}
snl = NULL;
init_parser(NULL, false, false);
}
if (def_group_plugin)
group_plugin_unload();