This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/23680] Feature Request: Add functions to convert between UID and group name


https://sourceware.org/bugzilla/show_bug.cgi?id=23680

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |carlos at redhat dot com

--- Comment #1 from Carlos O'Donell <carlos at redhat dot com> ---
(In reply to Dylan Stephano-Shachter from comment #0)
> Currently, in glibc, the best way I am aware of to convert a gid to a group
> name is to run getgrgid(). The problem is this also fetches every user of
> the group. If the group is very large this can take a long time, especially
> if it is done over a network.
> 
> Would it be possible to add functions which could convert between between
> gid and name? Possibly along the lines of
> convertgrgid()
> convertgrnam()

These would just be wrappers around setgrent/getgrent/endgrent?

Fundamentally you have to iterate over all groups, find the one with the
matching group ID and return that. Thus your iteration could end early or be
forced to iterate the entire list.

> I would be willing to write the patch but I would like to know if it would
> even get accepted before I move forward.

Does setgrent/getgrent/endgrent solve hte problem for you?

We try hard not to add new functions to core libraries unless there is no
possible way to implement it without a combination of other functions.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]