URL: https://github.com/freeipa/freeipa/pull/572
Author: HonzaCholasta
 Title: #572: rpc: fix crash in verbose mode
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/572/head:pr572
git checkout pr572
From bb56b33e205c89d458c04132a59e1df089a5079c Mon Sep 17 00:00:00 2001
From: Jan Cholasta <jchol...@redhat.com>
Date: Fri, 10 Mar 2017 09:33:15 +0000
Subject: [PATCH] rpc: fix crash in verbose mode

Fix a crash caused by feeding incorrect data to `json.dumps()` in
`JSONServerProxy.__request()` introduced by commit
8159c2883bf66980582d1227c364df4e592bdd7e.

https://pagure.io/freeipa/issue/6734
---
 ipalib/rpc.py | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/ipalib/rpc.py b/ipalib/rpc.py
index 3a589cb..16ffb8b 100644
--- a/ipalib/rpc.py
+++ b/ipalib/rpc.py
@@ -1136,16 +1136,17 @@ def __request(self, name, args):
             verbose=self.__verbose >= 3,
         )
 
+        if print_json:
+            root_logger.info(
+                'Response: %s',
+                json.dumps(json.loads(response), sort_keys=True, indent=4)
+            )
+
         try:
             response = json_decode_binary(response)
         except ValueError as e:
             raise JSONError(error=str(e))
 
-        if print_json:
-            root_logger.info(
-                'Response: %s',
-                json.dumps(response, sort_keys=True, indent=4)
-            )
         error = response.get('error')
         if error:
             try:
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to