diff options
author | Rob Crittenden <rcritten@redhat.com> | 2012-02-29 13:31:20 -0500 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2012-02-29 18:00:45 -0500 |
commit | 0099ccbea829203a14013255aa0a4058d4d58a36 (patch) | |
tree | 7efbbaec8e7b030dd20fa9ac9bfde5ff268aa7f8 /ipalib/plugins/baseldap.py | |
parent | 87901ed7098dff72e4a62dfe582c2b83439b7280 (diff) | |
download | freeipa.git-0099ccbea829203a14013255aa0a4058d4d58a36.tar.gz freeipa.git-0099ccbea829203a14013255aa0a4058d4d58a36.tar.xz freeipa.git-0099ccbea829203a14013255aa0a4058d4d58a36.zip |
Only apply validation rules when adding and updating.
There may be cases, for whatever reason, that an otherwise illegal
entry gets created that doesn't match the criteria for a valid
user/host/group name. If this happens (i.e. migration) there is no way
to remove this using the IPA tools because we always applied the name
pattern. So you can't, for example, delete a user with an illegal name.
Primary keys are cloned with query=True in PKQuery which causes no
rules to be applied on mod/show/find. This reverts a change from commit
3a5e26a0 which applies class rules when query=True (for enforcing no
white space).
Replace rdnattr with rdn_is_primary_key. This was meant to tell us when
an RDN change was necessary to do a rename. There could be a disconnect
where the rdnattr wasn't the primary key and in that case we don't
need to do an RDN change, so use a boolean instead so that it is
clear that RDN == primary key.
Add a test to ensure that nowhitespace is actually enforced.
https://fedorahosted.org/freeipa/ticket/2115
Related: https://fedorahosted.org/freeipa/ticket/2089
Whitespace tickets:
https://fedorahosted.org/freeipa/ticket/1285
https://fedorahosted.org/freeipa/ticket/1286
https://fedorahosted.org/freeipa/ticket/1287
Diffstat (limited to 'ipalib/plugins/baseldap.py')
-rw-r--r-- | ipalib/plugins/baseldap.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index 725704ee..2664160f 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -429,7 +429,7 @@ class LDAPObject(Object): rdn_attribute = '' uuid_attribute = '' attribute_members = {} - rdnattr = None + rdn_is_primary_key = False # Do we need RDN change to do a rename? password_attributes = [] # Can bind as this entry (has userPassword or krbPrincipalKey) bindable = False @@ -1178,7 +1178,7 @@ class LDAPUpdate(LDAPQuery, crud.Update): has_output_params = global_output_params def _get_rename_option(self): - rdnparam = getattr(self.obj.params, self.obj.rdnattr) + rdnparam = getattr(self.obj.params, self.obj.primary_key.name) return rdnparam.clone_rename('rename', cli_name='rename', required=False, label=_('Rename'), doc=_('Rename the %(ldap_obj_name)s object') % dict( @@ -1189,7 +1189,7 @@ class LDAPUpdate(LDAPQuery, crud.Update): def get_options(self): for option in super(LDAPUpdate, self).get_options(): yield option - if self.obj.rdnattr: + if self.obj.rdn_is_primary_key: yield self._get_rename_option() def execute(self, *keys, **options): @@ -1229,18 +1229,19 @@ class LDAPUpdate(LDAPQuery, crud.Update): rdnupdate = False try: - if self.obj.rdnattr and 'rename' in options: + if self.obj.rdn_is_primary_key and 'rename' in options: if not options['rename']: raise errors.ValidationError(name='rename', error=u'can\'t be empty') - entry_attrs[self.obj.rdnattr] = options['rename'] + entry_attrs[self.obj.primary_key.name] = options['rename'] - if self.obj.rdnattr and self.obj.rdnattr in entry_attrs: + if self.obj.rdn_is_primary_key and self.obj.primary_key.name in entry_attrs: # RDN change - ldap.update_entry_rdn(dn, unicode('%s=%s' % (self.obj.rdnattr, - entry_attrs[self.obj.rdnattr]))) - rdnkeys = keys[:-1] + (entry_attrs[self.obj.rdnattr], ) + ldap.update_entry_rdn(dn, + unicode('%s=%s' % (self.obj.primary_key.name, + entry_attrs[self.obj.primary_key.name]))) + rdnkeys = keys[:-1] + (entry_attrs[self.obj.primary_key.name], ) dn = self.obj.get_dn(*rdnkeys) - del entry_attrs[self.obj.rdnattr] + del entry_attrs[self.obj.primary_key.name] options['rdnupdate'] = True rdnupdate = True |