Bug 510740

Summary: ipa pwpolicy maxlife: Need to define and enforce acceptable data ranges
Product: [Retired] freeIPA Reporter: Jenny Severance <jgalipea>
Component: ipa-admintoolsAssignee: Rob Crittenden <rcritten>
Status: CLOSED ERRATA QA Contact: Chandrasekar Kannan <ckannan>
Severity: medium Docs Contact:
Priority: high    
Version: 2.0CC: benl, dpal, jgalipea
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: freeipa-2.0.0-1.fc15 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-03-27 07:16:23 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 431020    

Description Jenny Severance 2009-07-10 14:32:15 UTC
Description of problem:

Right now there is no defined or enforced data ranges for maxlife.  You can
define the maximum password lifetime with positive integers up to
29999999.  This is unrealistic.



[root@jennyv2 ~]# ipa pwpolicy-mod --maxlife=3000000000
ipa: ERROR: non-public: TypeError: value: need a <type 'int'>; got 3000000000L (a <type 'long'>)
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/ipalib/backend.py", line 110, in execute
    result = self.Command[_name](*args, **options)
  File "/usr/lib/python2.4/site-packages/ipalib/plugable.py", line 410, in __call__
    return self['__call__'](*args, **kw)
  File "/usr/lib/python2.4/site-packages/ipalib/frontend.py", line 396, in __call__
    self.validate(**params)
  File "/usr/lib/python2.4/site-packages/ipalib/frontend.py", line 583, in validate
    param.validate(value)
  File "/usr/lib/python2.4/site-packages/ipalib/parameters.py", line 622, in validate
    self._validate_scalar(value)
  File "/usr/lib/python2.4/site-packages/ipalib/parameters.py", line 630, in _validate_scalar
    raise TypeError(
TypeError: value: need a <type 'int'>; got 3000000000L (a <type 'long'>)
ipa: ERROR: an internal error has occurred


Version-Release number of selected component (if applicable):
2.0

How reproducible:
always

Steps to Reproduce:
1. see description example
2.
3.
  
Actual results:
internal error when maxlife is defined over 299999999
values up to 299999999 are accepted

Expected results:
Proper error message and no traceback
only values up to realistic maximum password lifetime are accepted 


Additional info:

Comment 1 Pavel Zuna 2009-11-23 13:14:12 UTC
There is no traceback anymore. Even if MAX limits are set for parameters on IPA commands, values that do not fit the required types will produce this error message (but w/o traceback, so I think it's OK).

# ./ipa pwpolicy-mod --maxlife=3000000000
ipa: ERROR: invalid 'krbmaxpwdlife': need a <type 'int'>; got 3000000000L (a <type 'long'>)

# ./ipa pwpolicy-mod --maxlife=10000
ipa: ERROR: invalid 'krbmaxpwdlife': can be at most 1000

That's just the way the framework works - type checking precedes bound checking.

Comment 2 Pavel Zuna 2009-11-23 13:15:33 UTC
*** Bug 510739 has been marked as a duplicate of this bug. ***

Comment 3 Pavel Zuna 2009-11-23 13:16:33 UTC
*** Bug 510735 has been marked as a duplicate of this bug. ***

Comment 4 Jenny Severance 2011-06-10 19:59:27 UTC
verified

# ipa pwpolicy-mod --maxlife=3000000000
ipa: ERROR: invalid 'maxlife': can be at most 2147483647

# ipa pwpolicy-mod --maxlife=10000
  Group: global_policy
  Max lifetime (days): 10000
  Min lifetime (hours): 24
  History size: 0
  Character classes: 0
  Min length: 8
  Max failures: 6
  Failure reset interval: 60
  Lockout duration: 600

[root@dhcp-100-19-202 data]# ipa pwpolicy-mod --maxlife=2147483648
ipa: ERROR: invalid 'maxlife': can be at most 2147483647

# ipa pwpolicy-mod --maxlife=-1
ipa: ERROR: invalid 'maxlife': must be at least 0

# rpm -qi ipa-server | head
Name        : ipa-server                   Relocations: (not relocatable)
Version     : 2.0.0                             Vendor: Red Hat, Inc.
Release     : 23.el6                        Build Date: Wed 20 Apr 2011 09:57:13 AM EDT
Install Date: Thu 19 May 2011 12:47:52 PM EDT      Build Host: x86-003.build.bos.redhat.com
Group       : System Environment/Base       Source RPM: ipa-2.0.0-23.el6.src.rpm
Size        : 2565882                          License: GPLv3+
Signature   : RSA/8, Thu 21 Apr 2011 03:48:25 PM EDT, Key ID 199e2f91fd431d51
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
URL         : http://www.freeipa.org/
Summary     : The IPA authentication server