|
|
8d3578 |
From 2e452583728b2596aba65a96d25f7f8312765538 Mon Sep 17 00:00:00 2001
|
|
|
8d3578 |
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
|
|
|
8d3578 |
Date: Thu, 15 Aug 2019 14:07:01 +0200
|
|
|
8d3578 |
Subject: [PATCH 86/90] ldap: implement autofs get entry
|
|
|
8d3578 |
MIME-Version: 1.0
|
|
|
8d3578 |
Content-Type: text/plain; charset=UTF-8
|
|
|
8d3578 |
Content-Transfer-Encoding: 8bit
|
|
|
8d3578 |
|
|
|
8d3578 |
Resolves:
|
|
|
8d3578 |
https://pagure.io/SSSD/sssd/issue/2607
|
|
|
8d3578 |
|
|
|
8d3578 |
Reviewed-by: Tomáš Halman <thalman@redhat.com>
|
|
|
8d3578 |
---
|
|
|
8d3578 |
src/providers/ipa/ipa_autofs.c | 4 +
|
|
|
8d3578 |
src/providers/ldap/ldap_common.h | 11 +
|
|
|
8d3578 |
src/providers/ldap/sdap_async_autofs.c | 235 +++++++++++++++++-
|
|
|
8d3578 |
src/providers/ldap/sdap_autofs.c | 88 +++++++
|
|
|
8d3578 |
src/providers/ldap/sdap_autofs.h | 8 +
|
|
|
8d3578 |
.../plugins/cache_req_autofs_entry_by_name.c | 4 +-
|
|
|
8d3578 |
6 files changed, 347 insertions(+), 3 deletions(-)
|
|
|
8d3578 |
|
|
|
8d3578 |
diff --git a/src/providers/ipa/ipa_autofs.c b/src/providers/ipa/ipa_autofs.c
|
|
|
8d3578 |
index 19d74071f..5f72d60cd 100644
|
|
|
8d3578 |
--- a/src/providers/ipa/ipa_autofs.c
|
|
|
8d3578 |
+++ b/src/providers/ipa/ipa_autofs.c
|
|
|
8d3578 |
@@ -55,5 +55,9 @@ errno_t ipa_autofs_init(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
sdap_autofs_get_map_handler_send, sdap_autofs_get_map_handler_recv, id_ctx,
|
|
|
8d3578 |
struct sdap_id_ctx, struct dp_autofs_data, struct dp_reply_std);
|
|
|
8d3578 |
|
|
|
8d3578 |
+ dp_set_method(dp_methods, DPM_AUTOFS_GET_ENTRY,
|
|
|
8d3578 |
+ sdap_autofs_get_entry_handler_send, sdap_autofs_get_entry_handler_recv, id_ctx,
|
|
|
8d3578 |
+ struct sdap_id_ctx, struct dp_autofs_data, struct dp_reply_std);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
return ret;
|
|
|
8d3578 |
}
|
|
|
8d3578 |
diff --git a/src/providers/ldap/ldap_common.h b/src/providers/ldap/ldap_common.h
|
|
|
8d3578 |
index 36623aca8..893f29a38 100644
|
|
|
8d3578 |
--- a/src/providers/ldap/ldap_common.h
|
|
|
8d3578 |
+++ b/src/providers/ldap/ldap_common.h
|
|
|
8d3578 |
@@ -177,6 +177,17 @@ sdap_autofs_get_map_handler_recv(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
struct tevent_req *req,
|
|
|
8d3578 |
struct dp_reply_std *data);
|
|
|
8d3578 |
|
|
|
8d3578 |
+struct tevent_req *
|
|
|
8d3578 |
+sdap_autofs_get_entry_handler_send(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
+ struct sdap_id_ctx *id_ctx,
|
|
|
8d3578 |
+ struct dp_autofs_data *data,
|
|
|
8d3578 |
+ struct dp_req_params *params);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+errno_t
|
|
|
8d3578 |
+sdap_autofs_get_entry_handler_recv(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
+ struct tevent_req *req,
|
|
|
8d3578 |
+ struct dp_reply_std *data);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
int sdap_service_init(TALLOC_CTX *memctx, struct be_ctx *ctx,
|
|
|
8d3578 |
const char *service_name, const char *dns_service_name,
|
|
|
8d3578 |
const char *urls, const char *backup_urls,
|
|
|
8d3578 |
diff --git a/src/providers/ldap/sdap_async_autofs.c b/src/providers/ldap/sdap_async_autofs.c
|
|
|
8d3578 |
index 52ceb84ac..c31df2f59 100644
|
|
|
8d3578 |
--- a/src/providers/ldap/sdap_async_autofs.c
|
|
|
8d3578 |
+++ b/src/providers/ldap/sdap_async_autofs.c
|
|
|
8d3578 |
@@ -1100,7 +1100,7 @@ static void sdap_autofs_get_map_connect_done(struct tevent_req *subreq)
|
|
|
8d3578 |
state->opts->sdom->autofs_search_bases,
|
|
|
8d3578 |
state->opts->autofs_mobject_map, false,
|
|
|
8d3578 |
dp_opt_get_int(state->opts->basic, SDAP_SEARCH_TIMEOUT),
|
|
|
8d3578 |
- filter, attrs);
|
|
|
8d3578 |
+ filter, attrs, NULL);
|
|
|
8d3578 |
if (subreq == NULL) {
|
|
|
8d3578 |
state->dp_error = DP_ERR_FATAL;
|
|
|
8d3578 |
tevent_req_error(req, ENOMEM);
|
|
|
8d3578 |
@@ -1177,3 +1177,236 @@ errno_t sdap_autofs_get_map_recv(struct tevent_req *req,
|
|
|
8d3578 |
|
|
|
8d3578 |
return EOK;
|
|
|
8d3578 |
}
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+struct sdap_autofs_get_entry_state {
|
|
|
8d3578 |
+ struct sdap_id_ctx *id_ctx;
|
|
|
8d3578 |
+ struct sdap_options *opts;
|
|
|
8d3578 |
+ struct sdap_id_op *sdap_op;
|
|
|
8d3578 |
+ const char *mapname;
|
|
|
8d3578 |
+ const char *entryname;
|
|
|
8d3578 |
+ int dp_error;
|
|
|
8d3578 |
+};
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+static errno_t sdap_autofs_get_entry_retry(struct tevent_req *req);
|
|
|
8d3578 |
+static void sdap_autofs_get_entry_connect_done(struct tevent_req *subreq);
|
|
|
8d3578 |
+static void sdap_autofs_get_entry_done(struct tevent_req *subreq);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+struct tevent_req *sdap_autofs_get_entry_send(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
+ struct sdap_id_ctx *id_ctx,
|
|
|
8d3578 |
+ const char *mapname,
|
|
|
8d3578 |
+ const char *entryname)
|
|
|
8d3578 |
+{
|
|
|
8d3578 |
+ struct tevent_req *req;
|
|
|
8d3578 |
+ struct sdap_autofs_get_entry_state *state;
|
|
|
8d3578 |
+ int ret;
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ req = tevent_req_create(mem_ctx, &state, struct sdap_autofs_get_entry_state);
|
|
|
8d3578 |
+ if (!req) {
|
|
|
8d3578 |
+ return NULL;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ state->id_ctx = id_ctx;
|
|
|
8d3578 |
+ state->opts = id_ctx->opts;
|
|
|
8d3578 |
+ state->mapname = mapname;
|
|
|
8d3578 |
+ state->entryname = entryname;
|
|
|
8d3578 |
+ state->dp_error = DP_ERR_FATAL;
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ state->sdap_op = sdap_id_op_create(state, id_ctx->conn->conn_cache);
|
|
|
8d3578 |
+ if (!state->sdap_op) {
|
|
|
8d3578 |
+ DEBUG(SSSDBG_OP_FAILURE, "sdap_id_op_create() failed\n");
|
|
|
8d3578 |
+ ret = ENOMEM;
|
|
|
8d3578 |
+ goto done;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ ret = sdap_autofs_get_entry_retry(req);
|
|
|
8d3578 |
+ if (ret == EAGAIN) {
|
|
|
8d3578 |
+ /* asynchronous processing */
|
|
|
8d3578 |
+ return req;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+done:
|
|
|
8d3578 |
+ if (ret == EOK) {
|
|
|
8d3578 |
+ tevent_req_done(req);
|
|
|
8d3578 |
+ } else {
|
|
|
8d3578 |
+ tevent_req_error(req, ret);
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+ tevent_req_post(req, id_ctx->be->ev);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ return req;
|
|
|
8d3578 |
+}
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+static errno_t sdap_autofs_get_entry_retry(struct tevent_req *req)
|
|
|
8d3578 |
+{
|
|
|
8d3578 |
+ struct sdap_autofs_get_entry_state *state;
|
|
|
8d3578 |
+ struct tevent_req *subreq;
|
|
|
8d3578 |
+ int ret;
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ state = tevent_req_data(req, struct sdap_autofs_get_entry_state);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ subreq = sdap_id_op_connect_send(state->sdap_op, state, &ret;;
|
|
|
8d3578 |
+ if (subreq == NULL) {
|
|
|
8d3578 |
+ DEBUG(SSSDBG_CRIT_FAILURE, "sdap_id_op_connect_send() failed: "
|
|
|
8d3578 |
+ "%d(%s)\n", ret, strerror(ret));
|
|
|
8d3578 |
+ return ret;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ tevent_req_set_callback(subreq, sdap_autofs_get_entry_connect_done, req);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ return EAGAIN;
|
|
|
8d3578 |
+}
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+static void sdap_autofs_get_entry_connect_done(struct tevent_req *subreq)
|
|
|
8d3578 |
+{
|
|
|
8d3578 |
+ struct tevent_req *req;
|
|
|
8d3578 |
+ struct sdap_autofs_get_entry_state *state;
|
|
|
8d3578 |
+ struct ldb_message *map;
|
|
|
8d3578 |
+ char *filter;
|
|
|
8d3578 |
+ char *safe_entryname;
|
|
|
8d3578 |
+ const char **attrs;
|
|
|
8d3578 |
+ const char *base_dn;
|
|
|
8d3578 |
+ int dp_error;
|
|
|
8d3578 |
+ int ret;
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ req = tevent_req_callback_data(subreq, struct tevent_req);
|
|
|
8d3578 |
+ state = tevent_req_data(req, struct sdap_autofs_get_entry_state);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ ret = sdap_id_op_connect_recv(subreq, &dp_error);
|
|
|
8d3578 |
+ talloc_zfree(subreq);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ if (ret != EOK) {
|
|
|
8d3578 |
+ DEBUG(SSSDBG_CRIT_FAILURE, "LDAP connection failed "
|
|
|
8d3578 |
+ "[%d]: %s\n", ret, strerror(ret));
|
|
|
8d3578 |
+ state->dp_error = dp_error;
|
|
|
8d3578 |
+ tevent_req_error(req, ret);
|
|
|
8d3578 |
+ return;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ DEBUG(SSSDBG_TRACE_FUNC, "LDAP connection successful\n");
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ ret = sysdb_get_map_byname(state, state->id_ctx->be->domain,
|
|
|
8d3578 |
+ state->mapname, &map);
|
|
|
8d3578 |
+ if (ret == ENOENT) {
|
|
|
8d3578 |
+ DEBUG(SSSDBG_CRIT_FAILURE, "Map %s does not exist!\n", state->mapname);
|
|
|
8d3578 |
+ tevent_req_error(req, ret);
|
|
|
8d3578 |
+ return;
|
|
|
8d3578 |
+ } else if (ret != EOK) {
|
|
|
8d3578 |
+ DEBUG(SSSDBG_CRIT_FAILURE, "Unable to get map %s [%d]: %s\n",
|
|
|
8d3578 |
+ state->mapname, ret, sss_strerror(ret));
|
|
|
8d3578 |
+ tevent_req_error(req, ret);
|
|
|
8d3578 |
+ return;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ base_dn = ldb_msg_find_attr_as_string(map, SYSDB_ORIG_DN, NULL);
|
|
|
8d3578 |
+ if (base_dn == NULL) {
|
|
|
8d3578 |
+ DEBUG(SSSDBG_CRIT_FAILURE, "Cannot get originalDN\n");
|
|
|
8d3578 |
+ tevent_req_error(req, ERR_INTERNAL);
|
|
|
8d3578 |
+ return;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ ret = sss_filter_sanitize(state, state->entryname, &safe_entryname);
|
|
|
8d3578 |
+ if (ret != EOK) {
|
|
|
8d3578 |
+ tevent_req_error(req, ret);
|
|
|
8d3578 |
+ return;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ filter = talloc_asprintf(state, "(&(%s=%s)(objectclass=%s))",
|
|
|
8d3578 |
+ state->opts->autofs_entry_map[SDAP_AT_AUTOFS_ENTRY_KEY].name,
|
|
|
8d3578 |
+ safe_entryname,
|
|
|
8d3578 |
+ state->opts->autofs_entry_map[SDAP_OC_AUTOFS_ENTRY].name);
|
|
|
8d3578 |
+ if (filter == NULL) {
|
|
|
8d3578 |
+ DEBUG(SSSDBG_CRIT_FAILURE, "Failed to build filter\n");
|
|
|
8d3578 |
+ tevent_req_error(req, ret);
|
|
|
8d3578 |
+ return;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ ret = build_attrs_from_map(state, state->opts->autofs_entry_map,
|
|
|
8d3578 |
+ SDAP_OPTS_AUTOFS_ENTRY, NULL, &attrs, NULL);
|
|
|
8d3578 |
+ if (ret != EOK) {
|
|
|
8d3578 |
+ DEBUG(SSSDBG_CRIT_FAILURE, "Failed to build attributes from map\n");
|
|
|
8d3578 |
+ tevent_req_error(req, ret);
|
|
|
8d3578 |
+ return;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ subreq = sdap_search_bases_return_first_send(state, state->id_ctx->be->ev,
|
|
|
8d3578 |
+ state->opts, sdap_id_op_handle(state->sdap_op),
|
|
|
8d3578 |
+ state->opts->sdom->autofs_search_bases,
|
|
|
8d3578 |
+ state->opts->autofs_entry_map, false,
|
|
|
8d3578 |
+ dp_opt_get_int(state->opts->basic, SDAP_SEARCH_TIMEOUT),
|
|
|
8d3578 |
+ filter, attrs, base_dn);
|
|
|
8d3578 |
+ if (subreq == NULL) {
|
|
|
8d3578 |
+ state->dp_error = DP_ERR_FATAL;
|
|
|
8d3578 |
+ tevent_req_error(req, ENOMEM);
|
|
|
8d3578 |
+ return;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ tevent_req_set_callback(subreq, sdap_autofs_get_entry_done, req);
|
|
|
8d3578 |
+}
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+static void sdap_autofs_get_entry_done(struct tevent_req *subreq)
|
|
|
8d3578 |
+{
|
|
|
8d3578 |
+ struct tevent_req *req;
|
|
|
8d3578 |
+ struct sdap_autofs_get_entry_state *state;
|
|
|
8d3578 |
+ struct sysdb_attrs **reply;
|
|
|
8d3578 |
+ size_t reply_count;
|
|
|
8d3578 |
+ errno_t ret;
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ req = tevent_req_callback_data(subreq, struct tevent_req);
|
|
|
8d3578 |
+ state = tevent_req_data(req, struct sdap_autofs_get_entry_state);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ ret = sdap_search_bases_return_first_recv(subreq, state, &reply_count,
|
|
|
8d3578 |
+ &reply);
|
|
|
8d3578 |
+ talloc_zfree(subreq);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ ret = sdap_id_op_done(state->sdap_op, ret, &state->dp_error);
|
|
|
8d3578 |
+ if (state->dp_error == DP_ERR_OK && ret != EOK) {
|
|
|
8d3578 |
+ /* retry */
|
|
|
8d3578 |
+ ret = sdap_autofs_get_entry_retry(req);
|
|
|
8d3578 |
+ if (ret != EOK) {
|
|
|
8d3578 |
+ tevent_req_error(req, ret);
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+ return;
|
|
|
8d3578 |
+ } else if (ret != EOK) {
|
|
|
8d3578 |
+ tevent_req_error(req, ret);
|
|
|
8d3578 |
+ return;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ if (reply_count == 0) {
|
|
|
8d3578 |
+ ret = sysdb_del_autofsentry_by_key(state->id_ctx->be->domain,
|
|
|
8d3578 |
+ state->mapname, state->entryname);
|
|
|
8d3578 |
+ if (ret != EOK) {
|
|
|
8d3578 |
+ DEBUG(SSSDBG_MINOR_FAILURE, "Cannot delete entry %s:%s\n",
|
|
|
8d3578 |
+ state->mapname, state->entryname);
|
|
|
8d3578 |
+ tevent_req_error(req, ret);
|
|
|
8d3578 |
+ return;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ tevent_req_done(req);
|
|
|
8d3578 |
+ return;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ ret = add_autofs_entry(state->id_ctx->be->domain, state->mapname,
|
|
|
8d3578 |
+ state->opts, reply[0], time(NULL));
|
|
|
8d3578 |
+ if (ret != EOK) {
|
|
|
8d3578 |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
8d3578 |
+ "Cannot save autofs entry %s:%s [%d]: %s\n",
|
|
|
8d3578 |
+ state->mapname, state->entryname, ret, strerror(ret));
|
|
|
8d3578 |
+ tevent_req_error(req, ret);
|
|
|
8d3578 |
+ return;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ tevent_req_done(req);
|
|
|
8d3578 |
+}
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+errno_t sdap_autofs_get_entry_recv(struct tevent_req *req,
|
|
|
8d3578 |
+ int *dp_error)
|
|
|
8d3578 |
+{
|
|
|
8d3578 |
+ struct sdap_autofs_get_entry_state *state;
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ state = tevent_req_data(req, struct sdap_autofs_get_entry_state);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ TEVENT_REQ_RETURN_ON_ERROR(req);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ *dp_error = state->dp_error;
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ return EOK;
|
|
|
8d3578 |
+}
|
|
|
8d3578 |
diff --git a/src/providers/ldap/sdap_autofs.c b/src/providers/ldap/sdap_autofs.c
|
|
|
8d3578 |
index 9a5ed11e8..b1e4b5aef 100644
|
|
|
8d3578 |
--- a/src/providers/ldap/sdap_autofs.c
|
|
|
8d3578 |
+++ b/src/providers/ldap/sdap_autofs.c
|
|
|
8d3578 |
@@ -391,6 +391,90 @@ sdap_autofs_get_map_handler_recv(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
return EOK;
|
|
|
8d3578 |
}
|
|
|
8d3578 |
|
|
|
8d3578 |
+struct sdap_autofs_get_entry_handler_state {
|
|
|
8d3578 |
+ struct dp_reply_std reply;
|
|
|
8d3578 |
+};
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+static void sdap_autofs_get_entry_handler_done(struct tevent_req *subreq);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+struct tevent_req *
|
|
|
8d3578 |
+sdap_autofs_get_entry_handler_send(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
+ struct sdap_id_ctx *id_ctx,
|
|
|
8d3578 |
+ struct dp_autofs_data *data,
|
|
|
8d3578 |
+ struct dp_req_params *params)
|
|
|
8d3578 |
+{
|
|
|
8d3578 |
+ struct sdap_autofs_get_entry_handler_state *state;
|
|
|
8d3578 |
+ struct tevent_req *subreq;
|
|
|
8d3578 |
+ struct tevent_req *req;
|
|
|
8d3578 |
+ errno_t ret;
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ req = tevent_req_create(mem_ctx, &state,
|
|
|
8d3578 |
+ struct sdap_autofs_get_entry_handler_state);
|
|
|
8d3578 |
+ if (req == NULL) {
|
|
|
8d3578 |
+ DEBUG(SSSDBG_CRIT_FAILURE, "tevent_req_create() failed\n");
|
|
|
8d3578 |
+ return NULL;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ DEBUG(SSSDBG_FUNC_DATA, "Requested refresh for: %s:%s\n",
|
|
|
8d3578 |
+ data->mapname, data->entryname);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ subreq = sdap_autofs_get_entry_send(mem_ctx, id_ctx,
|
|
|
8d3578 |
+ data->mapname, data->entryname);
|
|
|
8d3578 |
+ if (subreq == NULL) {
|
|
|
8d3578 |
+ DEBUG(SSSDBG_CRIT_FAILURE, "Unable to send request for %s:%s.\n",
|
|
|
8d3578 |
+ data->mapname, data->entryname);
|
|
|
8d3578 |
+ ret = ENOMEM;
|
|
|
8d3578 |
+ goto immediately;
|
|
|
8d3578 |
+ }
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ tevent_req_set_callback(subreq, sdap_autofs_get_entry_handler_done, req);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ return req;
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+immediately:
|
|
|
8d3578 |
+ dp_reply_std_set(&state->reply, DP_ERR_DECIDE, ret, NULL);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ /* TODO For backward compatibility we always return EOK to DP now. */
|
|
|
8d3578 |
+ tevent_req_done(req);
|
|
|
8d3578 |
+ tevent_req_post(req, params->ev);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ return req;
|
|
|
8d3578 |
+}
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+static void sdap_autofs_get_entry_handler_done(struct tevent_req *subreq)
|
|
|
8d3578 |
+{
|
|
|
8d3578 |
+ struct sdap_autofs_get_entry_handler_state *state;
|
|
|
8d3578 |
+ struct tevent_req *req;
|
|
|
8d3578 |
+ int dp_error;
|
|
|
8d3578 |
+ errno_t ret;
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ req = tevent_req_callback_data(subreq, struct tevent_req);
|
|
|
8d3578 |
+ state = tevent_req_data(req, struct sdap_autofs_get_entry_handler_state);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ ret = sdap_autofs_get_entry_recv(subreq, &dp_error);
|
|
|
8d3578 |
+ talloc_zfree(subreq);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ /* TODO For backward compatibility we always return EOK to DP now. */
|
|
|
8d3578 |
+ dp_reply_std_set(&state->reply, dp_error, ret, NULL);
|
|
|
8d3578 |
+ tevent_req_done(req);
|
|
|
8d3578 |
+}
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+errno_t
|
|
|
8d3578 |
+sdap_autofs_get_entry_handler_recv(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
+ struct tevent_req *req,
|
|
|
8d3578 |
+ struct dp_reply_std *data)
|
|
|
8d3578 |
+{
|
|
|
8d3578 |
+ struct sdap_autofs_get_entry_handler_state *state = NULL;
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ state = tevent_req_data(req, struct sdap_autofs_get_entry_handler_state);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ TEVENT_REQ_RETURN_ON_ERROR(req);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ *data = state->reply;
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+ return EOK;
|
|
|
8d3578 |
+}
|
|
|
8d3578 |
+
|
|
|
8d3578 |
errno_t sdap_autofs_init(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
struct be_ctx *be_ctx,
|
|
|
8d3578 |
struct sdap_id_ctx *id_ctx,
|
|
|
8d3578 |
@@ -414,5 +498,9 @@ errno_t sdap_autofs_init(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
sdap_autofs_get_map_handler_send, sdap_autofs_get_map_handler_recv, id_ctx,
|
|
|
8d3578 |
struct sdap_id_ctx, struct dp_autofs_data, struct dp_reply_std);
|
|
|
8d3578 |
|
|
|
8d3578 |
+ dp_set_method(dp_methods, DPM_AUTOFS_GET_ENTRY,
|
|
|
8d3578 |
+ sdap_autofs_get_entry_handler_send, sdap_autofs_get_entry_handler_recv, id_ctx,
|
|
|
8d3578 |
+ struct sdap_id_ctx, struct dp_autofs_data, struct dp_reply_std);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
return EOK;
|
|
|
8d3578 |
}
|
|
|
8d3578 |
diff --git a/src/providers/ldap/sdap_autofs.h b/src/providers/ldap/sdap_autofs.h
|
|
|
8d3578 |
index 34b9ca953..210393746 100644
|
|
|
8d3578 |
--- a/src/providers/ldap/sdap_autofs.h
|
|
|
8d3578 |
+++ b/src/providers/ldap/sdap_autofs.h
|
|
|
8d3578 |
@@ -50,5 +50,13 @@ struct tevent_req *sdap_autofs_get_map_send(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
errno_t sdap_autofs_get_map_recv(struct tevent_req *req,
|
|
|
8d3578 |
int *dp_error);
|
|
|
8d3578 |
|
|
|
8d3578 |
+struct tevent_req *sdap_autofs_get_entry_send(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
+ struct sdap_id_ctx *id_ctx,
|
|
|
8d3578 |
+ const char *mapname,
|
|
|
8d3578 |
+ const char *entryname);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
+errno_t sdap_autofs_get_entry_recv(struct tevent_req *req,
|
|
|
8d3578 |
+ int *dp_error);
|
|
|
8d3578 |
+
|
|
|
8d3578 |
#endif /* _SDAP_AUTOFS_H_ */
|
|
|
8d3578 |
|
|
|
8d3578 |
diff --git a/src/responder/common/cache_req/plugins/cache_req_autofs_entry_by_name.c b/src/responder/common/cache_req/plugins/cache_req_autofs_entry_by_name.c
|
|
|
8d3578 |
index f4d0cb140..422fe90c4 100644
|
|
|
8d3578 |
--- a/src/responder/common/cache_req/plugins/cache_req_autofs_entry_by_name.c
|
|
|
8d3578 |
+++ b/src/responder/common/cache_req/plugins/cache_req_autofs_entry_by_name.c
|
|
|
8d3578 |
@@ -72,8 +72,8 @@ cache_req_autofs_entry_by_name_dp_send(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
struct ldb_result *result)
|
|
|
8d3578 |
{
|
|
|
8d3578 |
return sss_dp_get_autofs_send(mem_ctx, cr->rctx, domain, true,
|
|
|
8d3578 |
- SSS_DP_AUTOFS_ENUMERATE,
|
|
|
8d3578 |
- data->name.name, NULL);
|
|
|
8d3578 |
+ SSS_DP_AUTOFS_GET_ENTRY,
|
|
|
8d3578 |
+ data->name.name, data->autofs_entry_name);
|
|
|
8d3578 |
}
|
|
|
8d3578 |
|
|
|
8d3578 |
const struct cache_req_plugin cache_req_autofs_entry_by_name = {
|
|
|
8d3578 |
--
|
|
|
8d3578 |
2.20.1
|
|
|
8d3578 |
|