d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina Pavel Březina <pbrezina@redhat.com>
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina Copyright (C) 2015 Red Hat
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina This program is free software; you can redistribute it and/or modify
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina it under the terms of the GNU General Public License as published by
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina the Free Software Foundation; either version 3 of the License, or
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina (at your option) any later version.
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina This program is distributed in the hope that it will be useful,
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina GNU General Public License for more details.
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina You should have received a copy of the GNU General Public License
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březinastatic struct ldb_dn *
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina base_dn = sysdb_user_base_dn(mem_ctx, domain);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina base_dn = sysdb_group_base_dn(mem_ctx, domain);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina path = ifp_users_build_path_from_msg(mem_ctx, domain, msg);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina path = ifp_groups_build_path_from_msg(mem_ctx, domain, msg);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březinastatic const char *
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březinaifp_cache_object_class(enum ifp_cache_type type)
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březinaifp_cache_get_cached_objects(TALLOC_CTX *mem_ctx,
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina const char ***_paths,
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina const char *class = ifp_cache_object_class(type);
0e238c259c066cf997aaa940d33d6bda96c15925Sumit Bose const char *attrs[] = {SYSDB_OBJECTCATEGORY, SYSDB_UIDNUM,
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina base_dn = ifp_cache_build_base_dn(tmp_ctx, type, domain);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to create base dn\n");
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina ldb_ret = ldb_search(sysdb_ctx_get_ldb(domain->sysdb), tmp_ctx, &result,
0e238c259c066cf997aaa940d33d6bda96c15925Sumit Bose "(&(%s=%s)(%s=TRUE))", SYSDB_OBJECTCATEGORY, class,
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to search the cache\n");
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina paths = talloc_zero_array(tmp_ctx, const char *, result->count + 1);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina paths[i] = ifp_cache_build_path(paths, type, domain, result->msgs[i]);
2b7ef850846029641cc59560c2d8d4ab7254dda5Pavel Březinaerrno_t ifp_cache_list_domains(TALLOC_CTX *mem_ctx,
2b7ef850846029641cc59560c2d8d4ab7254dda5Pavel Březina const char ***_paths,
2b7ef850846029641cc59560c2d8d4ab7254dda5Pavel Březina ret = ifp_cache_get_cached_objects(tmp_ctx, type, domain,
2b7ef850846029641cc59560c2d8d4ab7254dda5Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to build object list "
2b7ef850846029641cc59560c2d8d4ab7254dda5Pavel Březina ret = add_strings_lists(tmp_ctx, paths, tmp_paths, true,
2b7ef850846029641cc59560c2d8d4ab7254dda5Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to build object list "
877b92e80bde510d5cd9f03dbf01e2bcf73ab072Michal Židek domain = get_next_domain(domain, SSS_GND_DESCEND);
2b7ef850846029641cc59560c2d8d4ab7254dda5Pavel Březinaint ifp_cache_list(struct sbus_request *sbus_req,
2b7ef850846029641cc59560c2d8d4ab7254dda5Pavel Březina ifp_ctx = talloc_get_type(data, struct ifp_ctx);
2b7ef850846029641cc59560c2d8d4ab7254dda5Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
2b7ef850846029641cc59560c2d8d4ab7254dda5Pavel Březina ret = ifp_cache_list_domains(sbus_req, ifp_ctx->rctx->domains, type,
2b7ef850846029641cc59560c2d8d4ab7254dda5Pavel Březina error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED,
2b7ef850846029641cc59560c2d8d4ab7254dda5Pavel Březina "Unable to build object list [%d]: %s\n",
2b7ef850846029641cc59560c2d8d4ab7254dda5Pavel Březina return sbus_request_fail_and_finish(sbus_req, error);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina iface_ifp_cache_List_finish(sbus_req, paths, num_paths);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březinaint ifp_cache_list_by_domain(struct sbus_request *sbus_req,
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina ifp_ctx = talloc_get_type(data, struct ifp_ctx);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina domain = find_domain_by_name(ifp_ctx->rctx->domains, domainname, true);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED, "Unknown domain");
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina return sbus_request_fail_and_finish(sbus_req, error);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina ret = ifp_cache_get_cached_objects(sbus_req, type, domain,
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED, "Unable to build "
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina "object list [%d]: %s\n", ret, sss_strerror(ret));
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina return sbus_request_fail_and_finish(sbus_req, error);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina iface_ifp_cache_ListByDomain_finish(sbus_req, paths, num_paths);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březinastatic errno_t ifp_cache_object_set(struct sss_domain_info *domain,
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina ret = sysdb_attrs_add_bool(attrs, SYSDB_IFP_CACHED, value);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to add attribute [%d]: %s\n",
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina ret = sysdb_set_entry_attr(domain->sysdb, dn, attrs, SYSDB_MOD_REP);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to modify entry [%d]: %s\n",
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březinaint ifp_cache_object_store(struct sbus_request *sbus_req,
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina iface_ifp_cache_object_Store_finish(sbus_req, true);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina iface_ifp_cache_object_Store_finish(sbus_req, false);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březinaint ifp_cache_object_remove(struct sbus_request *sbus_req,
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina ret = ifp_cache_object_set(domain, dn, false);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina iface_ifp_cache_object_Remove_finish(sbus_req, true);