Bug 681020 - pwconv and pwunconv alter uids over 2147483647
pwconv and pwunconv alter uids over 2147483647
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: shadow-utils (Show other bugs)
5.6
i386 Linux
urgent Severity urgent
: rc
: ---
Assigned To: Peter Vrabec
Milos Malik
: Patch, ZStream
Depends On:
Blocks: 690830
  Show dependency treegraph
 
Reported: 2011-02-28 15:19 EST by Jeff Bastian
Modified: 2012-11-06 09:38 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-02-21 01:16:49 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
patch to fix pwconv and pwconv handling of large uids and gids (2.50 KB, patch)
2011-02-28 17:51 EST, Jeff Bastian
no flags Details | Diff

  None (edit)
Description Jeff Bastian 2011-02-28 15:19:46 EST
Description of problem:
On 32-bit systems, the pwconv and pwunconv utilities convert all uids greater than 2147483647 to just 2147483647.

Version-Release number of selected component (if applicable):
shadow-utils-4.0.17-18.el5.i386

How reproducible:
every time

Steps to Reproduce:
1. useradd -u 3000000000 -c "Big ID" bigid
2. id -u bigid ; id -g bigid
3. pwunconv
4. id -u bigid ; id -g bigid
  
Actual results:
uid and gid changed to 2147483647

Expected results:
uid and gid are preserved at 3000000000

Additional info:
See bug 505033 for useradd supporting uid > 2147483647
Comment 1 Jeff Bastian 2011-02-28 16:26:05 EST
I re-compiled shadow-utils-4.1.4.2-9 from RHEL 6 on my RHEL 5.6 system and tested it and found that pwconv and pwunconv work correctly.
Comment 2 Jeff Bastian 2011-02-28 17:51:25 EST
Created attachment 481463 [details]
patch to fix pwconv and pwconv handling of large uids and gids

The problem is the sgetpwent() and sgetgrent() functions from lib/sgetpwent.c and lib/sgetgrent.c use strtol() (or atoi() which calls strtol()) to convert the uid and gid to long ints which caps the uid to 2^31-1.

Newer versions of shadow-utils have get_uid() and get_gid() functions in lib/* that use strtoll().

I tried adding lib/get_uid.c and lib/get_gid.c to RHEL 5 shadow-utils but this conflicts with other static copies of get_uid() and get_gid() found in src/{user,group}{add,mod}.c so I just copied the functions directly into lib/sgetpwent.c and lib/sgetgrent.c as static functions.

See the attached patch.
Comment 4 Jeff Bastian 2011-02-28 17:56:32 EST
Testing the patch from comment 2 shows it correctly preserves uid > 2147483647:

[root@localhost ~]# rpm -q shadow-utils
shadow-utils-4.0.17-18.el5.bz681020.i386

[root@localhost ~]# id -u bigid ; id -g bigid
3000000000
3000000000

[root@localhost ~]# pwunconv

[root@localhost ~]# id -u bigid ; id -g bigid
3000000000
3000000000

[root@localhost ~]# pwconv

[root@localhost ~]# id -u bigid ; id -g bigid
3000000000
3000000000
Comment 9 errata-xmlrpc 2012-02-21 01:16:49 EST
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0244.html

Note You need to log in before you can comment on or make changes to this bug.