diff options
author | Martin Kosek <mkosek@redhat.com> | 2012-09-13 15:51:51 +0200 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2012-09-16 17:52:56 -0400 |
commit | cd7a85c12cf6b5455e40fd5440205ff2c5785a62 (patch) | |
tree | 1e51b1b4a2eca03ff5b994fd2edddcb68e69400a /ipalib | |
parent | d491ba028987b106b10f97ab93a106104a9c4eee (diff) | |
download | freeipa-cd7a85c12cf6b5455e40fd5440205ff2c5785a62.tar.gz freeipa-cd7a85c12cf6b5455e40fd5440205ff2c5785a62.tar.xz freeipa-cd7a85c12cf6b5455e40fd5440205ff2c5785a62.zip |
Fix addattr internal error
When ADD command is being executed and a single-value object attribute
is being set with both option and addattr IPA ends up in an internal
error.
Make better value sanitizing job in this case and let IPA throw
a user-friendly error. Unit test exercising this situation is added.
https://fedorahosted.org/freeipa/ticket/2429
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/plugins/baseldap.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index 6a054ffd8..14a46f2d0 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -882,7 +882,17 @@ last, after all sets and adds."""), entry_attrs[attr] = val for attr in direct_add: - entry_attrs.setdefault(attr, []).extend(adddict[attr]) + try: + val = entry_attrs[attr] + except KeyError: + val = [] + else: + if not isinstance(val, (list, tuple)): + val = [val] + elif isinstance(val, tuple): + val = list(val) + val.extend(adddict[attr]) + entry_attrs[attr] = val for attr in direct_del: for delval in deldict[attr]: |