Standardize minvalue for ipasearchrecordlimit and ipasesarchsizelimit for unlimited minvalue

https://fedorahosted.org/freeipa/ticket/4023

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
Gabe
2015-09-21 06:55:17 -06:00
committed by Jan Cholasta
parent a94f3e5be8
commit 65e958fda4
6 changed files with 25 additions and 20 deletions

View File

@@ -2446,7 +2446,7 @@
"attribute": true,
"class": "Int",
"deprecated_cli_aliases": [],
"doc": "Maximum amount of time (seconds) for a search (> 0, or -1 for unlimited)",
"doc": "Maximum amount of time (seconds) for a search (-1 or 0 is unlimited)",
"flags": [
"nonempty"
],
@@ -2460,7 +2460,7 @@
"attribute": true,
"class": "Int",
"deprecated_cli_aliases": [],
"doc": "Maximum number of records to search (-1 is unlimited)",
"doc": "Maximum number of records to search (-1 or 0 is unlimited)",
"flags": [
"nonempty"
],
@@ -24018,4 +24018,4 @@
"methods": {},
"objects": {}
}
}
}

View File

@@ -498,7 +498,7 @@
{
"class": "Int",
"deprecated_cli_aliases": [],
"doc": "Maximum amount of time (seconds) for a search (> 0, or -1 for unlimited)",
"doc": "Maximum amount of time (seconds) for a search (-1 or 0 is unlimited)",
"flags": [],
"label": "Search time limit",
"maxvalue": 2147483647,
@@ -510,7 +510,7 @@
{
"class": "Int",
"deprecated_cli_aliases": [],
"doc": "Maximum number of records to search (-1 is unlimited)",
"doc": "Maximum number of records to search (-1 or 0 is unlimited)",
"flags": [],
"label": "Search size limit",
"maxvalue": 2147483647,
@@ -9158,4 +9158,4 @@
}
}
}
}
}

View File

@@ -2596,7 +2596,7 @@
"cli_name": "searchtimelimit",
"cli_short_name": null,
"default": null,
"doc": "Max. amount of time (sec.) for a search (> 0, or -1 for unlimited)",
"doc": "Max. amount of time (sec.) for a search (-1 or 0 is unlimited)",
"exclude": null,
"flags": [],
"hint": null,
@@ -2619,7 +2619,7 @@
"cli_name": "searchrecordslimit",
"cli_short_name": null,
"default": null,
"doc": "Max. number of records to search (-1 is unlimited)",
"doc": "Max. number of records to search (-1 or 0 is unlimited)",
"exclude": null,
"flags": [],
"hint": null,

View File

@@ -1927,14 +1927,14 @@ class LDAPSearch(BaseLDAPCommand, crud.Search):
takes_options = (
Int('timelimit?',
label=_('Time Limit'),
doc=_('Time limit of search in seconds'),
doc=_('Time limit of search in seconds (0 is unlimited)'),
flags=['no_display'],
minvalue=0,
autofill=False,
),
Int('sizelimit?',
label=_('Size Limit'),
doc=_('Maximum number of entries returned'),
doc=_('Maximum number of entries returned (0 is unlimited)'),
flags=['no_display'],
minvalue=0,
autofill=False,

View File

@@ -78,11 +78,6 @@ EXAMPLES:
register = Registry()
def validate_searchtimelimit(ugettext, limit):
if limit == 0:
raise ValidationError(name='ipasearchtimelimit', error=_('searchtimelimit must be -1 or > 1.'))
return None
@register()
class config(LDAPObject):
"""
@@ -150,16 +145,16 @@ class config(LDAPObject):
label=_('Default e-mail domain'),
doc=_('Default e-mail domain'),
),
Int('ipasearchtimelimit', validate_searchtimelimit,
Int('ipasearchtimelimit',
cli_name='searchtimelimit',
label=_('Search time limit'),
doc=_('Maximum amount of time (seconds) for a search (> 0, or -1 for unlimited)'),
doc=_('Maximum amount of time (seconds) for a search (-1 or 0 is unlimited)'),
minvalue=-1,
),
Int('ipasearchrecordslimit',
cli_name='searchrecordslimit',
label=_('Search size limit'),
doc=_('Maximum number of records to search (-1 is unlimited)'),
doc=_('Maximum number of records to search (-1 or 0 is unlimited)'),
minvalue=-1,
),
IA5Str('ipausersearchfields',
@@ -268,6 +263,16 @@ class config_mod(LDAPUpdate):
name=k, error=_('attribute "%s" not allowed') % a
)
# Set ipasearchrecordslimit to -1 if 0 is used
if 'ipasearchrecordslimit' in entry_attrs:
if entry_attrs['ipasearchrecordslimit'] is 0:
entry_attrs['ipasearchrecordslimit'] = -1
# Set ipasearchtimelimit to -1 if 0 is used
if 'ipasearchtimelimit' in entry_attrs:
if entry_attrs['ipasearchtimelimit'] is 0:
entry_attrs['ipasearchtimelimit'] = -1
for (attr, obj) in (('ipauserobjectclasses', 'user'),
('ipagroupobjectclasses', 'group')):
if attr in entry_attrs:

View File

@@ -183,8 +183,8 @@ class ldap2(CrudBackend, LDAPClient):
"""Get configured global limits, caching them for more calls"""
if not _lims:
config = self.get_ipa_config()
_lims['time'] = config.get('ipasearchtimelimit', [None])[0]
_lims['size'] = config.get('ipasearchrecordslimit', [None])[0]
_lims['time'] = int(config.get('ipasearchtimelimit', [None])[0])
_lims['size'] = int(config.get('ipasearchrecordslimit', [None])[0])
return _lims
_lims = {}