diff options
author | Jan Cholasta <jcholast@redhat.com> | 2012-01-23 09:50:41 -0500 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2012-02-13 22:21:50 -0500 |
commit | ca3f3041106dbaa8462aeb78c35b640b169d694a (patch) | |
tree | 4821672b66a83847e39e2cbc48e90c5ee536c130 /ipalib/plugins/baseldap.py | |
parent | c00bf9e38afa4867f4ec397b260f2e467163096d (diff) | |
download | freeipa-ca3f3041106dbaa8462aeb78c35b640b169d694a.tar.gz freeipa-ca3f3041106dbaa8462aeb78c35b640b169d694a.tar.xz freeipa-ca3f3041106dbaa8462aeb78c35b640b169d694a.zip |
Base64-decode unicode values in Bytes parameters.
Fix wrong handling of strings in --setattr/--addattr/--delattr.
These changes make it possible to use Bytes in --setattr/--addattr/
--delattr without errors.
Fixes managing SSH keys on command-line
https://fedorahosted.org/freeipa/ticket/754
Diffstat (limited to 'ipalib/plugins/baseldap.py')
-rw-r--r-- | ipalib/plugins/baseldap.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index 66339ccad..d619f14ee 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -24,6 +24,7 @@ import re import json import time from copy import deepcopy +import base64 from ipalib import api, crud, errors from ipalib import Method, Object, Command @@ -862,6 +863,9 @@ last, after all sets and adds."""), try: entry_attrs[attr].remove(delval) except ValueError: + if isinstance(delval, str): + # This is a Binary value, base64 encode it + delval = unicode(base64.b64encode(delval)) raise errors.AttrValueNotFound(attr=attr, value=delval) # normalize all values @@ -871,8 +875,8 @@ last, after all sets and adds."""), entry_attrs[attr] = list(set([val for val in entry_attrs[attr] if val])) if not entry_attrs[attr]: entry_attrs[attr] = None - elif len(entry_attrs[attr]) == 1: - entry_attrs[attr] = entry_attrs[attr][0] + elif isinstance(entry_attrs[attr], (tuple, list)) and len(entry_attrs[attr]) == 1: + entry_attrs[attr] = entry_attrs[attr][0] class LDAPCreate(BaseLDAPCommand, crud.Create): """ |