From: nekral-guest Date: Sun, 3 Feb 2008 16:50:14 +0000 (+0000) Subject: New function to find an user by its UID on the local database. X-Git-Tag: 4.1.1~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7344e055be934288a15910b0a22fd2828c8c363b;p=thirdparty%2Fshadow.git New function to find an user by its UID on the local database. --- diff --git a/ChangeLog b/ChangeLog index e0f424168..42dcf6889 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-02-03 Nicolas François + + * lib/pwio.c, lib/pwio.h: New function to find an user by + its UID on the local database. + 2008-02-02 Nicolas François * po/*.po: Updated PO files. diff --git a/lib/pwio.c b/lib/pwio.c index 8dd6d61a0..328ce3267 100644 --- a/lib/pwio.c +++ b/lib/pwio.c @@ -96,6 +96,18 @@ const struct passwd *pw_locate (const char *name) return commonio_locate (&passwd_db, name); } +const struct passwd *pw_locate_uid (uid_t uid) +{ + const struct passwd *pwd; + + pw_rewind (); + while ( ((pwd = pw_next ()) != NULL) + && (pwd->pw_uid != uid)) { + } + + return pwd; +} + int pw_update (const struct passwd *pw) { return commonio_update (&passwd_db, (const void *) pw); diff --git a/lib/pwio.h b/lib/pwio.h index e060ed051..42082ebd4 100644 --- a/lib/pwio.h +++ b/lib/pwio.h @@ -1,5 +1,7 @@ +#include extern int pw_close (void); extern const struct passwd *pw_locate (const char *); +extern const struct passwd *pw_locate_uid (uid_t uid); extern int pw_lock (void); extern int pw_name (const char *); extern const struct passwd *pw_next (void);