permission plugin: Ensure ipapermlocation (subtree) always exists

This commit is contained in:
Petr Viktorin
2013-12-05 18:18:32 +01:00
committed by Martin Kosek
parent 53caa7aca2
commit 7fc35ced1d
2 changed files with 27 additions and 1 deletions

View File

@@ -623,6 +623,16 @@ class permission(baseldap.LDAPObject):
name='ipapermtargetfilter',
error=_('Bad search filter'))
# Ensure location exists
if entry.get('ipapermlocation'):
location = DN(entry.single_value['ipapermlocation'])
try:
ldap.get_entry(location, attrs_list=[])
except errors.NotFound:
raise errors.ValidationError(
name='ipapermlocation',
error=_('Entry %s does not exist') % location)
# Ensure there's something in the ACI's filter
needed_attrs = (
'ipapermtarget', 'ipapermtargetfilter', 'ipapermallowedattr')