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. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat
pgpg8HlgfmOmb.pgp
Description: PGP signature