getgrouplist implementation compatible with kdelibs?

Michael Pyne mpyne at purinchu.net
Thu Apr 16 04:02:30 BST 2009


On Wednesday 15 April 2009 05:16:21 Adriaan de Groot wrote:
> On Wednesday 15 April 2009 08:32:25 Thiago Macieira wrote:
> > If it's not present, then we have to call getpwnam(3) to get
> > the UID and main GID, then iterate over getgrent(3) to get all groups to
> > which this user is present.
>
> Yeah, that's exactly the implementation I'm asking for (and perhaps we can
> add it to libkdefakes). I *have* such an implementation from FreeBSD, but
> it's licensed incompatibly. Hence my request for someone to pull it out of
> glibc (if LGPL) or otherwise I'll have to, um, close my eyes and do a clean
> room implementation of it or something :)

I've made an implementation based on the manual page description I have of 
getgrouplist, which is attached and licensed LGPL (which ever version works 
best for you, change the header if necessary).  The implementation uses 
functions which are not re-entrant and is therefore not threadsafe or re-
entrant.  I leave that as an exercise to the reader if it is necessary.

An example is included of its use as well (as least, as I understand it is 
supposed to be used).

Regards,
 - Michael Pyne
-------------- next part --------------
A non-text attachment was scrubbed...
Name: getgrouplist.c
Type: text/x-csrc
Size: 3379 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20090415/fd91ed54/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20090415/fd91ed54/attachment.sig>


More information about the kde-core-devel mailing list