|
|
e06942 |
From 81c98e367ba4bc8d77668acd31e462ad31cf12be Mon Sep 17 00:00:00 2001
|
|
|
e06942 |
From: Sumit Bose <sbose@redhat.com>
|
|
|
e06942 |
Date: Tue, 27 Oct 2020 14:47:31 +0100
|
|
|
e06942 |
Subject: [PATCH 5/7] enroll: make adcli_enroll_add_keytab_for_service_account
|
|
|
e06942 |
public
|
|
|
e06942 |
|
|
|
e06942 |
Determine keytab name more early to catch errors more early.
|
|
|
e06942 |
|
|
|
e06942 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1854112
|
|
|
e06942 |
---
|
|
|
e06942 |
library/adenroll.c | 13 +++++++------
|
|
|
e06942 |
library/adenroll.h | 2 ++
|
|
|
e06942 |
tools/computer.c | 6 ++++++
|
|
|
e06942 |
3 files changed, 15 insertions(+), 6 deletions(-)
|
|
|
e06942 |
|
|
|
e06942 |
diff --git a/library/adenroll.c b/library/adenroll.c
|
|
|
e06942 |
index 44383cc..05bb085 100644
|
|
|
e06942 |
--- a/library/adenroll.c
|
|
|
e06942 |
+++ b/library/adenroll.c
|
|
|
e06942 |
@@ -2276,9 +2276,10 @@ adcli_enroll_add_description_for_service_account (adcli_enroll *enroll)
|
|
|
e06942 |
return ADCLI_SUCCESS;
|
|
|
e06942 |
}
|
|
|
e06942 |
|
|
|
e06942 |
-static adcli_result
|
|
|
e06942 |
+adcli_result
|
|
|
e06942 |
adcli_enroll_add_keytab_for_service_account (adcli_enroll *enroll)
|
|
|
e06942 |
{
|
|
|
e06942 |
+ adcli_result res;
|
|
|
e06942 |
krb5_context k5;
|
|
|
e06942 |
krb5_error_code code;
|
|
|
e06942 |
char def_keytab_name[MAX_KEYTAB_NAME_LEN];
|
|
|
e06942 |
@@ -2286,11 +2287,14 @@ adcli_enroll_add_keytab_for_service_account (adcli_enroll *enroll)
|
|
|
e06942 |
int ret;
|
|
|
e06942 |
|
|
|
e06942 |
if (adcli_enroll_get_keytab_name (enroll) == NULL) {
|
|
|
e06942 |
- k5 = adcli_conn_get_krb5_context (enroll->conn);
|
|
|
e06942 |
- return_unexpected_if_fail (k5 != NULL);
|
|
|
e06942 |
+ res = _adcli_krb5_init_context (&k5;;
|
|
|
e06942 |
+ if (res != ADCLI_SUCCESS) {
|
|
|
e06942 |
+ return res;
|
|
|
e06942 |
+ }
|
|
|
e06942 |
|
|
|
e06942 |
code = krb5_kt_default_name (k5, def_keytab_name,
|
|
|
e06942 |
sizeof (def_keytab_name));
|
|
|
e06942 |
+ krb5_free_context (k5);
|
|
|
e06942 |
return_unexpected_if_fail (code == 0);
|
|
|
e06942 |
|
|
|
e06942 |
lc_dom_name = strdup (adcli_conn_get_domain_name (enroll->conn));
|
|
|
e06942 |
@@ -2326,9 +2330,6 @@ adcli_enroll_join (adcli_enroll *enroll,
|
|
|
e06942 |
|
|
|
e06942 |
if (enroll->is_service) {
|
|
|
e06942 |
res = adcli_enroll_add_description_for_service_account (enroll);
|
|
|
e06942 |
- if (res == ADCLI_SUCCESS) {
|
|
|
e06942 |
- res = adcli_enroll_add_keytab_for_service_account (enroll);
|
|
|
e06942 |
- }
|
|
|
e06942 |
} else {
|
|
|
e06942 |
res = ensure_default_service_names (enroll);
|
|
|
e06942 |
}
|
|
|
e06942 |
diff --git a/library/adenroll.h b/library/adenroll.h
|
|
|
e06942 |
index 7765ed4..11a30c8 100644
|
|
|
e06942 |
--- a/library/adenroll.h
|
|
|
e06942 |
+++ b/library/adenroll.h
|
|
|
e06942 |
@@ -146,6 +146,8 @@ const char * adcli_enroll_get_keytab_name (adcli_enroll *enroll);
|
|
|
e06942 |
void adcli_enroll_set_keytab_name (adcli_enroll *enroll,
|
|
|
e06942 |
const char *value);
|
|
|
e06942 |
|
|
|
e06942 |
+adcli_result adcli_enroll_add_keytab_for_service_account (adcli_enroll *enroll);
|
|
|
e06942 |
+
|
|
|
e06942 |
krb5_enctype * adcli_enroll_get_keytab_enctypes (adcli_enroll *enroll);
|
|
|
e06942 |
|
|
|
e06942 |
void adcli_enroll_set_keytab_enctypes (adcli_enroll *enroll,
|
|
|
e06942 |
diff --git a/tools/computer.c b/tools/computer.c
|
|
|
e06942 |
index 63fd374..98a0472 100644
|
|
|
e06942 |
--- a/tools/computer.c
|
|
|
e06942 |
+++ b/tools/computer.c
|
|
|
e06942 |
@@ -1166,6 +1166,12 @@ adcli_tool_computer_managed_service_account (adcli_conn *conn,
|
|
|
e06942 |
|
|
|
e06942 |
adcli_enroll_set_is_service (enroll, true);
|
|
|
e06942 |
adcli_conn_set_allowed_login_types (conn, ADCLI_LOGIN_USER_ACCOUNT);
|
|
|
e06942 |
+ res = adcli_enroll_add_keytab_for_service_account (enroll);
|
|
|
e06942 |
+ if (res != ADCLI_SUCCESS) {
|
|
|
e06942 |
+ warnx ("Failed to set domain specific keytab name");
|
|
|
e06942 |
+ adcli_enroll_unref (enroll);
|
|
|
e06942 |
+ return 2;
|
|
|
e06942 |
+ }
|
|
|
e06942 |
|
|
|
e06942 |
res = adcli_enroll_load (enroll);
|
|
|
e06942 |
if (res != ADCLI_SUCCESS) {
|
|
|
e06942 |
--
|
|
|
e06942 |
2.28.0
|
|
|
e06942 |
|