Fix username/groupname cache so it returns a name that

was just looked up by get{pw,gr}id().  Otherwise, it
returns a NULL name unless it's already in the cache.

Credit to Juergen Lock.
This commit is contained in:
Tim Kientzle 2004-04-23 16:33:51 +00:00
parent 9214908dca
commit 7e02198e95

View file

@ -1113,6 +1113,7 @@ lookup_uname(struct bsdtar *bsdtar, uid_t uid)
} else if (pwent->pw_name != NULL && pwent->pw_name[0] != '\0') {
cache->cache[slot].name = strdup(pwent->pw_name);
cache->cache[slot].id = uid;
return (cache->cache[slot].name);
}
return (NULL);
}
@ -1146,6 +1147,7 @@ lookup_gname(struct bsdtar *bsdtar, gid_t gid)
} else if (grent->gr_name != NULL && grent->gr_name[0] != '\0') {
cache->cache[slot].name = strdup(grent->gr_name);
cache->cache[slot].id = gid;
return (cache->cache[slot].name);
}
return (NULL);
}