2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 14:25:15 +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

@@ -359,9 +359,9 @@ sudo_fakepwnam(const char *user, gid_t gid)
}
int
sudo_setpwent(void)
sudo_mkpwcache(void)
{
debug_decl(sudo_setpwent, SUDOERS_DEBUG_NSS)
debug_decl(sudo_mkpwcache, SUDOERS_DEBUG_NSS)
if (pwcache_byuid == NULL)
pwcache_byuid = rbcreate(cmp_pwuid);
@@ -370,8 +370,6 @@ sudo_setpwent(void)
if (pwcache_byuid == NULL || pwcache_byname == NULL)
debug_return_int(-1);
setpwent();
debug_return_int(0);
}
@@ -392,17 +390,6 @@ sudo_freepwcache(void)
debug_return;
}
void
sudo_endpwent(void)
{
debug_decl(sudo_endpwent, SUDOERS_DEBUG_NSS)
endpwent();
sudo_freepwcache();
debug_return;
}
/*
* Compare by gid.
*/
@@ -659,9 +646,9 @@ sudo_grlist_delref(struct group_list *grlist)
}
int
sudo_setgrent(void)
sudo_mkgrcache(void)
{
debug_decl(sudo_setgrent, SUDOERS_DEBUG_NSS)
debug_decl(sudo_mkgrcache, SUDOERS_DEBUG_NSS)
if (grcache_bygid == NULL)
grcache_bygid = rbcreate(cmp_grgid);
@@ -672,8 +659,6 @@ sudo_setgrent(void)
if (grcache_bygid == NULL || grcache_byname == NULL || grlist_cache == NULL)
debug_return_int(-1);
setgrent();
debug_return_int(0);
}
@@ -698,17 +683,6 @@ sudo_freegrcache(void)
debug_return;
}
void
sudo_endgrent(void)
{
debug_decl(sudo_endgrent, SUDOERS_DEBUG_NSS)
endgrent();
sudo_freegrcache();
debug_return;
}
struct group_list *
sudo_get_grlist(const struct passwd *pw)
{