empty fields in shadow handled wrongly

Bug #513497 reported by James Pharaoh
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
libnss-extrausers (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: libnss-extrausers

When reading shadow, integer fields are read with strtol directly. This produces 0 for an empty field. However, in many cases a -1 should be used for an empty field. This is certainly the case for account expiry, the final field. This can be seen in the code in glibc which loads these fields:

eglibc-2.10.1/shadow/sgetspent_r.c:

         INT_FIELD_MAYBE_NULL (result->sp_expire, ISCOLON, 0, 10, (long int),
                               (long int) -1);

In the definition of INT_FIELD_MAYBE_NULL the last field is called default.

pam_unix is interpreting this 0 value as an account expiring on the 1st of January 1970 which of course is always in the past and so all accounts are appearing expired.

Other fields which default to -1 are sp_lstchg, sp_min, sp_max, sp_warn and sp_inact.

A workaround for this is to set a value in this field.

I wonder if it's actually possible to use the shadow reading code in glibc instead of doing this separately? I don't have time to look into that now anyway.

Tags: patch
Revision history for this message
Nikolaus Rath (nikratio) wrote :

Reproduced here.

Changed in libnss-extrausers (Ubuntu):
status: New → Confirmed
Revision history for this message
Nikolaus Rath (nikratio) wrote :

Inline patch has whitespace messed up by launchpad, here is a working version.

tags: added: patch
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package libnss-extrausers - 0.2-3ubuntu1

---------------
libnss-extrausers (0.2-3ubuntu1) lucid; urgency=low

  * empty fields in shadow handled wrongly (LP: #513497)
    Patch provided by Nikolaus Rath <email address hidden>
    Thx Nikolaus
 -- Stephan Hermann <email address hidden> Wed, 10 Feb 2010 12:39:08 +0000

Changed in libnss-extrausers (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Nikolaus Rath (nikratio) wrote :

JFTR: The patch wasn't from me but from James, the initial reporter. I just reuploaded it as an attachment so that Launchpad doesn't mess up the whitespace.

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.