#3610 Leading zeros when specifying idrange or uid/gid results in wrong values assigned without warning
Opened 10 years ago by dpal. Modified 5 years ago

Ticket was cloned from Red Hat Bugzilla (product Red Hat Enterprise Linux 6): Bug 955685

Description of problem:
If you try to specify and idrange or an uid/gid using a leading zero, makes ipa
to use wrong values without warning

Version-Release number of selected component (if applicable):
RHEL 6.4
ipa-server-3.0.0-26.el6_4.2.x86_64

How reproducible:
Always

Steps to Reproduce:
1. A) Install an ipaserver using a leading zero in the idmax parameter:
ipa-server-install (.......) --idstart=0101000001 --idmax=9999999999
B) Try to add an ipa user using a leading zero in the uid or gid parameters:
ipa user-add --uid=0101000001 --gid=0101000001 --first=John --last=Smith
--random jsmith


Actual results:
A) The ipa server installation finished fine, but the idrange values are wrong:
[root@ipaserver ~]# grep dna /etc/dirsrv/slapd-SOMBREROROJO-COM/dse.ldif | grep
Value
dnaNextValue: 17039361
dnaMaxValue: 9999999999

[root@ipaserver ~]# ipa idrange-show SOMBREROROJO.COM_id_range | grep ID
  First Posix ID of the range: 17039361
  Number of IDs in the range: 9982960639

As a curiosity, event the invoked command showed in the ipaserver-install.log
shows the wrong values:
[root@ipaserver ~]# grep invoked /var/log/ipaserver-install.log
2013-04-23T08:41:36Z DEBUG /usr/sbin/ipa-server-install was invoked with
options: {'zone_refresh': 0, 'reverse_zone': None, 'realm_name':
'SOMBREROROJO.COM', 'create_sshfp': True, 'conf_sshd': True, 'conf_ntp': True,
'subject': None, 'no_forwarders': False, 'persistent_search': True,
'ui_redirect': True, 'domain_name': 'sombrerorojo.com', 'idmax': 9999999999,
'hbac_allow': False, 'no_reverse': False, 'dirsrv_pkcs12': None, 'unattended':
False, 'selfsign': False, 'trust_sshfp': False, 'external_ca_file': None,
'no_host_dns': False, 'http_pkcs12': None, 'zone_notif': False, 'forwarders':
[CheckedIPAddress('192.168.122.1')], 'idstart': 17039361, 'external_ca': False,
'ip_address': None, 'conf_ssh': True, 'serial_autoincrement': True, 'zonemgr':
None, 'setup_dns': True, 'host_name': 'ipaserver.sombrerorojo.com', 'debug':
False, 'external_cert_file': None, 'uninstall': False}

B) The user is added but with the wrong UID/GID:
[root@ipaserver ~]# ipa user-add --uid=0101000001 --gid=0101000001 --first=John
--last=Smith --random
User login [jsmith]:
-------------------
Added user "jsmith"
-------------------
  User login: jsmith
  First name: John
  Last name: Smith
  Full name: John Smith
  Display name: John Smith
  Initials: JS
  Home directory: /home/jsmith
  GECOS field: John Smith
  Login shell: /bin/sh
  Kerberos principal: jsmith@SOMBREROROJO.COM
  Email address: jsmith@sombrerorojo.com
  Random password: D5jiQEXUReSZ
  UID: 17039361
  GID: 17039361
  Password: True
  Kerberos keys available: True


Expected results:
An error message or the idrange,uid/gid paremeters set to the correct values
just removing the leading zeros

Additional info:

Metadata Update from @dpal:
- Issue assigned to someone
- Issue set to the milestone: Ticket Backlog

7 years ago

python treats a leading 0 as an octal value.

Metadata Update from @rcritten:
- Issue close_status updated to: None

5 years ago

This issue has been fixed in Python 3, too

>>> 010
  File "<stdin>", line 1
    010
      ^
SyntaxError: invalid token
>>> 0o10
8

It's still doing the wrong thing in master on F28 though:

$ ipa user-add --first=tim --last=user --uid=01000000 tuser


Added user "tuser"


[snip]
UID: 262144
GID: 262144

Login to comment on this ticket.

Metadata