public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* question about NSS [SUCCESS=merge] semantics
@ 2017-05-01 18:58 DJ Delorie
  2017-05-01 19:19 ` Stephen Gallagher
  0 siblings, 1 reply; 2+ messages in thread
From: DJ Delorie @ 2017-05-01 18:58 UTC (permalink / raw)
  To: libc-alpha; +Cc: Stephen Gallagher


If two services both have the same user in a given group, and the
merge feature needs to merge them, do we de-duplicate the user or not?
Do we also dedup the groups when enumerating?

The wiki proposing the feature says to dedup, but neither the man page
nor the patch submission mentions it.

I.e.

group	test1 [SUCCESS=merge] test2

with...

test1:  mygroup::4:alpha,beta,gamma

test2:  mygroup::4:alpha,delta

There are two interesting cases (well, three):

getgrgid(4) -> alpha,beta,gamma,delta
-OR-
getgrgid(4) -> alpha,beta,gamma,alpha,delta

and also:

getgrent() returns which?

mygroup:4:alpha,beta,gamma,delta
-OR-
mygroup:4:alpha,beta,gamma,alpha,delta
-OR-
mygroup:4:alpha,beta,gamma,delta
mygroup:4:alpha,delta

(i.e. two parts: dedup users, and/or dedup groups)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: question about NSS [SUCCESS=merge] semantics
  2017-05-01 18:58 question about NSS [SUCCESS=merge] semantics DJ Delorie
@ 2017-05-01 19:19 ` Stephen Gallagher
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Gallagher @ 2017-05-01 19:19 UTC (permalink / raw)
  To: DJ Delorie, libc-alpha


[-- Attachment #1.1: Type: text/plain, Size: 2997 bytes --]

On 05/01/2017 02:58 PM, DJ Delorie wrote:
> If two services both have the same user in a given group, and the
> merge feature needs to merge them, do we de-duplicate the user or not?
> Do we also dedup the groups when enumerating?
> 

We do not deduplicate. That was dropped from the plan because it introduced
unacceptably poor performance to address an edge-case. I also deemed it
reasonable to drop on the grounds that we have the same problem already if
someone was to duplicate results directly in /etc/passwd.


Basically, the performance hit would have been both with having to process
through the membership lists (which may have hundreds or thousands of messages)
as well as managing the memory for the buffer. I chose to match the way that
glibc was handling initgroups lookups (which also does no deduplication, just
tacks the results on at the end.


> The wiki proposing the feature says to dedup, but neither the man page
> nor the patch submission mentions it.
> 
> I.e.
> 
> group	test1 [SUCCESS=merge] test2
> 
> with...
> 
> test1:  mygroup::4:alpha,beta,gamma
> 
> test2:  mygroup::4:alpha,delta
> 
> There are two interesting cases (well, three):
> 
> getgrgid(4) -> alpha,beta,gamma,delta
> -OR-
> getgrgid(4) -> alpha,beta,gamma,alpha,delta

You should expect to get back:
mygroup::4:alpha,beta,gamma,alpha,delta


> 
> and also:
> 
> getgrent() returns which?
> 
> mygroup:4:alpha,beta,gamma,delta

No

> -OR-
> mygroup:4:alpha,beta,gamma,alpha,delta

No


> -OR-
> mygroup:4:alpha,beta,gamma,delta
> mygroup:4:alpha,delta
> 

Yes (which is exactly the way enumerated group lookups have always worked if
there were multiple copies of the group name/ID in one or more data sources).

For example, if you take [SUCCESS=merge] out of the equation, it will behave in
exactly the same way as it does here: it will call the reentrant function for
each source and iterate through them one at a time, returning them in order as
it goes. You can reproduce this even just with nss_files: if you have
```
mygroup::4:alpha,beta,gamma
mygroup::4:alpha,delta
```
in /etc/group, `getent group |grep mygroup` will return two lines, one with each
result. The same would be true if you had one or the other of them in nss_nis or
nss_ldap etc.

Deduplicating this information would be significantly memory-intensive and
poorly-performing, because we would have to first loop through all possible
results (which has no upper bound on number of entries and may require accessing
multiple remote data sources which might be very slow), then iterate through
each one looking for commonalities, then rewrite the buffers containing each of
the membership lists.

This is just one in a long list of reasons why the IDM teams (FreeIPA, Samba and
SSSD) all strongly recommend disabling enumeration for remote sources (and set
it that way by default).

> (i.e. two parts: dedup users, and/or dedup groups)
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-01 19:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-01 18:58 question about NSS [SUCCESS=merge] semantics DJ Delorie
2017-05-01 19:19 ` Stephen Gallagher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).