|
|
5fca41 |
From e683556dc6671a6047de8bb970d32360d5aa59dc Mon Sep 17 00:00:00 2001
|
|
|
5fca41 |
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
|
|
|
5fca41 |
Date: Tue, 6 Aug 2019 12:08:59 +0200
|
|
|
5fca41 |
Subject: [PATCH 76/90] cache_req: add autofs map by name plugin
|
|
|
5fca41 |
MIME-Version: 1.0
|
|
|
5fca41 |
Content-Type: text/plain; charset=UTF-8
|
|
|
5fca41 |
Content-Transfer-Encoding: 8bit
|
|
|
5fca41 |
|
|
|
5fca41 |
We will use the current data provider call that downloads all map entries
|
|
|
5fca41 |
but we will replace it later when new call is available.
|
|
|
5fca41 |
|
|
|
5fca41 |
Resolves:
|
|
|
5fca41 |
https://pagure.io/SSSD/sssd/issue/2607
|
|
|
5fca41 |
|
|
|
5fca41 |
Reviewed-by: Tomáš Halman <thalman@redhat.com>
|
|
|
5fca41 |
---
|
|
|
5fca41 |
Makefile.am | 1 +
|
|
|
5fca41 |
src/responder/common/cache_req/cache_req.c | 1 +
|
|
|
5fca41 |
src/responder/common/cache_req/cache_req.h | 13 ++
|
|
|
5fca41 |
.../common/cache_req/cache_req_data.c | 1 +
|
|
|
5fca41 |
.../common/cache_req/cache_req_plugin.h | 1 +
|
|
|
5fca41 |
.../plugins/cache_req_autofs_map_by_name.c | 124 ++++++++++++++++++
|
|
|
5fca41 |
src/tests/cwrap/Makefile.am | 1 +
|
|
|
5fca41 |
7 files changed, 142 insertions(+)
|
|
|
5fca41 |
create mode 100644 src/responder/common/cache_req/plugins/cache_req_autofs_map_by_name.c
|
|
|
5fca41 |
|
|
|
5fca41 |
diff --git a/Makefile.am b/Makefile.am
|
|
|
5fca41 |
index 879f38311..461a9355f 100644
|
|
|
5fca41 |
--- a/Makefile.am
|
|
|
5fca41 |
+++ b/Makefile.am
|
|
|
5fca41 |
@@ -560,6 +560,7 @@ SSSD_CACHE_REQ_OBJ = \
|
|
|
5fca41 |
src/responder/common/cache_req/plugins/cache_req_netgroup_by_name.c \
|
|
|
5fca41 |
src/responder/common/cache_req/plugins/cache_req_host_by_name.c \
|
|
|
5fca41 |
src/responder/common/cache_req/plugins/cache_req_autofs_map_entries.c \
|
|
|
5fca41 |
+ src/responder/common/cache_req/plugins/cache_req_autofs_map_by_name.c \
|
|
|
5fca41 |
$(NULL)
|
|
|
5fca41 |
|
|
|
5fca41 |
SSSD_RESPONDER_IFACE_OBJ = \
|
|
|
5fca41 |
diff --git a/src/responder/common/cache_req/cache_req.c b/src/responder/common/cache_req/cache_req.c
|
|
|
5fca41 |
index 2ce9deca0..75f396a23 100644
|
|
|
5fca41 |
--- a/src/responder/common/cache_req/cache_req.c
|
|
|
5fca41 |
+++ b/src/responder/common/cache_req/cache_req.c
|
|
|
5fca41 |
@@ -62,6 +62,7 @@ cache_req_get_plugin(enum cache_req_type type)
|
|
|
5fca41 |
&cache_req_host_by_name,
|
|
|
5fca41 |
|
|
|
5fca41 |
&cache_req_autofs_map_entries,
|
|
|
5fca41 |
+ &cache_req_autofs_map_by_name
|
|
|
5fca41 |
};
|
|
|
5fca41 |
|
|
|
5fca41 |
if (type >= CACHE_REQ_SENTINEL) {
|
|
|
5fca41 |
diff --git a/src/responder/common/cache_req/cache_req.h b/src/responder/common/cache_req/cache_req.h
|
|
|
5fca41 |
index 0c214a483..66a13445c 100644
|
|
|
5fca41 |
--- a/src/responder/common/cache_req/cache_req.h
|
|
|
5fca41 |
+++ b/src/responder/common/cache_req/cache_req.h
|
|
|
5fca41 |
@@ -55,6 +55,7 @@ enum cache_req_type {
|
|
|
5fca41 |
CACHE_REQ_HOST_BY_NAME,
|
|
|
5fca41 |
|
|
|
5fca41 |
CACHE_REQ_AUTOFS_MAP_ENTRIES,
|
|
|
5fca41 |
+ CACHE_REQ_AUTOFS_MAP_BY_NAME,
|
|
|
5fca41 |
|
|
|
5fca41 |
CACHE_REQ_SENTINEL
|
|
|
5fca41 |
};
|
|
|
5fca41 |
@@ -444,4 +445,16 @@ cache_req_autofs_map_entries_send(TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
#define cache_req_autofs_map_entries_recv(mem_ctx, req, _result) \
|
|
|
5fca41 |
cache_req_single_domain_recv(mem_ctx, req, _result)
|
|
|
5fca41 |
|
|
|
5fca41 |
+struct tevent_req *
|
|
|
5fca41 |
+cache_req_autofs_map_by_name_send(TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
+ struct tevent_context *ev,
|
|
|
5fca41 |
+ struct resp_ctx *rctx,
|
|
|
5fca41 |
+ struct sss_nc_ctx *ncache,
|
|
|
5fca41 |
+ int cache_refresh_percent,
|
|
|
5fca41 |
+ const char *domain,
|
|
|
5fca41 |
+ const char *name);
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+#define cache_req_autofs_map_by_name_recv(mem_ctx, req, _result) \
|
|
|
5fca41 |
+ cache_req_single_domain_recv(mem_ctx, req, _result)
|
|
|
5fca41 |
+
|
|
|
5fca41 |
#endif /* _CACHE_REQ_H_ */
|
|
|
5fca41 |
diff --git a/src/responder/common/cache_req/cache_req_data.c b/src/responder/common/cache_req/cache_req_data.c
|
|
|
5fca41 |
index 20d73ebfd..ad6176641 100644
|
|
|
5fca41 |
--- a/src/responder/common/cache_req/cache_req_data.c
|
|
|
5fca41 |
+++ b/src/responder/common/cache_req/cache_req_data.c
|
|
|
5fca41 |
@@ -94,6 +94,7 @@ cache_req_data_create(TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
case CACHE_REQ_NETGROUP_BY_NAME:
|
|
|
5fca41 |
case CACHE_REQ_OBJECT_BY_NAME:
|
|
|
5fca41 |
case CACHE_REQ_AUTOFS_MAP_ENTRIES:
|
|
|
5fca41 |
+ case CACHE_REQ_AUTOFS_MAP_BY_NAME:
|
|
|
5fca41 |
if (input->name.input == NULL) {
|
|
|
5fca41 |
DEBUG(SSSDBG_CRIT_FAILURE, "Bug: name cannot be NULL!\n");
|
|
|
5fca41 |
ret = ERR_INTERNAL;
|
|
|
5fca41 |
diff --git a/src/responder/common/cache_req/cache_req_plugin.h b/src/responder/common/cache_req/cache_req_plugin.h
|
|
|
5fca41 |
index 1071cd889..c040bf380 100644
|
|
|
5fca41 |
--- a/src/responder/common/cache_req/cache_req_plugin.h
|
|
|
5fca41 |
+++ b/src/responder/common/cache_req/cache_req_plugin.h
|
|
|
5fca41 |
@@ -315,5 +315,6 @@ extern const struct cache_req_plugin cache_req_svc_by_port;
|
|
|
5fca41 |
extern const struct cache_req_plugin cache_req_netgroup_by_name;
|
|
|
5fca41 |
extern const struct cache_req_plugin cache_req_host_by_name;
|
|
|
5fca41 |
extern const struct cache_req_plugin cache_req_autofs_map_entries;
|
|
|
5fca41 |
+extern const struct cache_req_plugin cache_req_autofs_map_by_name;
|
|
|
5fca41 |
|
|
|
5fca41 |
#endif /* _CACHE_REQ_PLUGIN_H_ */
|
|
|
5fca41 |
diff --git a/src/responder/common/cache_req/plugins/cache_req_autofs_map_by_name.c b/src/responder/common/cache_req/plugins/cache_req_autofs_map_by_name.c
|
|
|
5fca41 |
new file mode 100644
|
|
|
5fca41 |
index 000000000..2f69c762c
|
|
|
5fca41 |
--- /dev/null
|
|
|
5fca41 |
+++ b/src/responder/common/cache_req/plugins/cache_req_autofs_map_by_name.c
|
|
|
5fca41 |
@@ -0,0 +1,124 @@
|
|
|
5fca41 |
+/*
|
|
|
5fca41 |
+ Authors:
|
|
|
5fca41 |
+ Pavel Březina <pbrezina@redhat.com>
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ Copyright (C) 2019 Red Hat
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ This program is free software; you can redistribute it and/or modify
|
|
|
5fca41 |
+ it under the terms of the GNU General Public License as published by
|
|
|
5fca41 |
+ the Free Software Foundation; either version 3 of the License, or
|
|
|
5fca41 |
+ (at your option) any later version.
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ This program is distributed in the hope that it will be useful,
|
|
|
5fca41 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
5fca41 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
5fca41 |
+ GNU General Public License for more details.
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ You should have received a copy of the GNU General Public License
|
|
|
5fca41 |
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
5fca41 |
+*/
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+#include <talloc.h>
|
|
|
5fca41 |
+#include <ldb.h>
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+#include "db/sysdb.h"
|
|
|
5fca41 |
+#include "db/sysdb_autofs.h"
|
|
|
5fca41 |
+#include "util/util.h"
|
|
|
5fca41 |
+#include "providers/data_provider.h"
|
|
|
5fca41 |
+#include "responder/common/cache_req/cache_req_plugin.h"
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+static const char *
|
|
|
5fca41 |
+cache_req_autofs_map_by_name_create_debug_name(TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
+ struct cache_req_data *data,
|
|
|
5fca41 |
+ struct sss_domain_info *domain)
|
|
|
5fca41 |
+{
|
|
|
5fca41 |
+ return talloc_strdup(mem_ctx, data->name.name);
|
|
|
5fca41 |
+}
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+static errno_t
|
|
|
5fca41 |
+cache_req_autofs_map_by_name_lookup(TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
+ struct cache_req *cr,
|
|
|
5fca41 |
+ struct cache_req_data *data,
|
|
|
5fca41 |
+ struct sss_domain_info *domain,
|
|
|
5fca41 |
+ struct ldb_result **_result)
|
|
|
5fca41 |
+{
|
|
|
5fca41 |
+ struct ldb_message *map;
|
|
|
5fca41 |
+ struct ldb_result *result;
|
|
|
5fca41 |
+ errno_t ret;
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ ret = sysdb_get_map_byname(mem_ctx, domain, data->name.name, &map);
|
|
|
5fca41 |
+ if (ret != EOK) {
|
|
|
5fca41 |
+ return ret;
|
|
|
5fca41 |
+ }
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ result = cache_req_create_ldb_result_from_msg(mem_ctx, map);
|
|
|
5fca41 |
+ if (result == NULL) {
|
|
|
5fca41 |
+ talloc_free(map);
|
|
|
5fca41 |
+ return ENOMEM;
|
|
|
5fca41 |
+ }
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ *_result = talloc_steal(mem_ctx, result);
|
|
|
5fca41 |
+ return EOK;
|
|
|
5fca41 |
+}
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+static struct tevent_req *
|
|
|
5fca41 |
+cache_req_autofs_map_by_name_dp_send(TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
+ struct cache_req *cr,
|
|
|
5fca41 |
+ struct cache_req_data *data,
|
|
|
5fca41 |
+ struct sss_domain_info *domain,
|
|
|
5fca41 |
+ struct ldb_result *result)
|
|
|
5fca41 |
+{
|
|
|
5fca41 |
+ return sss_dp_get_autofs_send(mem_ctx, cr->rctx, domain, true,
|
|
|
5fca41 |
+ SSS_DP_AUTOFS, data->name.name);
|
|
|
5fca41 |
+}
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+const struct cache_req_plugin cache_req_autofs_map_by_name = {
|
|
|
5fca41 |
+ .name = "Get autofs map",
|
|
|
5fca41 |
+ .attr_expiration = SYSDB_CACHE_EXPIRE,
|
|
|
5fca41 |
+ .parse_name = true,
|
|
|
5fca41 |
+ .ignore_default_domain = true,
|
|
|
5fca41 |
+ .bypass_cache = false,
|
|
|
5fca41 |
+ .only_one_result = false,
|
|
|
5fca41 |
+ .search_all_domains = false,
|
|
|
5fca41 |
+ .require_enumeration = false,
|
|
|
5fca41 |
+ .allow_missing_fqn = true,
|
|
|
5fca41 |
+ .allow_switch_to_upn = false,
|
|
|
5fca41 |
+ .upn_equivalent = CACHE_REQ_SENTINEL,
|
|
|
5fca41 |
+ .get_next_domain_flags = 0,
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ .is_well_known_fn = NULL,
|
|
|
5fca41 |
+ .prepare_domain_data_fn = NULL,
|
|
|
5fca41 |
+ .create_debug_name_fn = cache_req_autofs_map_by_name_create_debug_name,
|
|
|
5fca41 |
+ .global_ncache_add_fn = NULL,
|
|
|
5fca41 |
+ .ncache_check_fn = NULL,
|
|
|
5fca41 |
+ .ncache_add_fn = NULL,
|
|
|
5fca41 |
+ .ncache_filter_fn = NULL,
|
|
|
5fca41 |
+ .lookup_fn = cache_req_autofs_map_by_name_lookup,
|
|
|
5fca41 |
+ .dp_send_fn = cache_req_autofs_map_by_name_dp_send,
|
|
|
5fca41 |
+ .dp_recv_fn = cache_req_common_dp_recv,
|
|
|
5fca41 |
+ .dp_get_domain_check_fn = NULL,
|
|
|
5fca41 |
+ .dp_get_domain_send_fn = NULL,
|
|
|
5fca41 |
+ .dp_get_domain_recv_fn = NULL,
|
|
|
5fca41 |
+};
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+struct tevent_req *
|
|
|
5fca41 |
+cache_req_autofs_map_by_name_send(TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
+ struct tevent_context *ev,
|
|
|
5fca41 |
+ struct resp_ctx *rctx,
|
|
|
5fca41 |
+ struct sss_nc_ctx *ncache,
|
|
|
5fca41 |
+ int cache_refresh_percent,
|
|
|
5fca41 |
+ const char *domain,
|
|
|
5fca41 |
+ const char *name)
|
|
|
5fca41 |
+{
|
|
|
5fca41 |
+ struct cache_req_data *data;
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ data = cache_req_data_name(mem_ctx, CACHE_REQ_AUTOFS_MAP_BY_NAME, name);
|
|
|
5fca41 |
+ if (data == NULL) {
|
|
|
5fca41 |
+ return NULL;
|
|
|
5fca41 |
+ }
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ return cache_req_steal_data_and_send(mem_ctx, ev, rctx, ncache,
|
|
|
5fca41 |
+ cache_refresh_percent,
|
|
|
5fca41 |
+ CACHE_REQ_POSIX_DOM, domain,
|
|
|
5fca41 |
+ data);
|
|
|
5fca41 |
+}
|
|
|
5fca41 |
diff --git a/src/tests/cwrap/Makefile.am b/src/tests/cwrap/Makefile.am
|
|
|
5fca41 |
index dfaf3f770..3fbcebf3c 100644
|
|
|
5fca41 |
--- a/src/tests/cwrap/Makefile.am
|
|
|
5fca41 |
+++ b/src/tests/cwrap/Makefile.am
|
|
|
5fca41 |
@@ -65,6 +65,7 @@ SSSD_CACHE_REQ_OBJ = \
|
|
|
5fca41 |
../../../src/responder/common/cache_req/plugins/cache_req_netgroup_by_name.c \
|
|
|
5fca41 |
../../../src/responder/common/cache_req/plugins/cache_req_host_by_name.c \
|
|
|
5fca41 |
../../../src/responder/common/cache_req/plugins/cache_req_autofs_map_entries.c \
|
|
|
5fca41 |
+ ../../../src/responder/common/cache_req/plugins/cache_req_autofs_map_by_name.c \
|
|
|
5fca41 |
$(NULL)
|
|
|
5fca41 |
|
|
|
5fca41 |
SSSD_RESPONDER_IFACE_OBJ = \
|
|
|
5fca41 |
--
|
|
|
5fca41 |
2.20.1
|
|
|
5fca41 |
|