From 040df002df8c58c84a94d2fb3dec717beb6e5f0a Mon Sep 17 00:00:00 2001
From: Florence Blanc-Renaud <flo@redhat.com>
Date: Wed, 22 Aug 2018 18:29:07 +0200
Subject: [PATCH] ipa commands: print 'IPA is not configured' when ipa is not
setup
Some commands print tracebacks or unclear error message when
they are called on a machine where ipa packages are installed but
IPA is not configured.
Consistently report 'IPA is not configured on this system' in this
case.
Related to https://pagure.io/freeipa/issue/6261
Reviewed-By: Christian Heimes <cheimes@redhat.com>
---
install/tools/ipa-compat-manage | 2 ++
install/tools/ipa-csreplica-manage | 4 +++-
ipaserver/advise/base.py | 2 ++
ipaserver/install/ipa_pkinit_manage.py | 2 ++
ipaserver/install/ipa_server_upgrade.py | 2 ++
ipaserver/install/ipa_winsync_migrate.py | 2 +-
6 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/install/tools/ipa-compat-manage b/install/tools/ipa-compat-manage
index 6dd259d2aad870e575093d6732157de743502ac2..ce61b702689448dcfbddbf0dad6c2adde861e6e9 100755
--- a/install/tools/ipa-compat-manage
+++ b/install/tools/ipa-compat-manage
@@ -82,6 +82,8 @@ def main():
retval = 0
files = [paths.SCHEMA_COMPAT_ULDIF]
+ installutils.check_server_configuration()
+
options, args = parse_options()
if len(args) != 1:
diff --git a/install/tools/ipa-csreplica-manage b/install/tools/ipa-csreplica-manage
index 87f034d1205938c4551f939b0e8c0da292e90bc1..c7b62b293d68c95912ab641294180eeb74a98573 100755
--- a/install/tools/ipa-csreplica-manage
+++ b/install/tools/ipa-csreplica-manage
@@ -32,6 +32,7 @@ from ipaserver.install import (replication, installutils, bindinstance,
from ipalib import api, errors
from ipalib.util import has_managed_topology
from ipapython import ipautil, ipaldap, version
+from ipapython.admintool import ScriptError
from ipapython.dn import DN
logger = logging.getLogger(os.path.basename(__file__))
@@ -408,6 +409,7 @@ def exit_on_managed_topology(what, hint="topologysegment"):
def main():
+ installutils.check_server_configuration()
options, args = parse_options()
# Just initialize the environment. This is so the installer can have
@@ -496,7 +498,7 @@ try:
main()
except KeyboardInterrupt:
sys.exit(1)
-except SystemExit as e:
+except (SystemExit, ScriptError) as e:
sys.exit(e)
except Exception as e:
sys.exit("unexpected error: %s" % e)
diff --git a/ipaserver/advise/base.py b/ipaserver/advise/base.py
index 40f2e65dc8f74a833ef6fe107eabf96ac6a3c12b..07b1431e84c31cb7ba2ecc58a9d152e596dd8b00 100644
--- a/ipaserver/advise/base.py
+++ b/ipaserver/advise/base.py
@@ -30,6 +30,7 @@ from ipalib.errors import ValidationError
from ipaplatform.paths import paths
from ipapython import admintool
from ipapython.ipa_log_manager import Filter
+from ipaserver.install import installutils
"""
@@ -418,6 +419,7 @@ class IpaAdvise(admintool.AdminTool):
def validate_options(self):
super(IpaAdvise, self).validate_options(needs_root=False)
+ installutils.check_server_configuration()
if len(self.args) > 1:
raise self.option_parser.error("You can only provide one "
diff --git a/ipaserver/install/ipa_pkinit_manage.py b/ipaserver/install/ipa_pkinit_manage.py
index c54bb14f58b9bfd19ae860270a1c1955b4de1732..4a79bba5d1b636827a7a031965b49cf7b34c6330 100644
--- a/ipaserver/install/ipa_pkinit_manage.py
+++ b/ipaserver/install/ipa_pkinit_manage.py
@@ -9,6 +9,7 @@ import logging
from ipalib import api
from ipaplatform.paths import paths
from ipapython.admintool import AdminTool
+from ipaserver.install import installutils
from ipaserver.install.krbinstance import KrbInstance, is_pkinit_enabled
logger = logging.getLogger(__name__)
@@ -21,6 +22,7 @@ class PKINITManage(AdminTool):
def validate_options(self):
super(PKINITManage, self).validate_options(needs_root=True)
+ installutils.check_server_configuration()
option_parser = self.option_parser
diff --git a/ipaserver/install/ipa_server_upgrade.py b/ipaserver/install/ipa_server_upgrade.py
index 1e52bca9765671c0b63bf08b0ad47d40477037ee..7643b97f22fbf6c6861317a171c6e2da377365cd 100644
--- a/ipaserver/install/ipa_server_upgrade.py
+++ b/ipaserver/install/ipa_server_upgrade.py
@@ -35,6 +35,8 @@ class ServerUpgrade(admintool.AdminTool):
def validate_options(self):
super(ServerUpgrade, self).validate_options(needs_root=True)
+ installutils.check_server_configuration()
+
if self.options.force:
self.options.skip_version_check = True
diff --git a/ipaserver/install/ipa_winsync_migrate.py b/ipaserver/install/ipa_winsync_migrate.py
index 0399b9b7b683cd92692094b53208dcc0f40fd392..43330ad502e736816a1af8e8c2a444e1eae05baa 100644
--- a/ipaserver/install/ipa_winsync_migrate.py
+++ b/ipaserver/install/ipa_winsync_migrate.py
@@ -350,7 +350,7 @@ class WinsyncMigrate(admintool.AdminTool):
# Check if the IPA server is configured before attempting to migrate
try:
installutils.check_server_configuration()
- except RuntimeError as e:
+ except admintool.ScriptError as e:
sys.exit(e)
# Finalize API
--
2.17.1