Subject: Re: need for end*ent()?
To: John Nemeth <>
From: Jason Thorpe <>
List: tech-security
Date: 09/14/2005 10:30:39
On Sep 14, 2005, at 10:23 AM, Jason Thorpe wrote:

> On Sep 14, 2005, at 1:10 AM, John Nemeth wrote:
>>      getpwent_r() isn't called by the library, just getgrnam() and
>> getpwnam_r() (it will be getgrnam_r() when I'm done).
> Please test it, but I thought that getgrnam() kept its own state,  
> separate from the iterator API.

Hm, I just looked.

getgrnam_r() and getgrgid_r() use a local __grstate_files structure.   
Thus, they do not require the "end" (they do it internally).

getgrent_r(), on the other hand, uses the global _files_state  
instance.  That seems unfortunate (and hardly re-entrant).

Anyway, using getgrnam_r() from within libwrap should be perfectly  
safe, and you don't need any endgrent() step after it.

-- thorpej