X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:date:from:to:subject:message-id:reply-to
	:references:mime-version:content-type:in-reply-to; q=dns; s=
	default; b=B8M3E9glqYNMKTURarKNPg2fUEUXgnqntjVNRBGp9l5tXBkLPRmHV
	oM+e1DJAxRpdYbC6LwNbdu+IZD13ZSMqQS9Si+7EzHL2jxpPpE8r6M5adh35Yfz+
	1qTNAf4Q287TGfQ8MHaBDMJ+8QAGw0x4GSx4jSX8PXedUYDsXQxkp0=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:date:from:to:subject:message-id:reply-to
	:references:mime-version:content-type:in-reply-to; s=default;
	 bh=tcKFOSJ0G6jFkxwfJzKlF4H5rI0=; b=QvNEIobKC3QbK4ldHIPsygicLZF+
	598jBw5WnM4aD8T0spsdCf+YMdBIOfkpn6y4lgKuqVWTw7DK8OIh/v2xlSbfvaMf
	wOzR85vYUgj2BJXiYVvb3fmAVW7DRB6DsKNw17wLV+hau13mCoAST8Azwej5R6AX
	gqy04H1L2JkJFC8=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-6.0 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2
X-HELO: calimero.vinschen.de
Date: Wed, 12 Feb 2014 20:59:31 +0100
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: get rid of getpwent? (Was: cygwin-1.7.28 getpwent header declaration changes ?)
Message-ID: <20140212195931.GA2246@calimero.vinschen.de>
Reply-To: cygwin@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
References: <8B7B5FE0-7413-4358-BA8A-E0B6E0B17653@etr-usa.com> <52F8B50E.7040307@lysator.liu.se> <52F92D58.9030408@etr-usa.com> <52F95D1D.4050108@tiscali.co.uk> <4510121021.20140211062515@mtu-net.ru> <52FAB14C.8060800@tiscali.co.uk> <52FABAF5.2060701@etr-usa.com> <52FAD730.9090507@redhat.com> <20140212090804.GM2821@calimero.vinschen.de> <52FB9E51.7030607@cornell.edu>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;	protocol="application/pgp-signature"; boundary="h31gzZEtNLTqOjlF"
Content-Disposition: inline
In-Reply-To: <52FB9E51.7030607@cornell.edu>
User-Agent: Mutt/1.5.21 (2010-09-15)

--h31gzZEtNLTqOjlF
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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.
>=20
> 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

--=20
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--h31gzZEtNLTqOjlF
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJS+9KjAAoJEPU2Bp2uRE+gm5QP/is6gP4XYLiiljshs383O2Kc
2f4qHUiFZ0IvzfIV+GkUW93X5bdqLet5fdO0O6ELZssXn+uPgHzsX4gp1sGMoIZi
3UW3EESB/rbpsFKCuMQof0FEty+v7UZLxBA8kWBVwPTp+uLnV2+460uZBsiLu9OI
MqzXdnBPnKcKGo+5QslCfTrjxHr6MZ9vX/pQy5NeV5QcrSfmqHmyoimoPm/c1FBX
nCkrqSKgDiHU0aqA/UgmajWAi+tku6sFvT9Qmcew9sQAhaFZZFuIswmVI1xF8grU
00j1M3inzdd9KsaqUm8r4enTuIfPAbsBN9DD4k4kv8rKPM5otfW6KZ/TLoLDbwtp
7FECwTXuCYqGHQHv4uEJ+cGQqWdVljhCgbyqpOUW8UfOZQQa0F1ATtS7UNqcdzAi
a0UxILlbyOMwXR687UkdThDtUb1IS7Wj7Uzv/XuF/tiT0SvWRwuJoSWbtEOv66+4
kwl7FuQd1E3IXYG+6zyoJ81SSgc9ZwLlYQUAF4iGBiVqjamvxyYDOGBnz0uC7h8n
lyy3Ge0rLz3IHhgaMx/7LRXYDuBSHw5Gl1ox4NlXpPVSKMhXwquArPerjK71etVT
cpADUK7CNnOtIhS+ze7aCUdsXfR7gKJIDGWMicTndtFPOJcYE5G6Fp8TNwoDJxcx
+YXQUN8829lQvCY7mehT
=ba2j
-----END PGP SIGNATURE-----

--h31gzZEtNLTqOjlF--
