summaryrefslogtreecommitdiffstats
path: root/ipalib/parameters.py
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2012-01-23 09:50:41 -0500
committerRob Crittenden <rcritten@redhat.com>2012-02-13 22:21:50 -0500
commitca3f3041106dbaa8462aeb78c35b640b169d694a (patch)
tree4821672b66a83847e39e2cbc48e90c5ee536c130 /ipalib/parameters.py
parentc00bf9e38afa4867f4ec397b260f2e467163096d (diff)
downloadfreeipa-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/parameters.py')
-rw-r--r--ipalib/parameters.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index d918a5737..c533f9d0b 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -101,6 +101,10 @@ a more detailed description for clarity.
import re
import decimal
+import base64
+import csv
+from xmlrpclib import MAXINT, MININT
+
from types import NoneType
from util import make_repr
from text import _ as ugettext
@@ -109,8 +113,6 @@ from errors import ConversionError, RequirementError, ValidationError
from errors import PasswordMismatch
from constants import NULLS, TYPE_ERROR, CALLABLE_ERROR
from text import Gettext, FixMe
-import csv
-from xmlrpclib import MAXINT, MININT
class DefaultFrom(ReadOnly):
@@ -1440,6 +1442,14 @@ class Bytes(Data):
length=self.length,
)
+ def _convert_scalar(self, value, index=None):
+ if isinstance(value, unicode):
+ try:
+ value = base64.b64decode(value)
+ except TypeError:
+ raise ConversionError(name=self.name, index=index, error=self.type_error)
+ return super(Bytes, self)._convert_scalar(value, index)
+
class Str(Data):
"""