useradd too slow with LDAP nsswitch

Bug #120015 reported by João Manuel Rodrigues
12
Affects Status Importance Assigned to Milestone
shadow (Ubuntu)
Fix Released
Wishlist
Kees Cook
Declined for Hardy by Daniel Holbach

Bug Description

Binary package hint: passwd

In a machine with nsswitch configured to used a LDAP server with around 50000 users, trying to add a new local user (with useradd) takes a really long time.

My /etc/nsswitch.conf contains this:
passwd: files ldap
group: files
shadow: files
hosts: files dns mdns
#hosts: dns [!UNAVAIL=return] files mdns #UA2006 ?
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis

An strace shows that useradd is fetching a full list of users from the server: on my system his takes a long time. Commenting out the "ldap" in nsswitch immediately solves the problem.

Maybe this is a feature but I can't see why adding a new user should need to verifiy every existing user.

Using the command newusers, there is no problem even with LDAP activated.

João Rodrigues

Related branches

Revision history for this message
João Manuel Rodrigues (jmr) wrote :

Forgot to say:
I'm using Ubuntu 6.06 but I recall similar behavior with a Mandrake 10.1 distro a few years ago. This is probably a upstream problem.

Some more info:
In my current setup, ldap is only used for the passwd DB --- Kerberos is used for authentication, so there is no need for shadow DB from nsswitch. I've installed libnss-ldap, but not libpam-ldap.

I tried creating users both with and without options specifying UID and GID:
   useradd johndoe
   useradd -u 1234 johndoe
   useradd -u 1234 -g 100 johndoe
All had the same problem. (I hoped that by specifying a UID only a single lookup would be made, but strace reveals the same behavior: fetching the full DB.)

Sorry for the typos in the previous comment.

João Rodrigues

Revision history for this message
Vince Busam (vbusam) wrote :

I can confirm this on hardy. The attached patch optimizes the case where useradd is passed a valid, unique username & id.

Revision history for this message
Matt T. Proud (matttproud-google) wrote :

Attached is a debdiff patch that reflects Vince Busam's changes for the latest shadow package in Hardy.

Please feel free to change the changelog entry as appropriate. I will be going abroad tomorrow, so it is likely that I will not be in a position to make trivial changes to the debdiff before the forthcoming code freeze.

I used update-maintainer and friends, so that stuff should be pretty well handled.

Revision history for this message
Daniel Holbach (dholbach) wrote :

Server Team: could you please take a look at it?

Revision history for this message
Daniel Holbach (dholbach) wrote :

Kees: can you take a look at it?

Revision history for this message
Kees Cook (kees) wrote :

This patch looks good. Once we're out of Beta Freeze, I will get this uploaded. Thanks!

Changed in shadow:
assignee: nobody → keescook
status: New → Triaged
Kees Cook (kees)
Changed in shadow:
importance: Undecided → Wishlist
Revision history for this message
Daniel Holbach (dholbach) wrote :

Kees: are you going to take a look at it?

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package shadow - 1:4.0.18.2-1ubuntu2

---------------
shadow (1:4.0.18.2-1ubuntu2) hardy; urgency=low

  * Add 498_make_useradd_faster_with_ldap: make useradd faster when
    nsswitch uses LDAP or some other remote names database (LP: #120015),
    thanks to Vince Busam.

 -- <email address hidden> (Matt T. Proud) Fri, 08 Feb 2008 18:30:51 -0800

Changed in shadow:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.