Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 156511 - sys-auth/nss_ldap - "getent -s ldap" does not work
Summary: sys-auth/nss_ldap - "getent -s ldap" does not work
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo LDAP project
URL: http://bugzilla.padl.com/show_bug.cgi...
Whiteboard:
Keywords:
Depends on:
Blocks: 147625
  Show dependency tree
 
Reported: 2006-11-28 07:00 UTC by Kevin Bryan
Modified: 2007-09-26 19:45 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Bryan 2006-11-28 07:00:10 UTC
# cat /etc/nsswitch.conf 
...
passwd:      files nis ldap
...

# getent passwd username
username:x:10000:600:User Name:/home/username:/bin/bash

# getent -s ldap passwd username -> hangs

Running strace against it shows that it gets stuck on a futex.  This is the same with nss_ldap-239-r1 and nss_ldap-253. glibc-2.4-r4 with "nls nptl nptlonly".  getent with '-s file' or '-s nis' work fine.
Comment 1 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2006-11-28 13:38:29 UTC
1. and plain 'getent password username' ?
2. what is your ssl configuration in /etc/ldap.conf?
Comment 2 Kevin Bryan 2006-11-29 04:32:50 UTC
(In reply to comment #1)
> 1. and plain 'getent password username' ?
> 2. what is your ssl configuration in /etc/ldap.conf?
> 

1. As shown in the original report, 'getent passwd username' works fine.
2. /etc/ldap.conf has 'ssl no'.
Comment 3 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2006-11-29 12:47:11 UTC
base-system/vapier: did something change in glibc's nss stuff again?
getent -s ldap worked previously...

Kevin Bryan:
1. please provide the contents of your /etc/ldap.conf here, exluding the comments in it. 
2. if your uri/host lines uses a hostname, try with it in /etc/hosts, or try with an IP directly.
Comment 4 Kevin Bryan 2006-12-01 05:54:15 UTC
ldap.conf:
host ldap1.domain.tld ldap2.domain.tld
base dc=domain,dc=tld
rootbinddn cn=nssldap,ou=DSA,dc=domain,dc=tld
timelimit 30
bind_timelimit 30
bind_policy hard
idle_timelimit 3600
nss_base_passwd     dc=domain,dc=tld?sub
nss_base_shadow     dc=domain,dc=tld?sub
nss_base_group            ou=Groups,dc=domain,dc=tld?one
ssl no
sizelimit 0
pam_password md5

Adding ldap1.domain.tld and ldap3.domain.tld to /etc/hosts did not
change the behavior, nor did replacing it with an IP.  In both cases, strace shows it hanging on the futex.
Comment 5 SpanKY gentoo-dev 2006-12-02 15:48:29 UTC
no idea, i dont track nss stuff as i dont use it at all
Comment 6 simishag 2006-12-14 11:12:43 UTC
I'm not sure which bug is the best to note this on, but I've added a post at robbat's blog that may help:

http://robbat2.livejournal.com/199841.html

Basically it concerns the problems with nss_ldap 249 and timeout weirdness.
Comment 7 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2006-12-15 19:48:08 UTC
Upstream bug:
http://bugzilla.padl.com/show_bug.cgi?id=176

This is also responsible for Gentoo bug 147625.

While the upstream bug has not seen much response from Luke Howard, here is my theory about the futex.

If you do 'getent -s $SRC $TYPE', then /etc/nsswitch.conf is overridden, and $SRC is used instead. If you use a hostname for your LDAP server, this would mean that a circular loop exists, just as if you did 'getent -s ldap hosts', because regardless of what source you use, nss_ldap (via the ldap libraries) would be doing a hostname lookup to connect to the LDAP server.

Test these two nsswitch.conf configurations:
1.
passwd: files ldap
host: files dns
2.
passwd: files ldap
host: files dns ldap 
3.
passwd: files ldap
host: ldap files dns

#1 and #2 should work.
#3 should hang with the same futex.

simishag:
Your comment was incorrectly placed here. I responded to it on my blog.
Comment 8 Kevin Bryan 2006-12-16 17:19:27 UTC
1 corresponds to my setup, yet it still does not work.  I tested it on several other machines that I have.  Here's the results:

nss_ldap-239-r1 works with both pam_ldap 180 and 183.
neither nss_ldap-249 nor nss_ldap-253 work with pam_ldap 183.
Comment 9 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2006-12-16 18:02:09 UTC
I meant for you to test all 3 nsswitch.conf configurations that I posted.
Command to test is 'getent passwd' (notice NO -s ldap on purpose).
Comment 10 Kevin Bryan 2006-12-16 20:07:57 UTC
Yes, it acts as you suspect.  1 and 2 work fine, and 3 stops on a futex.
Comment 11 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2006-12-17 03:19:06 UTC
vapier:
ok, this proves there is a specific breakage in the genent application.

State BEFORE:
"getent -s $SRC $FOO" overrides nsswitch.conf for $FOO only, so that it would be the same as '$FOO: $SRC', but the other lines would be untouched.

State AFTER:
"getent -s $SRC $FOO" overrides ALL entries in nsswitch.conf, which is a problem as 'host: ldap' then has a circular loop in lookup (to connect to the LDAP server it needs to do the lookup, but for the lookup it needs to connect to LDAP). Specifically, gethostbyname() triggers the NSS lookup.

This is NOT a recent breakage in glibc, so it's going to be hard to find.
If you look at the upstream bug report, it was originally in debian's glibc-2.3.2.ds1-13.
Comment 12 Kevin Bryan 2007-09-26 19:45:33 UTC
(In reply to comment #11)
> vapier:
> ok, this proves there is a specific breakage in the genent application.
> 
> State BEFORE:
> "getent -s $SRC $FOO" overrides nsswitch.conf for $FOO only, so that it would
> be the same as '$FOO: $SRC', but the other lines would be untouched.
> 
> State AFTER:
> "getent -s $SRC $FOO" overrides ALL entries in nsswitch.conf, which is a
> problem as 'host: ldap' then has a circular loop in lookup (to connect to the
> LDAP server it needs to do the lookup, but for the lookup it needs to connect
> to LDAP). Specifically, gethostbyname() triggers the NSS lookup.

Apparently it's not breakage, it's an "undocumented feature."  No, seriously:

getent -s passwd:ldap passwd username

works fine.  If you just do:

getent -s ldap passwd username

then the -s takes affect for all databases.  Note that the getent --help (there is no man page) doesn't explain this.  Had to pull open getent.c and read the parse_option code (in glibc-2.5, anyways, probably the same in all "affected" versions).