nss_ldap and openldap on the same server.

Gerhard Schmidt estartu at augusta.de
Tue Mar 13 08:34:46 UTC 2007

On Tue, Mar 13, 2007 at 09:08:34AM +0100, Joerg Pulz wrote:
> Hash: SHA1
> On Tue, 13 Mar 2007, Gerhard Schmidt wrote:
> >On Tue, Mar 13, 2007 at 12:07:15AM +0100, Pietro Cerutti wrote:
> >>On 3/12/07, Gerhard Schmidt <estartu at augusta.de> wrote:
> >>>Hi,
> >>Hello,
> >>
> >>>As I see it, nss asks all sources even if the frist one allready knows 
> >>>the
> >>>answer. Is there a way to change this.
> >>
> >>man nsswitch.conf(5)
> >>Look for Status codes and Actions
> >
> >Doesn't work. Tried the follwing nsswitch.conf
> >group: files [success=return] ldap
> >hosts: files dns
> >networks: files
> >passwd: files [success=return] ldap
> >shells: files
> >
> >This doesn't change the delay. And the nss_ldap timeout is still reported.
> >This is not supprising because the manpage states [success=return] is
> >default.
> >
> >Seams there is a bug somewhere.
> AFAICT, there is no bug.
> The behavior is completely correct as a look into the openldap code turns 
> out.
> When starting up slapd, it tries to switch the credentials to the user and 
> group specified, normally ldap:ldap. Therefor it uses getpwuid(3), 
> getpwnam(3), getgrgid(3) and getgrnam(3) functions. If lookup for the user 
> and group specified is okay, it then calls getuid(3) and initgroups(3).
> Reading initgroups(3) turns out the following:
> The initgroups() function uses the getgrouplist(3) function to calculate
> the group access list for the user specified in name.
> Reading getgrouplist(3) turns out the following:
> The getgrouplist() function reads through the group file and calculates
> the group access list for the user specified in name.
> [...]
> The getgrouplist() function uses the routines based on getgrent(3).
> Reading getgrent(3) turns out the following:
> The getgrent() function sequentially reads the group database and is
> intended for programs that wish to step through the complete list of
> groups.
> [...]
> The getgrent() and getgrent_r() functions make no attempt to suppress 
> duplicate information if multiple sources are specified in 
> nsswitch.conf(5).
> So after following the way through all man pages, it turns out that the 
> behavior is fully correct as a lookup is done to find out all groups to 
> which the specified slapd user belongs to. This includes lookups using 
> nss_ldap when ldap is configured as source for groups in nsswitch.conf.
> As a side note, a short look into the bind and cron source turns out that 
> these, and probably others too, also use the initgroups(3) function.

yes. But still there is something missing. The Admin should have controll
over this behavior. The reasonable default action for groups should be 
success=continue to go though all group sources. But the admin should
still have the posibility to stop the process on success which is not
possible right now.  


Gerhard Schmidt    | Nick : estartu      IRC : Estartu  |
Fischbachweg 3     |                                    |  PGP Public Key
86856 Hiltenfingen | EMail: estartu at augusta.de          |  on request 
Germany            | 					|  
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 305 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20070313/f893daf5/attachment.pgp

More information about the freebsd-questions mailing list