This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: get rid of getpwent? (Was: cygwin-1.7.28 getpwent header declaration changes ?)
- From: Christopher Faylor <cgf-use-the-mailinglist-please at cygwin dot com>
- To: cygwin at cygwin dot com
- Date: Wed, 12 Feb 2014 16:37:29 -0500
- Subject: Re: get rid of getpwent? (Was: cygwin-1.7.28 getpwent header declaration changes ?)
- Authentication-results: sourceware.org; auth=none
- References: <52F8B50E dot 7040307 at lysator dot liu dot se> <52F92D58 dot 9030408 at etr-usa dot com> <52F95D1D dot 4050108 at tiscali dot co dot uk> <4510121021 dot 20140211062515 at mtu-net dot ru> <52FAB14C dot 8060800 at tiscali dot co dot uk> <52FABAF5 dot 2060701 at etr-usa dot com> <52FAD730 dot 9090507 at redhat dot com> <20140212090804 dot GM2821 at calimero dot vinschen dot de> <52FB9E51 dot 7030607 at cornell dot edu> <20140212195931 dot GA2246 at calimero dot vinschen dot de>
- Reply-to: cygwin at cygwin dot com
On Wed, Feb 12, 2014 at 08:59:31PM +0100, Corinna Vinschen wrote:
>On Feb 12 11:16, Ken Brown wrote:
>> On 2/12/2014 4:08 AM, Corinna Vinschen wrote:
>> >On Feb 11 19:06, Eric Blake wrote:
>> >>On 02/11/2014 05:06 PM, Warren Young wrote:
>> >>>On 2/11/2014 16:25, David Stacey wrote:
>> >>>>getpwent() is called in three different places.
>> >>>
>> >>>To those of you who have investigated these code paths: do any of them
>> >>>look like they couldn't be replaced by getpwnam() or other calls that
>> >>>would let cygwin1.dll do single-record AD/SAM lookups, rather than
>> >>>whole-table/tree scans?
>> >>>
>> >>>That is, do any of these programs really need to visit every record in
>> >>>/etc/passwd?
>> >>
>> >>libreadline wants to know how to tab-complete ~foo; to do that, it has
>> >>to find all usernames beginning with foo. How would you do that without
>> >>visiting every single record?
>> >
>> >This seems to be the major usage of getpwent these days. The question
>> >is, how bad is it if only a handful entries, or even only a single one
>> >(of oneself) show up?
>> >
>> >Either way, implementing a full getpwent requires to return the local
>> >users, the users of the primary domain, and the users of all trusted
>> >domains. I know of domains with 200K users and there are probably
>> >bigger ones. How long should a search take when a user presses <TAB>
>> >after the ~? And then, shall the process running the getpwent actually
>> >cache all of them? This seems really excessive.
>>
>> What about the following compromise: If /etc/passwd exists, then
>> getpwent behaves as it does currently.
>
>This part is relatively easy to implement.
>
>> Otherwise, it returns a
>> handful of entries, or possibly just the current user.
>
>The handful entries would be the ones the process has cached at that
>point in time. The tricky part is that getpwent would have to keep
>track which entries from the file are in the cache so that those are not
>accidentally enumerated twice.
>
>> This gives
>> users a choice. If tab-completion in this situation is important to
>> them, they can keep their /etc/passwd file.
>
>There's only one tiny problem. Whatever I think about the full
>enumerate being right or wrong, I have this vague feeling that I'd like
>to have this implemented fully at one point. My cat disapproves, but we
>can't agree on everything, I guess. Another configuration option in
>/etc/nsswitch.conf might comfort her.
I don't know if this has been mentioned but would a cache help here,
i.e., nscd? I think that's how Linux deals with this type of situation.
cgf
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple