From be7c51d27abf6c1a269a3f42a96c86f7c0016dec Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Sun, 3 Feb 2008 16:51:08 +0000 Subject: [PATCH] New function to find a group by its GID on the local database. --- ChangeLog | 2 ++ lib/groupio.c | 12 ++++++++++++ lib/groupio.h | 2 ++ 3 files changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index 42dcf688..f4593305 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * lib/pwio.c, lib/pwio.h: New function to find an user by its UID on the local database. + * lib/groupio.c, lib/groupio.h: New function to find a group by + its GID on the local database. 2008-02-02 Nicolas François diff --git a/lib/groupio.c b/lib/groupio.c index 9d9b3d30..9839819e 100644 --- a/lib/groupio.c +++ b/lib/groupio.c @@ -113,6 +113,18 @@ const struct group *gr_locate (const char *name) return commonio_locate (&group_db, name); } +const struct group *gr_locate_gid (gid_t gid) +{ + const struct group *grp; + + gr_rewind (); + while ( ((grp = gr_next ()) != NULL) + && (grp->gr_gid != gid)) { + } + + return grp; +} + int gr_update (const struct group *gr) { return commonio_update (&group_db, (const void *) gr); diff --git a/lib/groupio.h b/lib/groupio.h index e2b5d04e..2d587a58 100644 --- a/lib/groupio.h +++ b/lib/groupio.h @@ -1,5 +1,7 @@ +#include extern int gr_close (void); extern const struct group *gr_locate (const char *); +extern const struct group *gr_locate_gid (gid_t gid); extern int gr_lock (void); extern int gr_name (const char *); extern const struct group *gr_next (void);