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,
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina uid = ldb_msg_find_attr_as_string(msg, SYSDB_UIDNUM, NULL);
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina return sbus_opath_compose(mem_ctx, IFP_PATH_USERS, domain->name, uid);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březinastatic errno_t ifp_users_decompose_path(struct sss_domain_info *domains,
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);
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina ret = cache_req_user_by_name_recv(sbus_req, req, &result, &domain, NULL);
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 "
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina object_path = ifp_users_build_path_from_msg(sbus_req, 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);
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina ret = cache_req_user_by_id_recv(sbus_req, req, &result, &domain);
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 "
c747b0c875785ce693f70b50bdda0237c4b04e35Pavel Březina object_path = ifp_users_build_path_from_msg(sbus_req, 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);
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);
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bose ret = cache_req_user_by_cert_recv(sbus_req, req, &result, &domain, NULL);
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 "
827a016a07d5f911cc4195be89896a376fd71f59Sumit Bose object_path = ifp_users_build_path_from_msg(sbus_req, 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);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozekstatic int ifp_users_list_copy(struct ifp_list_ctx *list_ctx,
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek copy_count = ifp_list_ctx_remaining_capacity(list_ctx, result->count);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek for (i = 0; i < copy_count; i++) {
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek if (list_ctx->paths[list_ctx->path_count + i] == NULL) {
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);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek ret = cache_req_user_by_name_recv(sbus_req, req, &result, &domain, NULL);
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));
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek error = sbus_error_new(sbus_req, SBUS_ERROR_INTERNAL,
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub 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);
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek ret = cache_req_user_by_name_recv(sbus_req, req, &result, &domain, NULL);
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));
bdf32fbb3c947dd1b2c54d1c21d8028a1ddc80e6Jakub Hrozek copy_count = ifp_list_ctx_remaining_capacity(list_ctx, result->count);
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,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březinaifp_users_user_get(struct sbus_request *sbus_req,
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ret = ifp_users_decompose_path(ifp_ctx->rctx->domains, sbus_req->path,
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));
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ret = sysdb_getpwuid_with_views(sbus_req, domain, uid, &res);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to lookup user %u@%s [%d]: %s\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);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ret = ifp_users_user_get(sbus_req, ifp_ctx, NULL, &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);
d0faaf01fd24a935d9779032886d228b3861fa48Jakub Hrozek ret = ifp_users_user_get(sbus_req, ifp_ctx, NULL, &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);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ret = ifp_users_user_get(sbus_req, ifp_ctx, NULL, &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");
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ret = ifp_users_user_get(sbus_req, data, NULL, &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);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ret = cache_req_initgr_by_name_recv(sbus_req, req, NULL, NULL, 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",
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ret = ifp_users_user_get(sbus_req, ifp_ctx, NULL, &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],
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");
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");
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina ret = ifp_users_user_get(sbus_req, data, &uid, &domain, NULL);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina basedn = sysdb_user_base_dn(sbus_req, domain);
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "sysdb_user_base_dn() failed\n");
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina filter = talloc_asprintf(sbus_req, "(&(%s=%s)(%s=%u))",
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",
a1e4113a5388e34c08459c5b69679c82ac2bddc9Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "User %u not found!\n", uid);
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,
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina ret = ifp_users_user_get(sbus_req, data, NULL, &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,
d3c82d0170d6d7407549afdadd08aa7e11aeb9a2Pavel Březina ret = ifp_users_user_get(sbus_req, data, NULL, &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. */