|
|
905b4d |
From f0af52e320e8f1b062701b2eb36b49915a4e8194 Mon Sep 17 00:00:00 2001
|
|
|
905b4d |
From: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
905b4d |
Date: Tue, 6 Jan 2015 13:03:34 +0100
|
|
|
905b4d |
Subject: [PATCH 156/160] GPO: Extract server hostname after connecting
|
|
|
905b4d |
|
|
|
905b4d |
https://fedorahosted.org/sssd/ticket/2543
|
|
|
905b4d |
|
|
|
905b4d |
The LDAP URI is not valid prior to connecting to LDAP. Moreover,
|
|
|
905b4d |
reconnecting to a different server might invalidate the URI.
|
|
|
905b4d |
|
|
|
905b4d |
Move reading the URI after the connection has been established.
|
|
|
905b4d |
|
|
|
905b4d |
Reviewed-by: Sumit Bose <sbose@redhat.com>
|
|
|
905b4d |
(cherry picked from commit ccff8e75940963a0f68f86efcddc37133318abfa)
|
|
|
905b4d |
---
|
|
|
905b4d |
src/providers/ad/ad_gpo.c | 58 +++++++++++++++++++++++------------------------
|
|
|
905b4d |
1 file changed, 29 insertions(+), 29 deletions(-)
|
|
|
905b4d |
|
|
|
905b4d |
diff --git a/src/providers/ad/ad_gpo.c b/src/providers/ad/ad_gpo.c
|
|
|
905b4d |
index 083fc8c2cde36bb15d1a1becd3ddac383a4008fe..375ef1d8a7df13911831a55fed5d5a425daaa996 100644
|
|
|
905b4d |
--- a/src/providers/ad/ad_gpo.c
|
|
|
905b4d |
+++ b/src/providers/ad/ad_gpo.c
|
|
|
905b4d |
@@ -1489,8 +1489,6 @@ ad_gpo_access_send(TALLOC_CTX *mem_ctx,
|
|
|
905b4d |
struct tevent_req *req;
|
|
|
905b4d |
struct tevent_req *subreq;
|
|
|
905b4d |
struct ad_gpo_access_state *state;
|
|
|
905b4d |
- char *server_uri;
|
|
|
905b4d |
- LDAPURLDesc *lud;
|
|
|
905b4d |
errno_t ret;
|
|
|
905b4d |
int hret;
|
|
|
905b4d |
hash_key_t key;
|
|
|
905b4d |
@@ -1580,33 +1578,6 @@ ad_gpo_access_send(TALLOC_CTX *mem_ctx,
|
|
|
905b4d |
goto immediately;
|
|
|
905b4d |
}
|
|
|
905b4d |
|
|
|
905b4d |
- /* extract server_hostname from server_uri */
|
|
|
905b4d |
- server_uri = state->conn->service->uri;
|
|
|
905b4d |
- ret = ldap_url_parse(server_uri, &lud;;
|
|
|
905b4d |
- if (ret != LDAP_SUCCESS) {
|
|
|
905b4d |
- DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
905b4d |
- "Failed to parse ldap URI (%s)!\n", server_uri);
|
|
|
905b4d |
- ret = EINVAL;
|
|
|
905b4d |
- goto immediately;
|
|
|
905b4d |
- }
|
|
|
905b4d |
-
|
|
|
905b4d |
- if (lud->lud_host == NULL) {
|
|
|
905b4d |
- DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
905b4d |
- "The LDAP URI (%s) did not contain a host name\n", server_uri);
|
|
|
905b4d |
- ldap_free_urldesc(lud);
|
|
|
905b4d |
- ret = EINVAL;
|
|
|
905b4d |
- goto immediately;
|
|
|
905b4d |
- }
|
|
|
905b4d |
-
|
|
|
905b4d |
- state->server_hostname = talloc_strdup(state, lud->lud_host);
|
|
|
905b4d |
- ldap_free_urldesc(lud);
|
|
|
905b4d |
- if (!state->server_hostname) {
|
|
|
905b4d |
- ret = ENOMEM;
|
|
|
905b4d |
- goto immediately;
|
|
|
905b4d |
- }
|
|
|
905b4d |
- DEBUG(SSSDBG_TRACE_ALL, "server_hostname from uri: %s\n",
|
|
|
905b4d |
- state->server_hostname);
|
|
|
905b4d |
-
|
|
|
905b4d |
subreq = sdap_id_op_connect_send(state->sdap_op, state, &ret;;
|
|
|
905b4d |
if (subreq == NULL) {
|
|
|
905b4d |
DEBUG(SSSDBG_OP_FAILURE,
|
|
|
905b4d |
@@ -1666,6 +1637,8 @@ ad_gpo_connect_done(struct tevent_req *subreq)
|
|
|
905b4d |
char *domain_dn;
|
|
|
905b4d |
int dp_error;
|
|
|
905b4d |
errno_t ret;
|
|
|
905b4d |
+ char *server_uri;
|
|
|
905b4d |
+ LDAPURLDesc *lud;
|
|
|
905b4d |
|
|
|
905b4d |
const char *attrs[] = {AD_AT_DN, AD_AT_UAC, NULL};
|
|
|
905b4d |
|
|
|
905b4d |
@@ -1702,6 +1675,33 @@ ad_gpo_connect_done(struct tevent_req *subreq)
|
|
|
905b4d |
}
|
|
|
905b4d |
}
|
|
|
905b4d |
|
|
|
905b4d |
+ /* extract server_hostname from server_uri */
|
|
|
905b4d |
+ server_uri = state->conn->service->uri;
|
|
|
905b4d |
+ ret = ldap_url_parse(server_uri, &lud;;
|
|
|
905b4d |
+ if (ret != LDAP_SUCCESS) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
905b4d |
+ "Failed to parse ldap URI (%s)!\n", server_uri);
|
|
|
905b4d |
+ ret = EINVAL;
|
|
|
905b4d |
+ goto done;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ if (lud->lud_host == NULL) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
905b4d |
+ "The LDAP URI (%s) did not contain a host name\n", server_uri);
|
|
|
905b4d |
+ ldap_free_urldesc(lud);
|
|
|
905b4d |
+ ret = EINVAL;
|
|
|
905b4d |
+ goto done;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ state->server_hostname = talloc_strdup(state, lud->lud_host);
|
|
|
905b4d |
+ ldap_free_urldesc(lud);
|
|
|
905b4d |
+ if (!state->server_hostname) {
|
|
|
905b4d |
+ ret = ENOMEM;
|
|
|
905b4d |
+ goto done;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+ DEBUG(SSSDBG_TRACE_ALL, "server_hostname from uri: %s\n",
|
|
|
905b4d |
+ state->server_hostname);
|
|
|
905b4d |
+
|
|
|
905b4d |
sam_account_name = sss_krb5_get_primary(state, "%S$", state->ad_hostname);
|
|
|
905b4d |
if (sam_account_name == NULL) {
|
|
|
905b4d |
ret = ENOMEM;
|
|
|
905b4d |
--
|
|
|
905b4d |
2.1.0
|
|
|
905b4d |
|