struct rbnode *node;
debug_decl(sudo_getpwuid, SUDOERS_DEBUG_NSS)
+ if (pwcache_byuid == NULL) {
+ pwcache_byuid = rbcreate(cmp_pwuid);
+ if (pwcache_byuid == NULL) {
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
+ debug_return_ptr(NULL);
+ }
+ }
+
key.k.uid = uid;
getauthregistry(IDtouser(uid), key.registry);
if ((node = rbfind(pwcache_byuid, &key)) != NULL) {
struct rbnode *node;
debug_decl(sudo_getpwnam, SUDOERS_DEBUG_NSS)
+ if (pwcache_byname == NULL) {
+ pwcache_byname = rbcreate(cmp_pwnam);
+ if (pwcache_byname == NULL) {
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
+ debug_return_ptr(NULL);
+ }
+ }
+
key.k.name = (char *) name;
getauthregistry((char *) name, key.registry);
if ((node = rbfind(pwcache_byname, &key)) != NULL) {
int i;
debug_decl(sudo_mkpwent, SUDOERS_DEBUG_NSS)
+ if (pwcache_byuid == NULL)
+ pwcache_byuid = rbcreate(cmp_pwuid);
+ if (pwcache_byname == NULL)
+ pwcache_byname = rbcreate(cmp_pwnam);
+ if (pwcache_byuid == NULL || pwcache_byname == NULL) {
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
+ debug_return_ptr(NULL);
+ }
+
/* Optional arguments. */
if (home == NULL)
home = "/";
debug_return_ptr(sudo_mkpwent(user, uid, gid, NULL, NULL));
}
-int
-sudo_mkpwcache(void)
-{
- debug_decl(sudo_mkpwcache, SUDOERS_DEBUG_NSS)
-
- if (pwcache_byuid == NULL)
- pwcache_byuid = rbcreate(cmp_pwuid);
- if (pwcache_byname == NULL)
- pwcache_byname = rbcreate(cmp_pwnam);
- if (pwcache_byuid == NULL || pwcache_byname == NULL)
- debug_return_int(-1);
-
- debug_return_int(0);
-}
-
void
sudo_freepwcache(void)
{
struct rbnode *node;
debug_decl(sudo_getgrgid, SUDOERS_DEBUG_NSS)
+ if (grcache_bygid == NULL) {
+ grcache_bygid = rbcreate(cmp_grgid);
+ if (grcache_bygid == NULL) {
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
+ debug_return_ptr(NULL);
+ }
+ }
+
key.k.gid = gid;
getauthregistry(NULL, key.registry);
if ((node = rbfind(grcache_bygid, &key)) != NULL) {
struct rbnode *node;
debug_decl(sudo_getgrnam, SUDOERS_DEBUG_NSS)
+ if (grcache_byname == NULL) {
+ grcache_byname = rbcreate(cmp_grnam);
+ if (grcache_byname == NULL) {
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
+ debug_return_ptr(NULL);
+ }
+ }
+
key.k.name = (char *) name;
getauthregistry(NULL, key.registry);
if ((node = rbfind(grcache_byname, &key)) != NULL) {
int i;
debug_decl(sudo_fakegrnam, SUDOERS_DEBUG_NSS)
+ if (grcache_bygid == NULL)
+ grcache_bygid = rbcreate(cmp_grgid);
+ if (grcache_byname == NULL)
+ grcache_byname = rbcreate(cmp_grnam);
+ if (grcache_bygid == NULL || grcache_byname == NULL) {
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
+ debug_return_ptr(NULL);
+ }
+
name_len = strlen(group);
len = sizeof(*gritem) + name_len + 1;
debug_return;
}
-int
-sudo_mkgrcache(void)
-{
- debug_decl(sudo_mkgrcache, SUDOERS_DEBUG_NSS)
-
- if (grcache_bygid == NULL)
- grcache_bygid = rbcreate(cmp_grgid);
- if (grcache_byname == NULL)
- grcache_byname = rbcreate(cmp_grnam);
- if (grlist_cache == NULL)
- grlist_cache = rbcreate(cmp_grnam);
- if (grcache_bygid == NULL || grcache_byname == NULL || grlist_cache == NULL)
- debug_return_int(-1);
-
- debug_return_int(0);
-}
-
void
sudo_freegrcache(void)
{
struct rbnode *node;
debug_decl(sudo_get_grlist, SUDOERS_DEBUG_NSS)
+ if (grlist_cache == NULL) {
+ grlist_cache = rbcreate(cmp_grnam);
+ if (grlist_cache == NULL) {
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
+ debug_return_ptr(NULL);
+ }
+ }
+
key.k.name = pw->pw_name;
getauthregistry(pw->pw_name, key.registry);
if ((node = rbfind(grlist_cache, &key)) != NULL) {
struct rbnode *node;
debug_decl(sudo_set_grlist, SUDOERS_DEBUG_NSS)
+ if (grlist_cache == NULL) {
+ grlist_cache = rbcreate(cmp_grnam);
+ if (grlist_cache == NULL) {
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
+ debug_return_int(-1);
+ }
+ }
+
/*
* Cache group db entry if it doesn't already exist
*/