summaryrefslogtreecommitdiffstats
path: root/ipapython
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2018-03-13 13:05:05 -0400
committerChristian Heimes <cheimes@redhat.com>2018-03-19 17:38:41 +0100
commit68c7b036893fcdad7cc2364b0fc2a841366493ef (patch)
tree1c376959a96e48ec30259035de3d654bbeea5e9d /ipapython
parent2b47f8994f7ccd0ee1590cf3b103e85ac996f0bd (diff)
downloadfreeipa-68c7b036893fcdad7cc2364b0fc2a841366493ef.tar.gz
freeipa-68c7b036893fcdad7cc2364b0fc2a841366493ef.tar.xz
freeipa-68c7b036893fcdad7cc2364b0fc2a841366493ef.zip
Return a value if exceptions are raised in server uninstall
The AdminTool class purports to "call sys.exit() with the return value" but most of the run implementations returned no value, or the methods they called returned nothing so there was nothing to return, so this was a no-op. The fix is to capture and bubble up the return values which will return 1 if any exceptions are caught. This potentially affects other users in that when executing the steps of an installer or uninstaller the highest return code will be the exit value of that installer. Don't use the Continuous class because it doesn't add any value and makes catching the exceptions more difficult. https://pagure.io/freeipa/issue/7330 Signed-off-by: Rob Crittenden rcritten@redhat.com Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
Diffstat (limited to 'ipapython')
-rw-r--r--ipapython/install/cli.py4
-rw-r--r--ipapython/install/common.py2
-rw-r--r--ipapython/install/core.py10
3 files changed, 10 insertions, 6 deletions
diff --git a/ipapython/install/cli.py b/ipapython/install/cli.py
index e8f67a3de..86503a66b 100644
--- a/ipapython/install/cli.py
+++ b/ipapython/install/cli.py
@@ -316,10 +316,10 @@ class ConfigureTool(admintool.AdminTool):
if self.use_private_ccache:
with private_ccache():
super(ConfigureTool, self).run()
- cfgr.run()
+ return cfgr.run()
else:
super(ConfigureTool, self).run()
- cfgr.run()
+ return cfgr.run()
@staticmethod
def __signal_handler(signum, frame):
diff --git a/ipapython/install/common.py b/ipapython/install/common.py
index 05dfadfcb..ca1e8fd30 100644
--- a/ipapython/install/common.py
+++ b/ipapython/install/common.py
@@ -109,7 +109,7 @@ def installer(cls):
def uninstaller(cls):
- class Uninstaller(Continuous, cls, Installable):
+ class Uninstaller(cls, Installable):
def __init__(self, **kwargs):
super(Uninstaller, self).__init__(uninstalling=True,
**kwargs)
diff --git a/ipapython/install/core.py b/ipapython/install/core.py
index 7ded343d9..2ed41f63e 100644
--- a/ipapython/install/core.py
+++ b/ipapython/install/core.py
@@ -361,7 +361,7 @@ class Configurable(six.with_metaclass(abc.ABCMeta, object)):
self.validate()
if self.__state == _EXECUTE_PENDING:
- self.execute()
+ return self.execute()
def validate(self):
"""
@@ -384,9 +384,13 @@ class Configurable(six.with_metaclass(abc.ABCMeta, object)):
"""
Run the execution part of the configurable.
"""
+ return_value = 0
- for _nothing in self._executor():
- pass
+ for rval in self._executor():
+ if rval is not None and rval > return_value:
+ return_value = rval
+
+ return return_value
def _executor(self):
"""