summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2013-02-14 07:23:06 -0500
committerMartin Kosek <mkosek@redhat.com>2013-02-22 17:20:34 +0100
commitda42daac2929972889aa42ec3a6d82a1aca4f1d7 (patch)
tree622048c0d43f9d2c57a98e1afed1d96065d8672c /ipalib
parent49beb8cd3a752322285aa21a94306f7b99bcfae8 (diff)
downloadfreeipa-da42daac2929972889aa42ec3a6d82a1aca4f1d7.tar.gz
freeipa-da42daac2929972889aa42ec3a6d82a1aca4f1d7.tar.xz
freeipa-da42daac2929972889aa42ec3a6d82a1aca4f1d7.zip
Fix permission validation and normalization in aci.py
The code split the permission string on commas, essentially doing poor man's CSV parsing. So if a permission contained a comma-separated list of valid permissions, validation would pass but we'd get errors later. https://fedorahosted.org/freeipa/ticket/3420
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/plugins/aci.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/ipalib/plugins/aci.py b/ipalib/plugins/aci.py
index a97bb48b0..665a7ec46 100644
--- a/ipalib/plugins/aci.py
+++ b/ipalib/plugins/aci.py
@@ -392,21 +392,18 @@ def _find_aci_by_name(acis, aciprefix, aciname):
return a
raise errors.NotFound(reason=_('ACI with name "%s" not found') % aciname)
-def validate_permissions(ugettext, permissions):
- valid_permissions = []
- permissions = permissions.split(',')
- for p in permissions:
- p = p.strip().lower()
- if not p in _valid_permissions_values:
- return '"%s" is not a valid permission' % p
-def _normalize_permissions(permissions):
+def validate_permissions(ugettext, perm):
+ perm = perm.strip().lower()
+ if perm not in _valid_permissions_values:
+ return '"%s" is not a valid permission' % perm
+
+
+def _normalize_permissions(perm):
valid_permissions = []
- permissions = permissions.split(',')
- for p in permissions:
- p = p.strip().lower()
- if p not in valid_permissions:
- valid_permissions.append(p)
+ perm = perm.strip().lower()
+ if perm not in valid_permissions:
+ valid_permissions.append(perm)
return ','.join(valid_permissions)
_prefix_option = StrEnum('aciprefix',