2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 06:15:37 +00:00

Eliminate use of setpwent()/endpwent() and setgrent()/endgrent().

Sudo never iterates over the passwd or group file.
Rename sudo_set{pw,gr}ent() -> sudo_mk{pw,gr}cache() and
use sudo_free{pw,gr}cache() instead of sudo_end{pw,gr}ent().
This commit is contained in:
Todd C. Miller
2016-05-11 07:06:45 -06:00
parent 8b4de84049
commit 23d288563e
7 changed files with 29 additions and 57 deletions

View File

@@ -155,7 +155,7 @@ sudoers_policy_init(void *info, char * const envp[])
bindtextdomain("sudoers", LOCALEDIR);
if (sudo_setpwent() == -1 || sudo_setgrent() == -1) {
if (sudo_mkpwcache() == -1 || sudo_mkgrcache() == -1) {
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_int(-1);
}
@@ -670,9 +670,9 @@ done:
restore_nproc();
/* Close the password and group files and free up memory. */
sudo_endpwent();
sudo_endgrent();
/* Destroy the password and group caches and free the contents. */
sudo_freepwcache();
sudo_freegrcache();
sudo_warn_set_locale_func(NULL);
@@ -1202,8 +1202,8 @@ sudoers_cleanup(void)
}
if (def_group_plugin)
group_plugin_unload();
sudo_endpwent();
sudo_endgrent();
sudo_freepwcache();
sudo_freegrcache();
debug_return;
}