Blob Blame History Raw
From 818fb211ae6e66de4014036cf2a003ade42a5c4a Mon Sep 17 00:00:00 2001
From: Martin Basti <mbasti@redhat.com>
Date: Tue, 25 Nov 2014 14:03:27 +0100
Subject: [PATCH] Fix zonemgr option encoding detection

Ticket: https://fedorahosted.org/freeipa/ticket/4766
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
---
 ipaserver/install/bindinstance.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py
index f02fe8647dd38d05734311406152c50108077561..547cf19ee36140b5f29fcf7d217933fa68e1952b 100644
--- a/ipaserver/install/bindinstance.py
+++ b/ipaserver/install/bindinstance.py
@@ -405,7 +405,10 @@ def zonemgr_callback(option, opt_str, value, parser):
         # validate the value first
         try:
             # IDNA support requires unicode
-            value = value.decode(getattr(sys.stdin, 'encoding', 'utf-8'))
+            encoding = getattr(sys.stdin, 'encoding', None)
+            if encoding is None:
+                encoding = 'utf-8'
+            value = value.decode(encoding)
             validate_zonemgr_str(value)
         except ValueError, e:
             parser.error("invalid zonemgr: " + unicode(e))
-- 
2.1.0