From 1431c80b3c2a256bb6c10cf042f7671004695a9f Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 10 Apr 2012 07:44:21 -0400 Subject: Convert --setattr values for attributes marked no_update Attribute Patrams marked no_update never get cloned to Update commands, and thus never receive the `attribute` flag. This makes their `encode` method a no-op, which meant they don't get properly encoded when used with --setattr, making the --setattr fail. Introduce a `force` argument to encode, which overrides checking for the attribute flag. Use this in set/add/delattr normalization, where we know we are dealing with attributes. https://fedorahosted.org/freeipa/ticket/2616 --- ipalib/plugins/baseldap.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'ipalib/plugins/baseldap.py') diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index daf1b07f..3e792347 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -937,7 +937,12 @@ last, after all sets and adds."""), raise errors.ValidationError(name=attr, error=err.error) except errors.ConversionError, err: raise errors.ConversionError(name=attr, error=err.error) - value = param.encode(value) + # FIXME: We use `force` when encoding because we know this is + # an attribute, even if it does not have the `attribute` flag + # set. This happens with no_update attributes, which are + # not cloned to Update commands. This cloning is where the flag + # gets set. + value = param.encode(value, force=True) entry_attrs[attr] = value else: # unknown attribute: remove duplicite and invalid values -- cgit