diff options
Diffstat (limited to 'libc/pwd_grp/getgrgid.c')
-rw-r--r-- | libc/pwd_grp/getgrgid.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/libc/pwd_grp/getgrgid.c b/libc/pwd_grp/getgrgid.c index 1eaed64c0..dc9176d39 100644 --- a/libc/pwd_grp/getgrgid.c +++ b/libc/pwd_grp/getgrgid.c @@ -26,18 +26,27 @@ struct group *getgrgid(const gid_t gid) { - struct group *group; - int grp_fd; + struct group *group; + int grp_fd; - if ((grp_fd = open(_PATH_GROUP, O_RDONLY)) < 0) - return NULL; + if ((grp_fd = open(_PATH_GROUP, O_RDONLY)) < 0) + return NULL; - while ((group = __getgrent(grp_fd)) != NULL) - if (group->gr_gid == gid) { - close(grp_fd); - return group; - } + while ((group = __getgrent(grp_fd)) != NULL) + if (group->gr_gid == gid) { + close(grp_fd); + return group; + } + + close(grp_fd); + return NULL; +} + +#if 0 +/* Search for an entry with a matching group ID. */ +int getgrgid_r (gid_t gid, struct group *resultbuf, char *buffer, + size_t buflen, struct group **result) +{ - close(grp_fd); - return NULL; } +#endif |