Merge pull request #44444 from twangboy/win_lgpo_non_zero

LGPO: Issue with Maximum Password Age
This commit is contained in:
Mike Place 2017-11-10 10:26:53 -07:00 committed by GitHub
commit 60719d0683
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -710,7 +710,9 @@ class _policy_info(object):
'lgpo_section': self.password_policy_gpedit_path,
'Settings': {
'Function': '_in_range_inclusive',
'Args': {'min': 0, 'max': 86313600}
'Args': {'min': 1,
'max': 86313600,
'zero_value': 0xffffffff}
},
'NetUserModal': {
'Modal': 0,
@ -718,7 +720,9 @@ class _policy_info(object):
},
'Transform': {
'Get': '_seconds_to_days',
'Put': '_days_to_seconds'
'Put': '_days_to_seconds',
'GetArgs': {'zero_value': 0xffffffff},
'PutArgs': {'zero_value': 0xffffffff}
},
},
'MinPasswordAge': {
@ -750,7 +754,7 @@ class _policy_info(object):
},
},
'PasswordComplexity': {
'Policy': 'Passwords must meet complexity requirements',
'Policy': 'Password must meet complexity requirements',
'lgpo_section': self.password_policy_gpedit_path,
'Settings': self.enabled_one_disabled_zero.keys(),
'Secedit': {
@ -2369,7 +2373,10 @@ class _policy_info(object):
'''
converts a number of seconds to days
'''
zero_value = kwargs.get('zero_value', 0)
if val is not None:
if val == zero_value:
return 0
return val / 86400
else:
return 'Not Defined'
@ -2379,7 +2386,10 @@ class _policy_info(object):
'''
converts a number of days to seconds
'''
zero_value = kwargs.get('zero_value', 0)
if val is not None:
if val == 0:
return zero_value
return val * 86400
else:
return 'Not Defined'
@ -2491,9 +2501,11 @@ class _policy_info(object):
def _in_range_inclusive(cls, val, **kwargs):
'''
checks that a value is in an inclusive range
The value for 0 used by Max Password Age is actually 0xffffffff
'''
minimum = 0
maximum = 1
minimum = kwargs.get('min', 0)
maximum = kwargs.get('max', 1)
zero_value = kwargs.get('zero_value', 0)
if isinstance(val, six.string_types):
if val.lower() == 'not defined':
@ -2503,12 +2515,8 @@ class _policy_info(object):
val = int(val)
except ValueError:
return False
if 'min' in kwargs:
minimum = kwargs['min']
if 'max' in kwargs:
maximum = kwargs['max']
if val is not None:
if val >= minimum and val <= maximum:
if minimum <= val <= maximum or val == zero_value:
return True
else:
return False
@ -2640,11 +2648,7 @@ class _policy_info(object):
or values
'''
log.debug('item == {0}'.format(item))
value_lookup = False
if 'value_lookup' in kwargs:
value_lookup = kwargs['value_lookup']
else:
value_lookup = False
value_lookup = kwargs.get('value_lookup', False)
if 'lookup' in kwargs:
for k, v in six.iteritems(kwargs['lookup']):
if value_lookup: