Question about getgrent_list

Simo Sorce idra at
Sat Sep 15 03:00:02 GMT 2001

On Fri, Sep 14, 2001 at 08:37:22PM +0200, andreas moroder wrote:
> Hello,
> In rpc_server/svr_samr_nt.c I found the following comment
> /* use getgrent_list() to retrieve the list of groups to avoid
>  * problems with getgrent possible infinite loop by internal
>  * libc grent structures overwrites by called functions */
> but I can not find the reason this should happen. In the loop following this 
> statement no function is called that does access group entries.
> If the statement is no longer valid it would be possible to optimize 
> get_group_alias_entries because there would be no need to create a temporary 
> list of group entries. ( getgrent_list is only used in this place )
> Bye
> Andreas

Hi, andreas, I introduced this function after I found the bug while testing
ACL code. The getgrent_list should be used to avoid present and possibile
future problems if you call other functions in the loop, because you do not
know what they call, or what they may call in future.
Better avoid to have this kind of problems.
At the time one of the called functions, was calling a pdb_XX function that
performed a getpw function, and that made the process loop endlessly by
clearing some sort of pointer in the internal libc structures and making
getgrent loop infinetly through the group db restarting before reaching the
I prefer to loose some performance than risk a potential bug.

Simo Sorce       idra at
Samba Team

More information about the samba-technical mailing list