Bug 681020 - pwconv and pwunconv alter uids over 2147483647
Summary: pwconv and pwunconv alter uids over 2147483647
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: shadow-utils
Version: 5.6
Hardware: i386
OS: Linux
urgent
urgent
Target Milestone: rc
: ---
Assignee: Peter Vrabec
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks: 690830
TreeView+ depends on / blocked
 
Reported: 2011-02-28 20:19 UTC by Jeff Bastian
Modified: 2018-11-14 14:14 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-02-21 06:16:49 UTC
Target Upstream Version:
Embargoed:


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


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2012:0244 0 normal SHIPPED_LIVE shadow-utils bug fix update 2012-02-20 15:07:21 UTC

Description Jeff Bastian 2011-02-28 20:19:46 UTC
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 21:26:05 UTC
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 22:51:25 UTC
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 22:56:32 UTC
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 06:16:49 UTC
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.