/*
- * Copyright (c) 1996, 1998-2005, 2007-2015
+ * Copyright (c) 1996, 1998-2005, 2007-2016
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
getauthregistry(IDtouser(uid), key.registry);
if ((node = rbfind(pwcache_byuid, &key)) != NULL) {
item = node->data;
- sudo_debug_printf(SUDO_DEBUG_DEBUG,
- "%s: uid %u [%s] -> user %s [%s] (cache hit)", __func__,
- (unsigned int)uid, key.registry,
- item->d.pw ? item->d.pw->pw_name : "unknown", item->registry);
goto done;
}
/*
item->refcnt = 0;
break;
}
- sudo_debug_printf(SUDO_DEBUG_DEBUG,
- "%s: uid %u [%s] -> user %s [%s] (cached)", __func__,
- (unsigned int)uid, key.registry,
- item->d.pw ? item->d.pw->pw_name : "unknown", item->registry);
done:
+ if (item->refcnt != 0) {
+ sudo_debug_printf(SUDO_DEBUG_DEBUG,
+ "%s: uid %u [%s] -> user %s [%s] (%s)", __func__,
+ (unsigned int)uid, key.registry,
+ item->d.pw ? item->d.pw->pw_name : "unknown",
+ item->registry, node ? "cache hit" : "cached");
+ }
item->refcnt++;
debug_return_ptr(item->d.pw);
}
getauthregistry((char *) name, key.registry);
if ((node = rbfind(pwcache_byname, &key)) != NULL) {
item = node->data;
- sudo_debug_printf(SUDO_DEBUG_DEBUG,
- "%s: user %s [%s] -> uid %d [%s] (cache hit)", __func__, name,
- key.registry, item->d.pw ? (int)item->d.pw->pw_uid : -1, item->registry);
goto done;
}
/*
item->refcnt = 0;
break;
}
- sudo_debug_printf(SUDO_DEBUG_DEBUG,
- "%s: user %s [%s] -> uid %d [%s] (cached)", __func__, name,
- key.registry, item->d.pw ? (int)item->d.pw->pw_uid : -1, item->registry);
done:
+ if (item->refcnt != 0) {
+ sudo_debug_printf(SUDO_DEBUG_DEBUG,
+ "%s: user %s [%s] -> uid %d [%s] (%s)", __func__, name,
+ key.registry, item->d.pw ? (int)item->d.pw->pw_uid : -1,
+ item->registry, node ? "cache hit" : "cached");
+ }
item->refcnt++;
debug_return_ptr(item->d.pw);
}
getauthregistry(NULL, key.registry);
if ((node = rbfind(grcache_bygid, &key)) != NULL) {
item = node->data;
- sudo_debug_printf(SUDO_DEBUG_DEBUG,
- "%s: gid %u [%s] -> group %s [%s] (cache hit)", __func__,
- (unsigned int)gid, key.registry,
- item->d.gr ? item->d.gr->gr_name : "unknown", item->registry);
goto done;
}
/*
item->refcnt = 0;
break;
}
- sudo_debug_printf(SUDO_DEBUG_DEBUG,
- "%s: gid %u [%s] -> group %s [%s] (cached)", __func__,
- (unsigned int)gid, key.registry,
- item->d.gr ? item->d.gr->gr_name : "unknown", item->registry);
done:
+ if (item->refcnt != 0) {
+ sudo_debug_printf(SUDO_DEBUG_DEBUG,
+ "%s: gid %u [%s] -> group %s [%s] (%s)", __func__,
+ (unsigned int)gid, key.registry,
+ item->d.gr ? item->d.gr->gr_name : "unknown",
+ item->registry, node ? "cache hit" : "cached");
+ }
item->refcnt++;
debug_return_ptr(item->d.gr);
}
getauthregistry(NULL, key.registry);
if ((node = rbfind(grcache_byname, &key)) != NULL) {
item = node->data;
- sudo_debug_printf(SUDO_DEBUG_DEBUG,
- "%s: group %s [%s] -> gid %u [%s] (cache hit)", __func__, name,
- key.registry, (unsigned int)item->d.gr->gr_gid, item->registry);
goto done;
}
/*
item->refcnt = 0;
break;
}
- sudo_debug_printf(SUDO_DEBUG_DEBUG,
- "%s: group %s [%s] -> gid %d [%s] (cache hit)", __func__, name,
- key.registry, item->d.gr ? (int)item->d.gr->gr_gid : -1, item->registry);
done:
+ if (item->refcnt != 0) {
+ sudo_debug_printf(SUDO_DEBUG_DEBUG,
+ "%s: group %s [%s] -> gid %d [%s] (%s)", __func__, name,
+ key.registry, item->d.gr ? (int)item->d.gr->gr_gid : -1,
+ item->registry, node ? "cache hit" : "cached");
+ }
item->refcnt++;
debug_return_ptr(item->d.gr);
}