summaryrefslogtreecommitdiffstats
path: root/src/responder/common
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2016-11-07 13:12:00 +0100
committerLukas Slebodnik <lslebodn@redhat.com>2016-12-19 23:23:28 +0100
commit0ae7e46a3990c47873fca879a9395e3ce00d9150 (patch)
treee80e1f573cdbe6a00804c4dd4621b2b13b3704ca /src/responder/common
parentc2fc9459c31cb1192ab3c15ce4df1c150e99bf95 (diff)
downloadsssd-0ae7e46a3990c47873fca879a9395e3ce00d9150.tar.gz
sssd-0ae7e46a3990c47873fca879a9395e3ce00d9150.tar.xz
sssd-0ae7e46a3990c47873fca879a9395e3ce00d9150.zip
cache_req: add support for services enumeration
Resolves: https://fedorahosted.org/sssd/ticket/3151 Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
Diffstat (limited to 'src/responder/common')
-rw-r--r--src/responder/common/cache_req/cache_req.c1
-rw-r--r--src/responder/common/cache_req/cache_req.h1
-rw-r--r--src/responder/common/cache_req/cache_req_data.c1
-rw-r--r--src/responder/common/cache_req/cache_req_plugin.h1
-rw-r--r--src/responder/common/cache_req/plugins/cache_req_enum_svc.c103
5 files changed, 107 insertions, 0 deletions
diff --git a/src/responder/common/cache_req/cache_req.c b/src/responder/common/cache_req/cache_req.c
index 9bf63b191..450a00768 100644
--- a/src/responder/common/cache_req/cache_req.c
+++ b/src/responder/common/cache_req/cache_req.c
@@ -47,6 +47,7 @@ cache_req_get_plugin(enum cache_req_type type)
&cache_req_enum_users,
&cache_req_enum_groups,
+ &cache_req_enum_svc,
&cache_req_svc_by_name,
&cache_req_svc_by_port,
diff --git a/src/responder/common/cache_req/cache_req.h b/src/responder/common/cache_req/cache_req.h
index c91d88c83..3ec6fced8 100644
--- a/src/responder/common/cache_req/cache_req.h
+++ b/src/responder/common/cache_req/cache_req.h
@@ -43,6 +43,7 @@ enum cache_req_type {
CACHE_REQ_ENUM_USERS,
CACHE_REQ_ENUM_GROUPS,
+ CACHE_REQ_ENUM_SVC,
CACHE_REQ_SVC_BY_NAME,
CACHE_REQ_SVC_BY_PORT,
diff --git a/src/responder/common/cache_req/cache_req_data.c b/src/responder/common/cache_req/cache_req_data.c
index fcbeef82c..093a17dd5 100644
--- a/src/responder/common/cache_req/cache_req_data.c
+++ b/src/responder/common/cache_req/cache_req_data.c
@@ -97,6 +97,7 @@ cache_req_data_create(TALLOC_CTX *mem_ctx,
break;
case CACHE_REQ_ENUM_USERS:
case CACHE_REQ_ENUM_GROUPS:
+ case CACHE_REQ_ENUM_SVC:
break;
case CACHE_REQ_SVC_BY_NAME:
if (input->svc.name->input == NULL) {
diff --git a/src/responder/common/cache_req/cache_req_plugin.h b/src/responder/common/cache_req/cache_req_plugin.h
index 6b461fa45..50993cbbc 100644
--- a/src/responder/common/cache_req/cache_req_plugin.h
+++ b/src/responder/common/cache_req/cache_req_plugin.h
@@ -196,6 +196,7 @@ extern struct cache_req_plugin cache_req_group_by_filter;
extern struct cache_req_plugin cache_req_object_by_sid;
extern struct cache_req_plugin cache_req_enum_users;
extern struct cache_req_plugin cache_req_enum_groups;
+extern struct cache_req_plugin cache_req_enum_svc;
extern struct cache_req_plugin cache_req_svc_by_name;
extern struct cache_req_plugin cache_req_svc_by_port;
diff --git a/src/responder/common/cache_req/plugins/cache_req_enum_svc.c b/src/responder/common/cache_req/plugins/cache_req_enum_svc.c
new file mode 100644
index 000000000..9e4d5aa30
--- /dev/null
+++ b/src/responder/common/cache_req/plugins/cache_req_enum_svc.c
@@ -0,0 +1,103 @@
+/*
+ Authors:
+ Pavel Březina <pbrezina@redhat.com>
+
+ Copyright (C) 2016 Red Hat
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <talloc.h>
+#include <ldb.h>
+
+#include "db/sysdb.h"
+#include "db/sysdb_services.h"
+#include "util/util.h"
+#include "providers/data_provider.h"
+#include "responder/common/cache_req/cache_req_plugin.h"
+
+static const char *
+cache_req_enum_svc_create_debug_name(TALLOC_CTX *mem_ctx,
+ struct cache_req_data *data,
+ struct sss_domain_info *domain)
+{
+ return talloc_strdup(mem_ctx, "Services enumeration");
+}
+
+static errno_t
+cache_req_enum_svc_lookup(TALLOC_CTX *mem_ctx,
+ struct cache_req *cr,
+ struct cache_req_data *data,
+ struct sss_domain_info *domain,
+ struct ldb_result **_result)
+{
+ return sysdb_enumservent(mem_ctx, domain, _result);
+}
+
+static errno_t
+cache_req_enum_svc_dpreq_params(TALLOC_CTX *mem_ctx,
+ struct cache_req *cr,
+ struct ldb_result *result,
+ const char **_string,
+ uint32_t *_id,
+ const char **_flag)
+{
+ *_id = 0;
+ *_string = NULL;
+ *_flag = NULL;
+
+ return EOK;
+}
+
+struct cache_req_plugin cache_req_enum_svc = {
+ .name = "Enumerate services",
+ .dp_type = SSS_DP_SERVICES,
+ .attr_expiration = SYSDB_CACHE_EXPIRE,
+ .parse_name = false,
+ .bypass_cache = true,
+ .only_one_result = false,
+ .search_all_domains = true,
+ .require_enumeration = true,
+ .allow_missing_fqn = true,
+ .allow_switch_to_upn = false,
+ .upn_equivalent = CACHE_REQ_SENTINEL,
+ .get_next_domain_flags = 0,
+
+ .prepare_domain_data_fn = NULL,
+ .create_debug_name_fn = cache_req_enum_svc_create_debug_name,
+ .global_ncache_add_fn = NULL,
+ .ncache_check_fn = NULL,
+ .ncache_add_fn = NULL,
+ .lookup_fn = cache_req_enum_svc_lookup,
+ .dpreq_params_fn = cache_req_enum_svc_dpreq_params
+};
+
+struct tevent_req *
+cache_req_enum_svc_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct resp_ctx *rctx,
+ struct sss_nc_ctx *ncache,
+ int cache_refresh_percent,
+ const char *domain)
+{
+ struct cache_req_data *data;
+
+ data = cache_req_data_enum(mem_ctx, CACHE_REQ_ENUM_SVC);
+ if (data == NULL) {
+ return NULL;
+ }
+
+ return cache_req_steal_data_and_send(mem_ctx, ev, rctx, ncache,
+ cache_refresh_percent, domain, data);
+}