summaryrefslogtreecommitdiffstats
path: root/src/responder/ifp/ifp_cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/responder/ifp/ifp_cache.c')
-rw-r--r--src/responder/ifp/ifp_cache.c78
1 files changed, 58 insertions, 20 deletions
diff --git a/src/responder/ifp/ifp_cache.c b/src/responder/ifp/ifp_cache.c
index 35d51ab2c..9bf7ed7e7 100644
--- a/src/responder/ifp/ifp_cache.c
+++ b/src/responder/ifp/ifp_cache.c
@@ -149,45 +149,43 @@ done:
return ret;
}
-int ifp_cache_list(struct sbus_request *sbus_req,
- void *data,
- enum ifp_cache_type type)
+errno_t ifp_cache_list_domains(TALLOC_CTX *mem_ctx,
+ struct sss_domain_info *domains,
+ enum ifp_cache_type type,
+ const char ***_paths,
+ int *_num_paths)
{
- DBusError *error;
+ TALLOC_CTX *tmp_ctx;
struct sss_domain_info *domain;
- struct ifp_ctx *ifp_ctx;
const char **tmp_paths;
int num_tmp_paths;
const char **paths;
int num_paths;
errno_t ret;
- ifp_ctx = talloc_get_type(data, struct ifp_ctx);
- if (ifp_ctx == NULL) {
- DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
- return ERR_INTERNAL;
+ tmp_ctx = talloc_new(NULL);
+ if (tmp_ctx == NULL) {
+ return ENOMEM;
}
- domain = ifp_ctx->rctx->domains;
+ domain = domains;
num_paths = 0;
paths = NULL;
while (domain != NULL) {
- ret = ifp_cache_get_cached_objects(sbus_req, type, domain,
+ ret = ifp_cache_get_cached_objects(tmp_ctx, type, domain,
&tmp_paths, &num_tmp_paths);
if (ret != EOK) {
- error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED,
- "Unable to build object list [%d]: %s\n",
- ret, sss_strerror(ret));
- return sbus_request_fail_and_finish(sbus_req, error);
+ DEBUG(SSSDBG_CRIT_FAILURE, "Unable to build object list "
+ "[%d]: %s\n", ret, sss_strerror(ret));
+ goto done;
}
- ret = add_strings_lists(sbus_req, paths, tmp_paths, false,
+ ret = add_strings_lists(tmp_ctx, paths, tmp_paths, true,
discard_const(&paths));
if (ret != EOK) {
- error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED,
- "Unable to build object list [%d]: %s\n",
- ret, sss_strerror(ret));
- return sbus_request_fail_and_finish(sbus_req, error);
+ DEBUG(SSSDBG_CRIT_FAILURE, "Unable to build object list "
+ "[%d]: %s\n", ret, sss_strerror(ret));
+ goto done;
}
num_paths += num_tmp_paths;
@@ -195,6 +193,46 @@ int ifp_cache_list(struct sbus_request *sbus_req,
domain = get_next_domain(domain, true);
}
+ if (_paths != NULL) {
+ *_paths = talloc_steal(mem_ctx, paths);
+ }
+
+ if (_num_paths != NULL) {
+ *_num_paths = num_paths;
+ }
+
+ ret = EOK;
+
+done:
+ talloc_free(tmp_ctx);
+ return ret;
+}
+
+int ifp_cache_list(struct sbus_request *sbus_req,
+ void *data,
+ enum ifp_cache_type type)
+{
+ DBusError *error;
+ struct ifp_ctx *ifp_ctx;
+ const char **paths;
+ int num_paths;
+ errno_t ret;
+
+ ifp_ctx = talloc_get_type(data, struct ifp_ctx);
+ if (ifp_ctx == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
+ return ERR_INTERNAL;
+ }
+
+ ret = ifp_cache_list_domains(sbus_req, ifp_ctx->rctx->domains, type,
+ &paths, &num_paths);
+ if (ret != EOK) {
+ error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED,
+ "Unable to build object list [%d]: %s\n",
+ ret, sss_strerror(ret));
+ return sbus_request_fail_and_finish(sbus_req, error);
+ }
+
iface_ifp_cache_List_finish(sbus_req, paths, num_paths);
return EOK;