c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina Pavel Březina <pbrezina@redhat.com>
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina Copyright (C) 2015 Red Hat
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina This program is free software; you can redistribute it and/or modify
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina it under the terms of the GNU General Public License as published by
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina the Free Software Foundation; either version 3 of the License, or
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina (at your option) any later version.
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina This program is distributed in the hope that it will be useful,
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina GNU General Public License for more details.
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina You should have received a copy of the GNU General Public License
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel 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"
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březinachar * ifp_users_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_UIDNUM, NULL);
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek return sbus_opath_compose(mem_ctx, IFP_PATH_USERS, domain->name, key);
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozekstatic errno_t ifp_users_decompose_path(TALLOC_CTX *mem_ctx,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ret = sbus_opath_decompose_exact(NULL, path, IFP_PATH_USERS, 2, &parts);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina domain = find_domain_by_name(domains, parts[0], false);
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březinastatic void ifp_users_find_by_name_done(struct tevent_req *req);
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březinaint ifp_users_find_by_name(struct sbus_request *sbus_req,
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina req = cache_req_user_by_name_send(sbus_req, ctx->rctx->ev, ctx->rctx,
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina tevent_req_set_callback(req, ifp_users_find_by_name_done, sbus_req);
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březinaifp_users_find_by_name_done(struct tevent_req *req)
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina sbus_req = tevent_req_callback_data(req, struct sbus_request);
b206e1abb7f6ea373d12537b3338552aed6b656dPavel Březina ret = cache_req_user_by_name_recv(sbus_req, req, &result);
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina error = sbus_error_new(sbus_req, SBUS_ERROR_NOT_FOUND,
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina "User not found");
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED, "Failed to fetch "
b206e1abb7f6ea373d12537b3338552aed6b656dPavel Březina object_path = ifp_users_build_path_from_msg(sbus_req, result->domain,
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina "Failed to compose object path");
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina sbus_request_fail_and_finish(sbus_req, error);
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina iface_ifp_users_FindByName_finish(sbus_req, object_path);
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březinastatic void ifp_users_find_by_id_done(struct tevent_req *req);
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březinaint ifp_users_find_by_id(struct sbus_request *sbus_req,
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina req = cache_req_user_by_id_send(sbus_req, ctx->rctx->ev, ctx->rctx,
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina tevent_req_set_callback(req, ifp_users_find_by_id_done, sbus_req);
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březinaifp_users_find_by_id_done(struct tevent_req *req)
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina sbus_req = tevent_req_callback_data(req, struct sbus_request);
b206e1abb7f6ea373d12537b3338552aed6b656dPavel Březina ret = cache_req_user_by_id_recv(sbus_req, req, &result);
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina error = sbus_error_new(sbus_req, SBUS_ERROR_NOT_FOUND,
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina "User not found");
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED, "Failed to fetch "
b206e1abb7f6ea373d12537b3338552aed6b656dPavel Březina object_path = ifp_users_build_path_from_msg(sbus_req, result->domain,
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina "Failed to compose object path");
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina sbus_request_fail_and_finish(sbus_req, error);
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina iface_ifp_users_FindByID_finish(sbus_req, object_path);
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bosestatic void ifp_users_find_by_cert_done(struct tevent_req *req);
827a016a07d5f911cc4195be89896a376fd71f59Sumit Boseint ifp_users_find_by_cert(struct sbus_request *sbus_req, void *data,
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bose DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bose ret = sss_cert_pem_to_derb64(sbus_req, pem_cert, &derb64);
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bose DEBUG(SSSDBG_OP_FAILURE, "sss_cert_pem_to_derb64 failed.\n");
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bose error = sbus_error_new(sbus_req, DBUS_ERROR_INVALID_ARGS,
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bose "Invalid certificate format");
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bose /* the connection is already terminated with an error message, hence
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bose * we have to return EOK to not terminate the connection twice. */
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bose req = cache_req_user_by_cert_send(sbus_req, ctx->rctx->ev, ctx->rctx,
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bose tevent_req_set_callback(req, ifp_users_find_by_cert_done, sbus_req);
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose#define SBUS_ERROR_MORE_THAN_ONE "org.freedesktop.sssd.Error.MoreThanOne"
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bosestatic void ifp_users_find_by_cert_done(struct tevent_req *req)
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bose sbus_req = tevent_req_callback_data(req, struct sbus_request);
b206e1abb7f6ea373d12537b3338552aed6b656dPavel Březina ret = cache_req_user_by_cert_recv(sbus_req, req, &result);
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bose error = sbus_error_new(sbus_req, SBUS_ERROR_NOT_FOUND,
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bose "User not found");
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bose error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED, "Failed to fetch "
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose error = sbus_error_new(sbus_req, SBUS_ERROR_MORE_THAN_ONE,
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose "More than one user found. "
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose "Use ListByCertificate to get all.");
b206e1abb7f6ea373d12537b3338552aed6b656dPavel Březina object_path = ifp_users_build_path_from_msg(sbus_req, result->domain,
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bose error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bose "Failed to compose object path");
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bose iface_ifp_users_FindByCertificate_finish(sbus_req, object_path);
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bosestatic int ifp_users_list_by_cert_step(struct ifp_list_ctx *list_ctx);
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bosestatic void ifp_users_list_by_cert_done(struct tevent_req *req);
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bosestatic void ifp_users_list_by_name_reply(struct ifp_list_ctx *list_ctx);
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bosestatic int ifp_users_list_copy(struct ifp_list_ctx *list_ctx,
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Boseint ifp_users_list_by_cert(struct sbus_request *sbus_req, void *data,
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose ret = sss_cert_pem_to_derb64(sbus_req, pem_cert, &derb64);
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose DEBUG(SSSDBG_OP_FAILURE, "sss_cert_pem_to_derb64 failed.\n");
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose error = sbus_error_new(sbus_req, DBUS_ERROR_INVALID_ARGS,
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose "Invalid certificate format");
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose /* the connection is already terminated with an error message, hence
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose * we have to return EOK to not terminate the connection twice. */
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose list_ctx = ifp_list_ctx_new(sbus_req, ctx, derb64, limit);
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bosestatic int ifp_users_list_by_cert_step(struct ifp_list_ctx *list_ctx)
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose tevent_req_set_callback(req, ifp_users_list_by_cert_done, list_ctx);
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bosestatic void ifp_users_list_by_cert_done(struct tevent_req *req)
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose list_ctx = tevent_req_callback_data(req, struct ifp_list_ctx);
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose ret = cache_req_user_by_cert_recv(sbus_req, req, &result);
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED,
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose "Failed to fetch user [%d]: %s\n",
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose ret = ifp_users_list_copy(list_ctx, result->ldb_result);
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose "Failed to copy domain result");
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose list_ctx->dom = get_next_domain(list_ctx->dom, SSS_GND_DESCEND);
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
861dbe0794739a1c93a5bed00913c7442a2bdac9Sumit Bose "Failed to start next-domain search");
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekstatic int ifp_users_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 if (list_ctx->paths[list_ctx->path_count + i] == NULL) {
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bosestatic void ifp_users_find_by_name_and_cert_name_done(struct tevent_req *req);
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bosestatic void ifp_users_find_by_name_and_cert_done(struct tevent_req *req);
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bosestatic void ifp_users_find_by_name_and_cert_reply(
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Boseint ifp_users_find_by_name_and_cert(struct sbus_request *sbus_req, void *data,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose struct name_and_cert_ctx *name_and_cert_ctx = NULL;
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose error = sbus_error_new(sbus_req, DBUS_ERROR_INVALID_ARGS,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose "Missing input");
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose /* the connection is already terminated with an error message, hence
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose * we have to return EOK to not terminate the connection twice. */
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose name_and_cert_ctx = talloc_zero(sbus_req, struct name_and_cert_ctx);
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose name_and_cert_ctx->name = talloc_strdup(name_and_cert_ctx, name);
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose DEBUG(SSSDBG_OP_FAILURE, "talloc_strdup failed.\n");
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose ret = sss_cert_pem_to_derb64(name_and_cert_ctx, pem_cert,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose DEBUG(SSSDBG_OP_FAILURE, "sss_cert_pem_to_derb64 failed.\n");
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose error = sbus_error_new(sbus_req, DBUS_ERROR_INVALID_ARGS,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose "Invalid certificate format");
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose /* the connection is already terminated with an error message, hence
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose * we have to return EOK to not terminate the connection twice. */
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose /* FIXME: if unlimted searches with limit=0 will work please replace
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose * 100 with 0. */
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose name_and_cert_ctx->list_ctx = ifp_list_ctx_new(sbus_req, ctx,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose req = cache_req_user_by_name_send(sbus_req, ctx->rctx->ev, ctx->rctx,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose tevent_req_set_callback(req, ifp_users_find_by_name_and_cert_name_done,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose ret = ifp_users_find_by_name_and_cert_step(name_and_cert_ctx);
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bosestatic void ifp_users_find_by_name_and_cert_name_done(struct tevent_req *req)
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose struct name_and_cert_ctx *name_and_cert_ctx = NULL;
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose name_and_cert_ctx = tevent_req_callback_data(req, struct name_and_cert_ctx);
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose ret = cache_req_user_by_name_recv(name_and_cert_ctx, req, &result);
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose error = sbus_error_new(sbus_req, SBUS_ERROR_NOT_FOUND,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose "User not found");
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose "Failed to fetch user [%d]: %s\n",
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose name_and_cert_ctx->user_opath = ifp_users_build_path_from_msg(
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose "Failed to compose object path");
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose ret = ifp_users_find_by_name_and_cert_step(name_and_cert_ctx);
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose "Failed to fetch certificate [%d]: %s\n",
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose ifp_users_find_by_name_and_cert_reply(name_and_cert_ctx);
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose struct ifp_list_ctx *list_ctx = name_and_cert_ctx->list_ctx;
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose tevent_req_set_callback(req, ifp_users_find_by_name_and_cert_done,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bosestatic void ifp_users_find_by_name_and_cert_done(struct tevent_req *req)
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose name_and_cert_ctx = tevent_req_callback_data(req, struct name_and_cert_ctx);
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose ret = cache_req_user_by_cert_recv(name_and_cert_ctx, req, &result);
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose "Failed to fetch user [%d]: %s\n",
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose ret = ifp_users_list_copy(list_ctx, result->ldb_result);
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose "Failed to copy domain result");
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose list_ctx->dom = get_next_domain(list_ctx->dom, SSS_GND_DESCEND);
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose return ifp_users_find_by_name_and_cert_reply(name_and_cert_ctx);
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose ret = ifp_users_find_by_name_and_cert_step(name_and_cert_ctx);
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose "Failed to start next-domain search");
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bosestatic void ifp_users_find_by_name_and_cert_reply(
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose struct sbus_request *sbus_req = name_and_cert_ctx->sbus_req;
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose struct ifp_list_ctx *list_ctx = name_and_cert_ctx->list_ctx;
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose /* If no name was given check if there is only one user mapped to the
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose * certificate and return its object path. Either no or more than one
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose * mapped users are errors in this case.
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose * The case where a given name could not be found is already handled in
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose * ifp_users_find_by_name_and_cert_name_done(). */
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose if (list_ctx == NULL || list_ctx->path_count == 0) {
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose error = sbus_error_new(sbus_req, SBUS_ERROR_NOT_FOUND,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose "User not found");
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose iface_ifp_users_FindByNameAndCertificate_finish(sbus_req,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose error = sbus_error_new(sbus_req, SBUS_ERROR_MORE_THAN_ONE,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose "More than one user found. "
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose "Use ListByCertificate to get all.");
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose /* If there was no certficate given just return the object path of the
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose * user found by name. If a certificate was given an no mapped user was
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose * found return an error. */
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose if (list_ctx == NULL || list_ctx->path_count == 0) {
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose iface_ifp_users_FindByNameAndCertificate_finish(sbus_req,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose error = sbus_error_new(sbus_req, SBUS_ERROR_NOT_FOUND,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose "No user matching name and certificate "
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose /* Check if the user found by name is one of the users mapped to the
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose * certificate. */
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose if (strcmp(name_and_cert_ctx->user_opath, list_ctx->paths[c]) == 0) {
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose iface_ifp_users_FindByNameAndCertificate_finish(sbus_req,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose /* A user was found by name but the certificate is mapped to one or more
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose * different users. */
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose error = sbus_error_new(sbus_req, SBUS_ERROR_NOT_FOUND,
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose "No user matching name and certificate found");
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose /* name_and_cert_ctx is already freed because sbus_req (the parent) is
ef55b0e470a8fbcf6e6d0a55883145e02a907842Sumit Bose * already freed by the DBus finish calls */
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekstatic int ifp_users_list_by_name_step(struct ifp_list_ctx *list_ctx);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekstatic void ifp_users_list_by_name_done(struct tevent_req *req);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekstatic void ifp_users_list_by_name_reply(struct ifp_list_ctx *list_ctx);
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březinaint ifp_users_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_users_list_by_name_step(struct ifp_list_ctx *list_ctx)
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekstatic void ifp_users_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_user_by_name_recv(sbus_req, req, &result);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED, "Failed to fetch "
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek "users by filter [%d]: %s\n", ret, sss_strerror(ret));
b010f24f4d96d15c5c85021bb4aa83db25cd3df5Jakub Hrozek ret = ifp_users_list_copy(list_ctx, result->ldb_result);
b010f24f4d96d15c5c85021bb4aa83db25cd3df5Jakub Hrozek error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
b010f24f4d96d15c5c85021bb4aa83db25cd3df5Jakub Hrozek "Failed to copy domain result");
877b92e80bde510d5cd9f03dbf01e2bcf73ab072Michal Židek list_ctx->dom = get_next_domain(list_ctx->dom, SSS_GND_DESCEND);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek "Failed to start next-domain search");
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekstatic void ifp_users_list_by_name_reply(struct ifp_list_ctx *list_ctx)
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek iface_ifp_users_ListByName_finish(list_ctx->sbus_req,
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekstatic void ifp_users_list_by_domain_and_name_done(struct tevent_req *req);
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březinaint ifp_users_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_user_by_filter_send(list_ctx, ctx->rctx->ev, ctx->rctx,
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek ifp_users_list_by_domain_and_name_done, list_ctx);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekstatic void ifp_users_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 "users by filter [%d]: %s\n", ret, sss_strerror(ret));
5d855b5d546eb995023d80d61433bbe91888dbdfFabiano Fidêncio ret = ifp_list_ctx_remaining_capacity(list_ctx, result->count, ©_count);
5d855b5d546eb995023d80d61433bbe91888dbdfFabiano Fidêncio error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
5d855b5d546eb995023d80d61433bbe91888dbdfFabiano Fidêncio "Failed to get the list remaining capacity\n");
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek for (i = 0; i < copy_count; i++) {
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek list_ctx->paths[i] = ifp_users_build_path_from_msg(list_ctx->paths,
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek "Failed to compose object path");
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek iface_ifp_users_ListByDomainAndName_finish(sbus_req,
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozekifp_users_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_getpwuid_with_views(sbus_req, domain, uid, &user_res);
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "Unable to lookup user %u@%s [%d]: %s\n",
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = sysdb_getpwnam_with_views(sbus_req, domain, key, &user_res);
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "Unable to lookup user %s@%s [%d]: %s\n",
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "More users matched by the single key\n");
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březinaifp_users_user_get(struct sbus_request *sbus_req,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to decompose object path"
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina "[%s] [%d]: %s\n", sbus_req->path, ret, sss_strerror(ret));
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = ifp_users_get_from_cache(sbus_req, domain, key, _user);
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek DEBUG(SSSDBG_OP_FAILURE, "Unable to retrieve user from cache\n");
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březinastatic void ifp_users_get_as_string(struct sbus_request *sbus_req,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina const char **_out)
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ifp_ctx = talloc_get_type(data, struct ifp_ctx);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina if (!ifp_is_user_attr_allowed(ifp_ctx, attr)) {
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_TRACE_ALL, "Attribute %s is not allowed\n", attr);
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = ifp_users_user_get(sbus_req, ifp_ctx, &domain, &msg);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina *_out = sss_view_ldb_msg_find_attr_as_string(domain, msg, attr, NULL);
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozekstatic void ifp_users_get_name(struct sbus_request *sbus_req,
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek const char *attr,
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek const char **_out)
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek ifp_ctx = talloc_get_type(data, struct ifp_ctx);
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek if (!ifp_is_user_attr_allowed(ifp_ctx, attr)) {
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek DEBUG(SSSDBG_TRACE_ALL, "Attribute %s is not allowed\n", attr);
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = ifp_users_user_get(sbus_req, ifp_ctx, &domain, &msg);
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek in_name = sss_view_ldb_msg_find_attr_as_string(domain, msg, attr, NULL);
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek *_out = ifp_format_name_attr(sbus_req, ifp_ctx, in_name, domain);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březinastatic void ifp_users_get_as_uint32(struct sbus_request *sbus_req,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ifp_ctx = talloc_get_type(data, struct ifp_ctx);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina if (!ifp_is_user_attr_allowed(ifp_ctx, attr)) {
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_TRACE_ALL, "Attribute %s is not allowed\n", attr);
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = ifp_users_user_get(sbus_req, ifp_ctx, &domain, &msg);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina *_out = sss_view_ldb_msg_find_attr_as_uint64(domain, msg, attr, 0);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březinastatic void ifp_users_user_update_groups_list_done(struct tevent_req *req);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březinaint ifp_users_user_update_groups_list(struct sbus_request *sbus_req,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = ifp_users_user_get(sbus_req, data, &domain, &user);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina username = ldb_msg_find_attr_as_string(user, SYSDB_NAME, NULL);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "User name is empty!\n");
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina req = cache_req_initgr_by_name_send(sbus_req, ctx->rctx->ev, ctx->rctx,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina tevent_req_set_callback(req, ifp_users_user_update_groups_list_done,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březinastatic void ifp_users_user_update_groups_list_done(struct tevent_req *req)
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina sbus_req = tevent_req_callback_data(req, struct sbus_request);
b206e1abb7f6ea373d12537b3338552aed6b656dPavel Březina ret = cache_req_initgr_by_name_recv(sbus_req, req, NULL);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina error = sbus_error_new(sbus_req, SBUS_ERROR_NOT_FOUND,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina "User not found");
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina error = sbus_error_new(sbus_req, DBUS_ERROR_FAILED, "Failed to fetch "
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina sbus_request_fail_and_finish(sbus_req, error);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina iface_ifp_users_user_UpdateGroupsList_finish(sbus_req);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březinavoid ifp_users_user_get_name(struct sbus_request *sbus_req,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina const char **_out)
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek ifp_users_get_name(sbus_req, data, SYSDB_NAME, _out);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březinavoid ifp_users_user_get_uid_number(struct sbus_request *sbus_req,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ifp_users_get_as_uint32(sbus_req, data, SYSDB_UIDNUM, _out);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březinavoid ifp_users_user_get_gid_number(struct sbus_request *sbus_req,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ifp_users_get_as_uint32(sbus_req, data, SYSDB_GIDNUM, _out);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březinavoid ifp_users_user_get_gecos(struct sbus_request *sbus_req,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina const char **_out)
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ifp_users_get_as_string(sbus_req, data, SYSDB_GECOS, _out);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březinavoid ifp_users_user_get_home_directory(struct sbus_request *sbus_req,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina const char **_out)
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ifp_users_get_as_string(sbus_req, data, SYSDB_HOMEDIR, _out);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březinavoid ifp_users_user_get_login_shell(struct sbus_request *sbus_req,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina const char **_out)
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ifp_users_get_as_string(sbus_req, data, SYSDB_SHELL, _out);
e9a2e7afbd09c23dd8748246e09831ed7b17d7c5Thomas Equetervoid ifp_users_user_get_unique_id(struct sbus_request *sbus_req,
e9a2e7afbd09c23dd8748246e09831ed7b17d7c5Thomas Equeter const char **_out)
e9a2e7afbd09c23dd8748246e09831ed7b17d7c5Thomas Equeter ifp_users_get_as_string(sbus_req, data, SYSDB_UUID, _out);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březinavoid ifp_users_user_get_groups(struct sbus_request *sbus_req,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina const char ***_out,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ifp_ctx = talloc_get_type(data, struct ifp_ctx);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina if (!ifp_is_user_attr_allowed(ifp_ctx, "groups")) {
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_TRACE_ALL, "Attribute %s is not allowed\n",
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = ifp_users_user_get(sbus_req, ifp_ctx, &domain, &user);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina username = ldb_msg_find_attr_as_string(user, SYSDB_NAME, NULL);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "User name is empty!\n");
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina /* Run initgroups. */
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ret = sysdb_initgroups_with_views(sbus_req, domain, username, &res);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to get groups for %s@%s [%d]: %s\n",
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina username, domain->name, ret, sss_strerror(ret));
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina out = talloc_zero_array(sbus_req, const char *, res->count);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "talloc_zero_array() failed\n");
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina gid = sss_view_ldb_msg_find_attr_as_uint64(domain, res->msgs[i],
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek if (gid == 0 && domain->type == DOM_TYPE_POSIX) {
788146c3e3a564f333f39a2fcffccf3012cc2679Jakub Hrozek out[num_groups] = ifp_groups_build_path_from_msg(out,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "ifp_groups_build_path() failed\n");
37d2194cc9ea4d0254c88a3419e2376572562babPavel Březinavoid ifp_users_user_get_domain(struct sbus_request *sbus_req,
37d2194cc9ea4d0254c88a3419e2376572562babPavel Březina const char **_out)
37d2194cc9ea4d0254c88a3419e2376572562babPavel Březina ifp_users_user_get_domainname(sbus_req, data, &domainname);
37d2194cc9ea4d0254c88a3419e2376572562babPavel Březina *_out = sbus_opath_compose(sbus_req, IFP_PATH_DOMAINS,
37d2194cc9ea4d0254c88a3419e2376572562babPavel Březinavoid ifp_users_user_get_domainname(struct sbus_request *sbus_req,
37d2194cc9ea4d0254c88a3419e2376572562babPavel Březina const char **_out)
37d2194cc9ea4d0254c88a3419e2376572562babPavel Březina ifp_ctx = talloc_get_type(data, struct ifp_ctx);
37d2194cc9ea4d0254c88a3419e2376572562babPavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
37d2194cc9ea4d0254c88a3419e2376572562babPavel Březina if (!ifp_is_user_attr_allowed(ifp_ctx, "domainname")) {
37d2194cc9ea4d0254c88a3419e2376572562babPavel Březina DEBUG(SSSDBG_TRACE_ALL, "Attribute domainname is not allowed\n");
37d2194cc9ea4d0254c88a3419e2376572562babPavel Březina ret = ifp_users_user_get(sbus_req, ifp_ctx, &domain, NULL);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březinavoid ifp_users_user_get_extra_attributes(struct sbus_request *sbus_req,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ifp_ctx = talloc_get_type(data, struct ifp_ctx);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina extra = ifp_get_user_extra_attributes(sbus_req, ifp_ctx);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_TRACE_ALL, "No extra attributes to return\n");
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = ifp_users_user_get(sbus_req, data, &domain, &base_user);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina basedn = sysdb_user_base_dn(sbus_req, domain);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "sysdb_user_base_dn() failed\n");
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek name = ldb_msg_find_attr_as_string(base_user, SYSDB_NAME, NULL);
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "A user with no name\n");
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek filter = talloc_asprintf(sbus_req, "(&(%s=%s)(%s=%s))",
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "talloc_asprintf() failed\n");
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ret = sysdb_search_entry(sbus_req, domain->sysdb, basedn,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to lookup user [%d]: %s\n",
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek DEBUG(SSSDBG_TRACE_FUNC, "User %s not found!\n", name);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "More than one entry found!\n");
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to create hash table!\n");
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina /* Read each extra attribute. */
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_TRACE_ALL, "Attribute %s not found, skipping...\n",
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina values = sss_ldb_el_to_string_list(table, el);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "sss_ldb_el_to_string_list() failed\n");
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "talloc_strdup() failed\n");
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to insert entry "
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březinaint ifp_cache_list_user(struct sbus_request *sbus_req,
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina return ifp_cache_list(sbus_req, data, IFP_CACHE_USER);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březinaint ifp_cache_list_by_domain_user(struct sbus_request *sbus_req,
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina return ifp_cache_list_by_domain(sbus_req, data, domain, IFP_CACHE_USER);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březinaint ifp_cache_object_store_user(struct sbus_request *sbus_req,
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = ifp_users_user_get(sbus_req, data, &domain, &user);
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, user->dn);
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březinaint ifp_cache_object_remove_user(struct sbus_request *sbus_req,
35f0f5ff9dac790f6c947190fcdc00d01ae9077cJakub Hrozek ret = ifp_users_user_get(sbus_req, data, &domain, &user);
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. */