|
|
59dcbd |
From f05adc23d5cc9f1dfa5638e31949dcd81d632df9 Mon Sep 17 00:00:00 2001
|
|
|
59dcbd |
From: Sumit Bose <sbose@redhat.com>
|
|
|
59dcbd |
Date: Mon, 13 Aug 2018 17:32:24 +0200
|
|
|
59dcbd |
Subject: [PATCH 3/4] Do not add service principals twice
|
|
|
59dcbd |
|
|
|
59dcbd |
---
|
|
|
59dcbd |
library/adenroll.c | 23 +++++++++++++++++++----
|
|
|
59dcbd |
1 file changed, 19 insertions(+), 4 deletions(-)
|
|
|
59dcbd |
|
|
|
59dcbd |
diff --git a/library/adenroll.c b/library/adenroll.c
|
|
|
59dcbd |
index c4ba537..bb50365 100644
|
|
|
59dcbd |
--- a/library/adenroll.c
|
|
|
59dcbd |
+++ b/library/adenroll.c
|
|
|
59dcbd |
@@ -313,6 +313,7 @@ add_service_names_to_service_principals (adcli_enroll *enroll)
|
|
|
59dcbd |
char *name;
|
|
|
59dcbd |
int length = 0;
|
|
|
59dcbd |
int i;
|
|
|
59dcbd |
+ size_t c;
|
|
|
59dcbd |
|
|
|
59dcbd |
if (enroll->service_principals != NULL) {
|
|
|
59dcbd |
length = seq_count (enroll->service_principals);
|
|
|
59dcbd |
@@ -321,14 +322,28 @@ add_service_names_to_service_principals (adcli_enroll *enroll)
|
|
|
59dcbd |
for (i = 0; enroll->service_names[i] != NULL; i++) {
|
|
|
59dcbd |
if (asprintf (&name, "%s/%s", enroll->service_names[i], enroll->computer_name) < 0)
|
|
|
59dcbd |
return_unexpected_if_reached ();
|
|
|
59dcbd |
- enroll->service_principals = _adcli_strv_add (enroll->service_principals,
|
|
|
59dcbd |
- name, &length);
|
|
|
59dcbd |
+ for (c = 0; enroll->service_principals != NULL && enroll->service_principals[c] != NULL; c++) {
|
|
|
59dcbd |
+ if (strcmp (name, enroll->service_principals[c]) == 0) {
|
|
|
59dcbd |
+ break;
|
|
|
59dcbd |
+ }
|
|
|
59dcbd |
+ }
|
|
|
59dcbd |
+ if (enroll->service_principals == NULL || enroll->service_principals[c] == NULL) {
|
|
|
59dcbd |
+ enroll->service_principals = _adcli_strv_add (enroll->service_principals,
|
|
|
59dcbd |
+ name, &length);
|
|
|
59dcbd |
+ }
|
|
|
59dcbd |
|
|
|
59dcbd |
if (enroll->host_fqdn) {
|
|
|
59dcbd |
if (asprintf (&name, "%s/%s", enroll->service_names[i], enroll->host_fqdn) < 0)
|
|
|
59dcbd |
return_unexpected_if_reached ();
|
|
|
59dcbd |
- enroll->service_principals = _adcli_strv_add (enroll->service_principals,
|
|
|
59dcbd |
- name, &length);
|
|
|
59dcbd |
+ for (c = 0; enroll->service_principals != NULL && enroll->service_principals[c] != NULL; c++) {
|
|
|
59dcbd |
+ if (strcmp (name, enroll->service_principals[c]) == 0) {
|
|
|
59dcbd |
+ break;
|
|
|
59dcbd |
+ }
|
|
|
59dcbd |
+ }
|
|
|
59dcbd |
+ if (enroll->service_principals == NULL || enroll->service_principals[c] == NULL) {
|
|
|
59dcbd |
+ enroll->service_principals = _adcli_strv_add (enroll->service_principals,
|
|
|
59dcbd |
+ name, &length);
|
|
|
59dcbd |
+ }
|
|
|
59dcbd |
}
|
|
|
59dcbd |
}
|
|
|
59dcbd |
|
|
|
59dcbd |
--
|
|
|
59dcbd |
2.17.1
|
|
|
59dcbd |
|