a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina Pavel Březina <pbrezina@redhat.com>
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina Copyright (C) 2015 Red Hat
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina This program is free software; you can redistribute it and/or modify
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina it under the terms of the GNU General Public License as published by
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina the Free Software Foundation; either version 3 of the License, or
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina (at your option) any later version.
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina This program is distributed in the hope that it will be useful,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina GNU General Public License for more details.
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina You should have received a copy of the GNU General Public License
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
4169fb26ea2ff93c19ecdad6e09382732ea5deebPavel Březina#include "responder/common/cache_req/cache_req.h"
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březinachar * ifp_groups_build_path_from_msg(TALLOC_CTX *mem_ctx,
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek key = ldb_msg_find_attr_as_string(msg, SYSDB_NAME, NULL);
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek key = ldb_msg_find_attr_as_string(msg, SYSDB_GIDNUM, NULL);
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek return sbus_opath_compose(mem_ctx, IFP_PATH_GROUPS, domain->name, key);
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozekstatic errno_t ifp_groups_decompose_path(TALLOC_CTX *mem_ctx,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina ret = sbus_opath_decompose_exact(NULL, path, IFP_PATH_GROUPS, 2, &parts);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina domain = find_domain_by_name(domains, parts[0], false);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekstatic int ifp_groups_list_copy(struct ifp_list_ctx *list_ctx,
5d855b5d546eb995023d80d61433bbe91888dbdfFabiano Fidêncio ret = ifp_list_ctx_remaining_capacity(list_ctx, result->count, ©_count);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek for (i = 0; i < copy_count; i++) {
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek ifp_groups_build_path_from_msg(list_ctx->paths,
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek if (list_ctx->paths[list_ctx->path_count + i] == NULL) {
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březinastatic void ifp_groups_find_by_name_done(struct tevent_req *req);
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březinaint ifp_groups_find_by_name(struct sbus_request *sbus_req,
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina req = cache_req_group_by_name_send(sbus_req, ctx->rctx->ev, ctx->rctx,
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina tevent_req_set_callback(req, ifp_groups_find_by_name_done, sbus_req);
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březinaifp_groups_find_by_name_done(struct tevent_req *req)
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina sbus_req = tevent_req_callback_data(req, struct sbus_request);
b206e1abb7f6ea373d12537b3338552aed6b656dPavel Březina ret = cache_req_group_by_name_recv(sbus_req, req, &result);
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina error = sbus_error_new(sbus_req, SBUS_ERROR_NOT_FOUND,
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina "Group not found");
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED, "Failed to fetch "
b206e1abb7f6ea373d12537b3338552aed6b656dPavel Březina object_path = ifp_groups_build_path_from_msg(sbus_req, result->domain,
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina "Failed to compose object path");
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina sbus_request_fail_and_finish(sbus_req, error);
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina iface_ifp_groups_FindByName_finish(sbus_req, object_path);
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březinastatic void ifp_groups_find_by_id_done(struct tevent_req *req);
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březinaint ifp_groups_find_by_id(struct sbus_request *sbus_req,
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina req = cache_req_group_by_id_send(sbus_req, ctx->rctx->ev, ctx->rctx,
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina tevent_req_set_callback(req, ifp_groups_find_by_id_done, sbus_req);
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březinaifp_groups_find_by_id_done(struct tevent_req *req)
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina sbus_req = tevent_req_callback_data(req, struct sbus_request);
b206e1abb7f6ea373d12537b3338552aed6b656dPavel Březina ret = cache_req_group_by_id_recv(sbus_req, req, &result);
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina error = sbus_error_new(sbus_req, SBUS_ERROR_NOT_FOUND,
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina "Group not found");
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED, "Failed to fetch "
b206e1abb7f6ea373d12537b3338552aed6b656dPavel Březina object_path = ifp_groups_build_path_from_msg(sbus_req, result->domain,
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina "Failed to compose object path");
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina sbus_request_fail_and_finish(sbus_req, error);
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březina iface_ifp_groups_FindByID_finish(sbus_req, object_path);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekstatic int ifp_groups_list_by_name_step(struct ifp_list_ctx *list_ctx);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekstatic void ifp_groups_list_by_name_done(struct tevent_req *req);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekstatic void ifp_groups_list_by_name_reply(struct ifp_list_ctx *list_ctx);
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březinaint ifp_groups_list_by_name(struct sbus_request *sbus_req,
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek list_ctx = ifp_list_ctx_new(sbus_req, ctx, filter, limit);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekstatic int ifp_groups_list_by_name_step(struct ifp_list_ctx *list_ctx)
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekstatic void ifp_groups_list_by_name_done(struct tevent_req *req)
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek list_ctx = tevent_req_callback_data(req, struct ifp_list_ctx);
b206e1abb7f6ea373d12537b3338552aed6b656dPavel Březina ret = cache_req_group_by_name_recv(sbus_req, req, &result);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED, "Failed to fetch "
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek "groups by filter [%d]: %s\n", ret, sss_strerror(ret));
5fe1e8ba91a1e2e95aadf94ecc5148bec804aa5aPetr Čech ret = ifp_groups_list_copy(list_ctx, result->ldb_result);
5fe1e8ba91a1e2e95aadf94ecc5148bec804aa5aPetr Čech error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
5fe1e8ba91a1e2e95aadf94ecc5148bec804aa5aPetr Čech "Failed to copy domain result");
877b92e80bde510d5cd9f03dbf01e2bcf73ab072Michal Židek list_ctx->dom = get_next_domain(list_ctx->dom, SSS_GND_DESCEND);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek return ifp_groups_list_by_name_reply(list_ctx);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek "Failed to start next-domain search");
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekstatic void ifp_groups_list_by_name_reply(struct ifp_list_ctx *list_ctx)
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek iface_ifp_groups_ListByDomainAndName_finish(list_ctx->sbus_req,
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekstatic void ifp_groups_list_by_domain_and_name_done(struct tevent_req *req);
132e477d69e07e02fe6e4d668c0bb6226206474aPavel Březinaint ifp_groups_list_by_domain_and_name(struct sbus_request *sbus_req,
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek list_ctx = ifp_list_ctx_new(sbus_req, ctx, filter, limit);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek req = cache_req_group_by_filter_send(list_ctx, ctx->rctx->ev, ctx->rctx,
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek ifp_groups_list_by_domain_and_name_done, list_ctx);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekstatic void ifp_groups_list_by_domain_and_name_done(struct tevent_req *req)
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek list_ctx = tevent_req_callback_data(req, struct ifp_list_ctx);
b206e1abb7f6ea373d12537b3338552aed6b656dPavel Březina ret = cache_req_user_by_name_recv(sbus_req, req, &result);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek error = sbus_error_new(sbus_req, SBUS_ERROR_NOT_FOUND,
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek "User not found by filter");
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED, "Failed to fetch "
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek "groups by filter [%d]: %s\n", ret, sss_strerror(ret));
5fe1e8ba91a1e2e95aadf94ecc5148bec804aa5aPetr Čech ret = ifp_groups_list_copy(list_ctx, result->ldb_result);
5fe1e8ba91a1e2e95aadf94ecc5148bec804aa5aPetr Čech error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
5fe1e8ba91a1e2e95aadf94ecc5148bec804aa5aPetr Čech "Failed to copy domain result");
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek iface_ifp_groups_ListByDomainAndName_finish(sbus_req,
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozekifp_groups_get_from_cache(struct sbus_request *sbus_req,
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek const char *key,
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "Invalid UID value\n");
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = sysdb_getgrgid_with_views(sbus_req, domain, gid, &group_res);
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "Unable to lookup group %u@%s [%d]: %s\n",
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = sysdb_getgrnam_with_views(sbus_req, domain, key, &group_res);
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "Unable to lookup group %s@%s [%d]: %s\n",
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "More groups matched by the single key\n");
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březinaifp_groups_group_get(struct sbus_request *sbus_req,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to decompose object path"
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina "[%s] [%d]: %s\n", sbus_req->path, ret, sss_strerror(ret));
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = ifp_groups_get_from_cache(sbus_req, domain, key, _group);
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek DEBUG(SSSDBG_OP_FAILURE, "Unable to retrieve group from cache\n");
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březinastatic void resolv_ghosts_group_done(struct tevent_req *subreq);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březinastatic errno_t resolv_ghosts_step(struct tevent_req *req);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březinastatic void resolv_ghosts_done(struct tevent_req *subreq);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březinastatic struct tevent_req *resolv_ghosts_send(TALLOC_CTX *mem_ctx,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina req = tevent_req_create(mem_ctx, &state, struct resolv_ghosts_state);
c02b8482375837b57cb618ed56d4bede0e006d9dPavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "tevent_req_create() failed\n");
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = ifp_groups_group_get(sbus_req, data, &domain, &group);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina name = ldb_msg_find_attr_as_string(group, SYSDB_NAME, NULL);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Group name is empty!\n");
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina subreq = cache_req_group_by_name_send(state, ev, ctx->rctx,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina tevent_req_set_callback(subreq, resolv_ghosts_group_done, req);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březinastatic void resolv_ghosts_group_done(struct tevent_req *subreq)
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina req = tevent_req_callback_data(subreq, struct tevent_req);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina state = tevent_req_data(req, struct resolv_ghosts_state);
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = ifp_groups_group_get(state->sbus_req, state->data,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina el = ldb_msg_find_element(group, SYSDB_GHOST);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina state->ghosts = sss_ldb_el_to_string_list(state, el);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březinaerrno_t resolv_ghosts_step(struct tevent_req *req)
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina state = tevent_req_data(req, struct resolv_ghosts_state);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina subreq = cache_req_user_by_name_send(state, state->ev, state->ctx->rctx,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina tevent_req_set_callback(subreq, resolv_ghosts_done, req);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březinastatic void resolv_ghosts_done(struct tevent_req *subreq)
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina req = tevent_req_callback_data(subreq, struct tevent_req);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina state = tevent_req_data(req, struct resolv_ghosts_state);
b206e1abb7f6ea373d12537b3338552aed6b656dPavel Březina ret = cache_req_user_by_name_recv(state, subreq, NULL);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březinastatic errno_t resolv_ghosts_recv(struct tevent_req *req)
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březinastatic void ifp_groups_group_update_member_list_done(struct tevent_req *req);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březinaint ifp_groups_group_update_member_list(struct sbus_request *sbus_req,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina subreq = resolv_ghosts_send(sbus_req, ctx->rctx->ev, sbus_req, data);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina tevent_req_set_callback(subreq, ifp_groups_group_update_member_list_done,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březinastatic void ifp_groups_group_update_member_list_done(struct tevent_req *subreq)
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina sbus_req = tevent_req_callback_data(subreq, struct sbus_request);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina "Unable to resolve ghost members [%d]: %s\n",
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina sbus_request_fail_and_finish(sbus_req, error);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina iface_ifp_groups_group_UpdateMemberList_finish(sbus_req);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březinavoid ifp_groups_group_get_name(struct sbus_request *sbus_req,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina const char **_out)
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek ifp_ctx = talloc_get_type(data, struct ifp_ctx);
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = ifp_groups_group_get(sbus_req, data, &domain, &msg);
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek in_name = sss_view_ldb_msg_find_attr_as_string(domain, msg,
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek *_out = ifp_format_name_attr(sbus_req, ifp_ctx, in_name, domain);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březinavoid ifp_groups_group_get_gid_number(struct sbus_request *sbus_req,
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = ifp_groups_group_get(sbus_req, data, &domain, &msg);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina *_out = sss_view_ldb_msg_find_attr_as_uint64(domain, msg, SYSDB_GIDNUM, 0);
e9a2e7afbd09c23dd8748246e09831ed7b17d7c5Thomas Equetervoid ifp_groups_group_get_unique_id(struct sbus_request *sbus_req,
e9a2e7afbd09c23dd8748246e09831ed7b17d7c5Thomas Equeter const char **_out)
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = ifp_groups_group_get(sbus_req, data, &domain, &msg);
e9a2e7afbd09c23dd8748246e09831ed7b17d7c5Thomas Equeter *_out = sss_view_ldb_msg_find_attr_as_string(domain, msg, SYSDB_UUID, 0);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březinaifp_groups_group_get_members(TALLOC_CTX *mem_ctx,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina const char ***_users,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina const char ***_groups,
0e238c259c066cf997aaa940d33d6bda96c15925Sumit Bose const char *attrs[] = {SYSDB_OBJECTCATEGORY, SYSDB_UIDNUM,
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = ifp_groups_group_get(sbus_req, data, &domain, &group);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina ret = sysdb_asq_search(tmp_ctx, domain, group->dn, NULL, SYSDB_MEMBER,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to perform ASQ search [%d]: %s\n",
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina users = talloc_zero_array(tmp_ctx, const char *, num_members + 1);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "talloc_zero_array() failed\n");
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina groups = talloc_zero_array(tmp_ctx, const char *, num_members + 1);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "talloc_zero_array() failed\n");
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina for (i = 0; i < num_members; i++) {
0e238c259c066cf997aaa940d33d6bda96c15925Sumit Bose class = ldb_msg_find_attr_as_string(members[i], SYSDB_OBJECTCATEGORY,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina users[num_users] = ifp_users_build_path_from_msg(users, domain,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina } else if (strcmp(class, SYSDB_GROUP_CLASS) == 0) {
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina groups[num_groups] = ifp_groups_build_path_from_msg(groups,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unexpected object class %s\n", class);
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březinavoid ifp_groups_group_get_users(struct sbus_request *sbus_req,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina const char ***_out,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina ret = ifp_groups_group_get_members(sbus_req, sbus_req, data, _out, _size,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to acquire groups members\n");
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březinavoid ifp_groups_group_get_groups(struct sbus_request *sbus_req,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina const char ***_out,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina ret = ifp_groups_group_get_members(sbus_req, sbus_req, data, NULL, NULL,
8fe171bf5a7a570591418e6548105f1d5a0097b3Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to acquire groups members\n");
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březinaint ifp_cache_list_group(struct sbus_request *sbus_req,
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina return ifp_cache_list(sbus_req, data, IFP_CACHE_GROUP);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březinaint ifp_cache_list_by_domain_group(struct sbus_request *sbus_req,
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina return ifp_cache_list_by_domain(sbus_req, data, domain, IFP_CACHE_GROUP);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březinaint ifp_cache_object_store_group(struct sbus_request *sbus_req,
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = ifp_groups_group_get(sbus_req, data, &domain, &group);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED, "Failed to fetch "
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina return sbus_request_fail_and_finish(sbus_req, error);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina /* The request is finished inside. */
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina return ifp_cache_object_store(sbus_req, domain, group->dn);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březinaint ifp_cache_object_remove_group(struct sbus_request *sbus_req,
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = ifp_groups_group_get(sbus_req, data, &domain, &group);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED, "Failed to fetch "
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina return sbus_request_fail_and_finish(sbus_req, error);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina /* The request is finished inside. */