|
|
f441eb |
From 972f1a2f35829ed89f5353bd204683aa9ad6a2d2 Mon Sep 17 00:00:00 2001
|
|
|
f441eb |
From: Sumit Bose <sbose@redhat.com>
|
|
|
f441eb |
Date: Fri, 22 Mar 2019 10:37:57 +0100
|
|
|
f441eb |
Subject: [PATCH 4/4] library: make sure server side SPNs are preserved
|
|
|
f441eb |
|
|
|
f441eb |
adcli should not delete service principal names (SPNs) unexpectedly. If
|
|
|
f441eb |
a SPN was added on the server while presetting a host or updating an
|
|
|
f441eb |
existing entry and upcoming adcli join or update should preserver this
|
|
|
f441eb |
change.
|
|
|
f441eb |
|
|
|
f441eb |
Related to https://bugzilla.redhat.com/show_bug.cgi?id=1630187
|
|
|
f441eb |
---
|
|
|
f441eb |
library/adenroll.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
f441eb |
1 file changed, 46 insertions(+)
|
|
|
f441eb |
|
|
|
f441eb |
diff --git a/library/adenroll.c b/library/adenroll.c
|
|
|
f441eb |
index 48cb4cf..1cce86a 100644
|
|
|
f441eb |
--- a/library/adenroll.c
|
|
|
f441eb |
+++ b/library/adenroll.c
|
|
|
f441eb |
@@ -1961,6 +1961,47 @@ adcli_enroll_prepare (adcli_enroll *enroll,
|
|
|
f441eb |
return res;
|
|
|
f441eb |
}
|
|
|
f441eb |
|
|
|
f441eb |
+static adcli_result
|
|
|
f441eb |
+add_server_side_service_principals (adcli_enroll *enroll)
|
|
|
f441eb |
+{
|
|
|
f441eb |
+ char **spn_list;
|
|
|
f441eb |
+ LDAP *ldap;
|
|
|
f441eb |
+ size_t c;
|
|
|
f441eb |
+ int length = 0;
|
|
|
f441eb |
+ adcli_result res;
|
|
|
f441eb |
+
|
|
|
f441eb |
+ ldap = adcli_conn_get_ldap_connection (enroll->conn);
|
|
|
f441eb |
+ assert (ldap != NULL);
|
|
|
f441eb |
+
|
|
|
f441eb |
+ spn_list = _adcli_ldap_parse_values (ldap, enroll->computer_attributes,
|
|
|
f441eb |
+ "servicePrincipalName");
|
|
|
f441eb |
+ if (spn_list == NULL) {
|
|
|
f441eb |
+ return ADCLI_SUCCESS;
|
|
|
f441eb |
+ }
|
|
|
f441eb |
+
|
|
|
f441eb |
+ if (enroll->service_principals != NULL) {
|
|
|
f441eb |
+ length = seq_count (enroll->service_principals);
|
|
|
f441eb |
+ }
|
|
|
f441eb |
+
|
|
|
f441eb |
+ for (c = 0; spn_list[c] != NULL; c++) {
|
|
|
f441eb |
+ _adcli_info ("Checking %s", spn_list[c]);
|
|
|
f441eb |
+ if (!_adcli_strv_has_ex (enroll->service_principals_to_remove, spn_list[c], strcasecmp)) {
|
|
|
f441eb |
+ enroll->service_principals = _adcli_strv_add_unique (enroll->service_principals,
|
|
|
f441eb |
+ spn_list[c], &length, false);
|
|
|
f441eb |
+ assert (enroll->service_principals != NULL);
|
|
|
f441eb |
+ _adcli_info (" Added %s", spn_list[c]);
|
|
|
f441eb |
+ }
|
|
|
f441eb |
+ }
|
|
|
f441eb |
+ _adcli_strv_free (spn_list);
|
|
|
f441eb |
+
|
|
|
f441eb |
+ res = ensure_keytab_principals (ADCLI_SUCCESS, enroll);
|
|
|
f441eb |
+ if (res != ADCLI_SUCCESS) {
|
|
|
f441eb |
+ return res;
|
|
|
f441eb |
+ }
|
|
|
f441eb |
+
|
|
|
f441eb |
+ return ADCLI_SUCCESS;
|
|
|
f441eb |
+}
|
|
|
f441eb |
+
|
|
|
f441eb |
static adcli_result
|
|
|
f441eb |
enroll_join_or_update_tasks (adcli_enroll *enroll,
|
|
|
f441eb |
adcli_enroll_flags flags)
|
|
|
f441eb |
@@ -2019,6 +2060,11 @@ enroll_join_or_update_tasks (adcli_enroll *enroll,
|
|
|
f441eb |
update_and_calculate_enctypes (enroll);
|
|
|
f441eb |
update_computer_account (enroll);
|
|
|
f441eb |
|
|
|
f441eb |
+ res = add_server_side_service_principals (enroll);
|
|
|
f441eb |
+ if (res != ADCLI_SUCCESS) {
|
|
|
f441eb |
+ return res;
|
|
|
f441eb |
+ }
|
|
|
f441eb |
+
|
|
|
f441eb |
/* service_names is only set from input on the command line, so no
|
|
|
f441eb |
* additional check for explicit is needed here */
|
|
|
f441eb |
if (enroll->service_names != NULL) {
|
|
|
f441eb |
--
|
|
|
f441eb |
2.20.1
|
|
|
f441eb |
|