|
|
6ec482 |
From 6953cecad70fc183ca4a8eddc467a7efa7ff83d3 Mon Sep 17 00:00:00 2001
|
|
|
6ec482 |
From: Florence Blanc-Renaud <flo@redhat.com>
|
|
|
6ec482 |
Date: Mon, 9 Sep 2019 12:58:48 +0200
|
|
|
6ec482 |
Subject: [PATCH] replica install: enforce --server arg
|
|
|
6ec482 |
|
|
|
6ec482 |
When the --server option is provided to ipa-replica-install (1-step
|
|
|
6ec482 |
install), make sure that the server offers all the required roles
|
|
|
6ec482 |
(CA, KRA). If it's not the case, refuse the installation.
|
|
|
6ec482 |
|
|
|
6ec482 |
Note that the --server option is ignored when promoting from client to
|
|
|
6ec482 |
replica (2-step install with ipa-client-install and ipa-replica-install),
|
|
|
6ec482 |
meaning that the existing behavior is not changed in this use case:
|
|
|
6ec482 |
by default the host specified in default.conf as server is used for
|
|
|
6ec482 |
enrollment, but if it does not provide a required role, another host can
|
|
|
6ec482 |
be picked for CA or KRA setup.
|
|
|
6ec482 |
|
|
|
6ec482 |
Fixes: https://pagure.io/freeipa/issue/7566
|
|
|
6ec482 |
Signed-off-by: Florence Blanc-Renaud <flo@redhat.com>
|
|
|
6ec482 |
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
|
|
|
6ec482 |
Reviewed-By: Mohammad Rizwan Yusuf <myusuf@redhat.com>
|
|
|
6ec482 |
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
|
|
|
6ec482 |
Reviewed-By: Mohammad Rizwan Yusuf <myusuf@redhat.com>
|
|
|
6ec482 |
---
|
|
|
6ec482 |
install/tools/man/ipa-replica-install.1 | 4 ++-
|
|
|
6ec482 |
ipaserver/install/server/replicainstall.py | 36 ++++++++++++++++++++--
|
|
|
6ec482 |
2 files changed, 37 insertions(+), 3 deletions(-)
|
|
|
6ec482 |
|
|
|
6ec482 |
diff --git a/install/tools/man/ipa-replica-install.1 b/install/tools/man/ipa-replica-install.1
|
|
|
6ec482 |
index a1284135ac67de2b67b322aec3f6bbfb05f1a8ec..12764b8994a04bf56e80492bdcc66578a1f991e0 100644
|
|
|
6ec482 |
--- a/install/tools/man/ipa-replica-install.1
|
|
|
6ec482 |
+++ b/install/tools/man/ipa-replica-install.1
|
|
|
6ec482 |
@@ -51,7 +51,7 @@ One Time Password for joining a machine to the IPA realm.
|
|
|
6ec482 |
Path to host keytab.
|
|
|
6ec482 |
.TP
|
|
|
6ec482 |
\fB\-\-server\fR
|
|
|
6ec482 |
-The fully qualified domain name of the IPA server to enroll to.
|
|
|
6ec482 |
+The fully qualified domain name of the IPA server to enroll to. The IPA server must provide the CA role if \fB\-\-setup-ca\fR option is specified, and the KRA role if \fB\-\-setup-kra\fR option is specified.
|
|
|
6ec482 |
.TP
|
|
|
6ec482 |
\fB\-n\fR, \fB\-\-domain\fR=\fIDOMAIN\fR
|
|
|
6ec482 |
The primary DNS domain of an existing IPA deployment, e.g. example.com.
|
|
|
6ec482 |
@@ -281,3 +281,5 @@ path.
|
|
|
6ec482 |
1 if an error occurred
|
|
|
6ec482 |
|
|
|
6ec482 |
3 if the host exists in the IPA server or a replication agreement to the remote master already exists
|
|
|
6ec482 |
+
|
|
|
6ec482 |
+4 if the remote master specified for enrollment does not provide required services such as CA or KRA
|
|
|
6ec482 |
diff --git a/ipaserver/install/server/replicainstall.py b/ipaserver/install/server/replicainstall.py
|
|
|
6ec482 |
index bd82a9d1483545d478e790a727e48eaa9ac22cfc..14e8b2c3a76525c6ec2a16ca26fa032aab694a59 100644
|
|
|
6ec482 |
--- a/ipaserver/install/server/replicainstall.py
|
|
|
6ec482 |
+++ b/ipaserver/install/server/replicainstall.py
|
|
|
6ec482 |
@@ -1024,6 +1024,8 @@ def promote_check(installer):
|
|
|
6ec482 |
print("IPA client is already configured on this system, ignoring "
|
|
|
6ec482 |
"the --domain, --server, --realm, --hostname, --password "
|
|
|
6ec482 |
"and --keytab options.")
|
|
|
6ec482 |
+ # Make sure options.server is not used
|
|
|
6ec482 |
+ options.server = None
|
|
|
6ec482 |
|
|
|
6ec482 |
sstore = sysrestore.StateFile(paths.SYSRESTORE)
|
|
|
6ec482 |
|
|
|
6ec482 |
@@ -1269,8 +1271,15 @@ def promote_check(installer):
|
|
|
6ec482 |
config.subject_base = DN(subject_base)
|
|
|
6ec482 |
|
|
|
6ec482 |
# Find any server with a CA
|
|
|
6ec482 |
+ # The order of preference is
|
|
|
6ec482 |
+ # 1. the first server specified in --server, if any
|
|
|
6ec482 |
+ # 2. the server specified in the config file
|
|
|
6ec482 |
+ # 3. any other
|
|
|
6ec482 |
+ preferred_cas = [config.ca_host_name]
|
|
|
6ec482 |
+ if options.server:
|
|
|
6ec482 |
+ preferred_cas.insert(0, options.server)
|
|
|
6ec482 |
ca_host = find_providing_server(
|
|
|
6ec482 |
- 'CA', conn, [config.ca_host_name]
|
|
|
6ec482 |
+ 'CA', conn, preferred_cas
|
|
|
6ec482 |
)
|
|
|
6ec482 |
if ca_host is not None:
|
|
|
6ec482 |
config.ca_host_name = ca_host
|
|
|
6ec482 |
@@ -1279,6 +1288,14 @@ def promote_check(installer):
|
|
|
6ec482 |
logger.error("Certificates could not be provided when "
|
|
|
6ec482 |
"CA is present on some master.")
|
|
|
6ec482 |
raise ScriptError(rval=3)
|
|
|
6ec482 |
+ if options.setup_ca and options.server and \
|
|
|
6ec482 |
+ ca_host != options.server:
|
|
|
6ec482 |
+ # Installer was provided with a specific master
|
|
|
6ec482 |
+ # but this one doesn't provide CA
|
|
|
6ec482 |
+ logger.error("The specified --server %s does not provide CA, "
|
|
|
6ec482 |
+ "please provide a server with the CA role",
|
|
|
6ec482 |
+ options.server)
|
|
|
6ec482 |
+ raise ScriptError(rval=4)
|
|
|
6ec482 |
else:
|
|
|
6ec482 |
if options.setup_ca:
|
|
|
6ec482 |
logger.error("The remote master does not have a CA "
|
|
|
6ec482 |
@@ -1293,12 +1310,27 @@ def promote_check(installer):
|
|
|
6ec482 |
raise ScriptError(rval=3)
|
|
|
6ec482 |
|
|
|
6ec482 |
# Find any server with a KRA
|
|
|
6ec482 |
+ # The order of preference is
|
|
|
6ec482 |
+ # 1. the first server specified in --server, if any
|
|
|
6ec482 |
+ # 2. the server specified in the config file
|
|
|
6ec482 |
+ # 3. any other
|
|
|
6ec482 |
+ preferred_kras = [config.kra_host_name]
|
|
|
6ec482 |
+ if options.server:
|
|
|
6ec482 |
+ preferred_kras.insert(0, options.server)
|
|
|
6ec482 |
kra_host = find_providing_server(
|
|
|
6ec482 |
- 'KRA', conn, [config.kra_host_name]
|
|
|
6ec482 |
+ 'KRA', conn, preferred_kras
|
|
|
6ec482 |
)
|
|
|
6ec482 |
if kra_host is not None:
|
|
|
6ec482 |
config.kra_host_name = kra_host
|
|
|
6ec482 |
kra_enabled = True
|
|
|
6ec482 |
+ if options.setup_kra and options.server and \
|
|
|
6ec482 |
+ kra_host != options.server:
|
|
|
6ec482 |
+ # Installer was provided with a specific master
|
|
|
6ec482 |
+ # but this one doesn't provide KRA
|
|
|
6ec482 |
+ logger.error("The specified --server %s does not provide KRA, "
|
|
|
6ec482 |
+ "please provide a server with the KRA role",
|
|
|
6ec482 |
+ options.server)
|
|
|
6ec482 |
+ raise ScriptError(rval=4)
|
|
|
6ec482 |
else:
|
|
|
6ec482 |
if options.setup_kra:
|
|
|
6ec482 |
logger.error("There is no active KRA server in the domain, "
|
|
|
6ec482 |
--
|
|
|
6ec482 |
2.20.1
|
|
|
6ec482 |
|