Blame SOURCES/0001-join-always-add-service-principals.patch

59dcbd
From cd296bf24e7cc56fb8d00bad7e9a56c539894309 Mon Sep 17 00:00:00 2001
59dcbd
From: Sumit Bose <sbose@redhat.com>
59dcbd
Date: Tue, 19 Mar 2019 20:44:36 +0100
59dcbd
Subject: [PATCH 1/2] join: always add service principals
59dcbd
59dcbd
If currently --service-name is given during the join only the service
59dcbd
names given by this option are added as service principal names. As a
59dcbd
result the default 'host' service principal name might be missing which
59dcbd
might cause issues e.g. with SSSD and sshd.
59dcbd
59dcbd
The patch makes sure the default service principals 'host' and
59dcbd
'RestrictedKrbHost' are always added during join.
59dcbd
59dcbd
Related to https://bugzilla.redhat.com/show_bug.cgi?id=1644311
59dcbd
---
59dcbd
 library/adenroll.c | 36 ++++++++++++++++++++++++++++++------
59dcbd
 1 file changed, 30 insertions(+), 6 deletions(-)
59dcbd
59dcbd
diff --git a/library/adenroll.c b/library/adenroll.c
59dcbd
index 58362c2..d1f746c 100644
59dcbd
--- a/library/adenroll.c
59dcbd
+++ b/library/adenroll.c
59dcbd
@@ -288,16 +288,23 @@ ensure_computer_password (adcli_result res,
59dcbd
 }
59dcbd
 
59dcbd
 static adcli_result
59dcbd
-ensure_service_names (adcli_result res,
59dcbd
-                      adcli_enroll *enroll)
59dcbd
+ensure_default_service_names (adcli_enroll *enroll)
59dcbd
 {
59dcbd
 	int length = 0;
59dcbd
 
59dcbd
-	if (res != ADCLI_SUCCESS)
59dcbd
-		return res;
59dcbd
+	if (enroll->service_names != NULL) {
59dcbd
+		length = seq_count (enroll->service_names);
59dcbd
 
59dcbd
-	if (enroll->service_names || enroll->service_principals)
59dcbd
-		return ADCLI_SUCCESS;
59dcbd
+		/* Make sure there is no entry with an unexpected case. AD
59dcbd
+		 * would not care but since the client side is case-sensitive
59dcbd
+		 * we should make sure we use the expected spelling. */
59dcbd
+		seq_remove_unsorted (enroll->service_names,
59dcbd
+		                     &length, "host",
59dcbd
+		                     (seq_compar)strcasecmp, free);
59dcbd
+		seq_remove_unsorted (enroll->service_names,
59dcbd
+		                     &length, "RestrictedKrbHost",
59dcbd
+		                     (seq_compar)strcasecmp, free);
59dcbd
+	}
59dcbd
 
59dcbd
 	/* The default ones specified by MS */
59dcbd
 	enroll->service_names = _adcli_strv_add (enroll->service_names,
59dcbd
@@ -307,6 +314,19 @@ ensure_service_names (adcli_result res,
59dcbd
 	return ADCLI_SUCCESS;
59dcbd
 }
59dcbd
 
59dcbd
+static adcli_result
59dcbd
+ensure_service_names (adcli_result res,
59dcbd
+                      adcli_enroll *enroll)
59dcbd
+{
59dcbd
+	if (res != ADCLI_SUCCESS)
59dcbd
+		return res;
59dcbd
+
59dcbd
+	if (enroll->service_names || enroll->service_principals)
59dcbd
+		return ADCLI_SUCCESS;
59dcbd
+
59dcbd
+	return ensure_default_service_names (enroll);
59dcbd
+}
59dcbd
+
59dcbd
 static adcli_result
59dcbd
 add_service_names_to_service_principals (adcli_enroll *enroll)
59dcbd
 {
59dcbd
@@ -2039,6 +2059,10 @@ adcli_enroll_join (adcli_enroll *enroll,
59dcbd
 	if (res != ADCLI_SUCCESS)
59dcbd
 		return res;
59dcbd
 
59dcbd
+	res = ensure_default_service_names (enroll);
59dcbd
+	if (res != ADCLI_SUCCESS)
59dcbd
+		return res;
59dcbd
+
59dcbd
 	res = adcli_enroll_prepare (enroll, flags);
59dcbd
 	if (res != ADCLI_SUCCESS)
59dcbd
 		return res;
59dcbd
-- 
59dcbd
2.20.1
59dcbd