LCOV - code coverage report
Current view: top level - responder/ifp - ifpsrv_cmd.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 264 0.0 %
Date: 2016-06-29 Functions: 0 14 0.0 %

          Line data    Source code
       1             : /*
       2             :     Authors:
       3             :         Jakub Hrozek <jhrozek@redhat.com>
       4             : 
       5             :     Copyright (C) 2013 Red Hat
       6             : 
       7             :     InfoPipe responder: the responder commands
       8             : 
       9             :     This program is free software; you can redistribute it and/or modify
      10             :     it under the terms of the GNU General Public License as published by
      11             :     the Free Software Foundation; either version 3 of the License, or
      12             :     (at your option) any later version.
      13             : 
      14             :     This program is distributed in the hope that it will be useful,
      15             :     but WITHOUT ANY WARRANTY; without even the implied warranty of
      16             :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17             :     GNU General Public License for more details.
      18             : 
      19             :     You should have received a copy of the GNU General Public License
      20             :     along with this program.  If not, see <http://www.gnu.org/licenses/>.
      21             : */
      22             : 
      23             : #include "db/sysdb.h"
      24             : 
      25             : #include "responder/ifp/ifp_private.h"
      26             : #include "responder/common/responder_cache_req.h"
      27             : 
      28             : struct ifp_attr_req {
      29             :     const char *name;
      30             :     const char **attrs;
      31             :     int nattrs;
      32             : 
      33             :     struct ifp_req *ireq;
      34             : };
      35             : 
      36             : static struct tevent_req *
      37             : ifp_user_get_attr_send(TALLOC_CTX *mem_ctx, struct resp_ctx *rctx,
      38             :                        struct sss_nc_ctx *ncache,
      39             :                        enum sss_dp_acct_type search_type,
      40             :                        const char *inp, const char **attrs);
      41             : static errno_t ifp_user_get_attr_recv(TALLOC_CTX *mem_ctx,
      42             :                                       struct tevent_req *req,
      43             :                                       struct ldb_result **_res,
      44             :                                       struct sss_domain_info **_domain);
      45             : 
      46             : static void ifp_user_get_attr_process(struct tevent_req *req);
      47             : 
      48             : static errno_t
      49             : ifp_user_get_attr_handle_reply(struct sss_domain_info *domain,
      50             :                                struct ifp_req *ireq,
      51             :                                const char **attrs,
      52             :                                struct ldb_result *res);
      53             : static errno_t
      54             : ifp_user_get_attr_unpack_msg(struct ifp_attr_req *attr_req);
      55             : 
      56           0 : int ifp_user_get_attr(struct sbus_request *dbus_req, void *data)
      57             : {
      58             :     errno_t ret;
      59             :     struct ifp_req *ireq;
      60             :     struct ifp_ctx *ifp_ctx;
      61             :     struct ifp_attr_req *attr_req;
      62             :     struct tevent_req *req;
      63             : 
      64           0 :     DEBUG(SSSDBG_IMPORTANT_INFO, "GetUserAttr is deprecated, please consider "
      65             :           "switching to org.freedesktop.sssd.infopipe.Users.User interface\n");
      66             : 
      67           0 :     ifp_ctx = talloc_get_type(data, struct ifp_ctx);
      68           0 :     if (ifp_ctx == NULL) {
      69           0 :         DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
      70           0 :         return sbus_request_return_and_finish(dbus_req, DBUS_TYPE_INVALID);
      71             :     }
      72             : 
      73           0 :     ret = ifp_req_create(dbus_req, ifp_ctx, &ireq);
      74           0 :     if (ret != EOK) {
      75           0 :         return ifp_req_create_handle_failure(dbus_req, ret);
      76             :     }
      77             : 
      78           0 :     attr_req = talloc_zero(ireq, struct ifp_attr_req);
      79           0 :     if (attr_req == NULL) {
      80           0 :         return sbus_request_finish(dbus_req, NULL);
      81             :     }
      82           0 :     attr_req->ireq = ireq;
      83             : 
      84           0 :     ret = ifp_user_get_attr_unpack_msg(attr_req);
      85           0 :     if (ret != EOK) {
      86           0 :         return ret;     /* internal error */
      87             :     }
      88             : 
      89           0 :     DEBUG(SSSDBG_FUNC_DATA,
      90             :           "Looking up attributes of user [%s] on behalf of %"PRIi64"\n",
      91             :           attr_req->name, ireq->dbus_req->client);
      92             : 
      93           0 :     req = ifp_user_get_attr_send(ireq, ifp_ctx->rctx,
      94           0 :                                  ifp_ctx->rctx->ncache, SSS_DP_USER,
      95             :                                  attr_req->name, attr_req->attrs);
      96           0 :     if (req == NULL) {
      97           0 :         return sbus_request_finish(dbus_req, NULL);
      98             :     }
      99           0 :     tevent_req_set_callback(req, ifp_user_get_attr_process, attr_req);
     100           0 :     return EOK;
     101             : }
     102             : 
     103             : static errno_t
     104           0 : ifp_user_get_attr_unpack_msg(struct ifp_attr_req *attr_req)
     105             : {
     106             :     bool parsed;
     107             :     char **attrs;
     108             :     int nattrs;
     109             :     int i, ai;
     110           0 :     const char **whitelist = attr_req->ireq->ifp_ctx->user_whitelist;
     111             : 
     112           0 :     parsed = sbus_request_parse_or_finish(attr_req->ireq->dbus_req,
     113             :                                           DBUS_TYPE_STRING, &attr_req->name,
     114             :                                           DBUS_TYPE_ARRAY, DBUS_TYPE_STRING,
     115             :                                           &attrs, &nattrs,
     116             :                                           DBUS_TYPE_INVALID);
     117           0 :     if (parsed == false) {
     118           0 :         DEBUG(SSSDBG_OP_FAILURE, "Could not parse arguments\n");
     119           0 :         return ERR_SBUS_REQUEST_HANDLED;
     120             :     }
     121             : 
     122             :     /* Copy the attributes to maintain memory hierarchy with talloc */
     123           0 :     attr_req->attrs = talloc_zero_array(attr_req, const char *, nattrs+1);
     124           0 :     if (attr_req->attrs == NULL) {
     125           0 :         return ENOMEM;
     126             :     }
     127             : 
     128           0 :     ai = 0;
     129           0 :     for (i = 0; i < nattrs; i++) {
     130           0 :         if (ifp_attr_allowed(whitelist, attrs[i]) == false) {
     131           0 :             DEBUG(SSSDBG_MINOR_FAILURE,
     132             :                   "Attribute %s not present in the whitelist, skipping\n",
     133             :                   attrs[i]);
     134           0 :             continue;
     135             :         }
     136             : 
     137           0 :         attr_req->attrs[ai] = talloc_strdup(attr_req->attrs, attrs[i]);
     138           0 :         if (attr_req->attrs[ai] == NULL) {
     139           0 :             return ENOMEM;
     140             :         }
     141           0 :         ai++;
     142             :     }
     143             : 
     144           0 :     return EOK;
     145             : }
     146             : 
     147           0 : static void ifp_user_get_attr_process(struct tevent_req *req)
     148             : {
     149             :     struct ifp_attr_req *attr_req;
     150             :     errno_t ret;
     151           0 :     struct ldb_result *res = NULL;
     152           0 :     struct sss_domain_info *dom = NULL;
     153             : 
     154           0 :     attr_req = tevent_req_callback_data(req, struct ifp_attr_req);
     155             : 
     156           0 :     ret = ifp_user_get_attr_recv(attr_req, req, &res, &dom);
     157           0 :     talloc_zfree(req);
     158           0 :     if (ret == ENOENT) {
     159           0 :         sbus_request_fail_and_finish(attr_req->ireq->dbus_req,
     160           0 :                                sbus_error_new(attr_req->ireq->dbus_req,
     161             :                                               DBUS_ERROR_FAILED,
     162             :                                               "No such user\n"));
     163           0 :         return;
     164           0 :     } else if (ret != EOK) {
     165           0 :         sbus_request_fail_and_finish(attr_req->ireq->dbus_req,
     166           0 :                                sbus_error_new(attr_req->ireq->dbus_req,
     167             :                                               DBUS_ERROR_FAILED,
     168             :                                               "Failed to read user attribute\n"));
     169           0 :         return;
     170             :     }
     171             : 
     172           0 :     ret = ifp_user_get_attr_handle_reply(dom, attr_req->ireq,
     173             :                                          attr_req->attrs, res);
     174           0 :     if (ret != EOK) {
     175           0 :         sbus_request_fail_and_finish(attr_req->ireq->dbus_req,
     176           0 :                                sbus_error_new(attr_req->ireq->dbus_req,
     177             :                                               DBUS_ERROR_FAILED,
     178             :                                               "Failed to build a reply\n"));
     179           0 :         return;
     180             :     }
     181             : }
     182             : 
     183             : static errno_t
     184           0 : ifp_user_get_attr_replace_space(TALLOC_CTX *mem_ctx,
     185             :                                 struct ldb_message_element *el,
     186             :                                 const char sub)
     187             : {
     188             :     int i;
     189             : 
     190           0 :     for (i = 0; i < el->num_values; i++) {
     191           0 :         el->values[i].data = (uint8_t *) sss_replace_space(mem_ctx,
     192           0 :                                              (const char *) el->values[i].data,
     193             :                                              sub);
     194           0 :         if (el->values[i].data == NULL) {
     195           0 :             DEBUG(SSSDBG_CRIT_FAILURE, "sss_replace_space failed, skipping\n");
     196           0 :             return ENOMEM;
     197             :         }
     198             :     }
     199             : 
     200           0 :     return EOK;
     201             : }
     202             : 
     203             : static errno_t
     204           0 : ifp_user_get_attr_handle_reply(struct sss_domain_info *domain,
     205             :                                struct ifp_req *ireq,
     206             :                                const char **attrs,
     207             :                                struct ldb_result *res)
     208             : {
     209             :     errno_t ret;
     210             :     dbus_bool_t dbret;
     211             :     DBusMessage *reply;
     212             :     DBusMessageIter iter;
     213             :     DBusMessageIter iter_dict;
     214             :     struct ldb_message_element *el;
     215             :     int ai;
     216             : 
     217             :     /* Construct a reply */
     218           0 :     reply = dbus_message_new_method_return(ireq->dbus_req->message);
     219           0 :     if (!reply) {
     220           0 :         return sbus_request_finish(ireq->dbus_req, NULL);
     221             :     }
     222             : 
     223           0 :     dbus_message_iter_init_append(reply, &iter);
     224             : 
     225           0 :     dbret = dbus_message_iter_open_container(
     226             :                                       &iter, DBUS_TYPE_ARRAY,
     227             :                                       DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
     228             :                                       DBUS_TYPE_STRING_AS_STRING
     229             :                                       DBUS_TYPE_VARIANT_AS_STRING
     230             :                                       DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
     231             :                                       &iter_dict);
     232           0 :     if (!dbret) {
     233           0 :         return sbus_request_finish(ireq->dbus_req, NULL);
     234             :     }
     235             : 
     236           0 :     if (res->count > 0) {
     237           0 :         for (ai = 0; attrs[ai]; ai++) {
     238           0 :             el = sss_view_ldb_msg_find_element(domain, res->msgs[0], attrs[ai]);
     239           0 :             if (el == NULL || el->num_values == 0) {
     240           0 :                 DEBUG(SSSDBG_MINOR_FAILURE,
     241             :                       "Attribute %s not present or has no values\n",
     242             :                       attrs[ai]);
     243           0 :                 continue;
     244             :             }
     245             : 
     246             :             /* Normalize white space in user names */
     247           0 :             if (ireq->ifp_ctx->rctx->override_space != '\0' &&
     248           0 :                     strcmp(attrs[ai], SYSDB_NAME) == 0) {
     249           0 :                 ret = ifp_user_get_attr_replace_space(ireq, el,
     250           0 :                                         ireq->ifp_ctx->rctx->override_space);
     251           0 :                 if (ret != EOK) {
     252           0 :                     DEBUG(SSSDBG_MINOR_FAILURE, "Cannot normalize %s\n",
     253             :                           attrs[ai]);
     254           0 :                     continue;
     255             :                 }
     256             :             }
     257             : 
     258           0 :             ret = ifp_add_ldb_el_to_dict(&iter_dict, el);
     259           0 :             if (ret != EOK) {
     260           0 :                 DEBUG(SSSDBG_MINOR_FAILURE,
     261             :                       "Cannot add attribute %s to message\n",
     262             :                       attrs[ai]);
     263           0 :                 continue;
     264             :             }
     265             :         }
     266             :     }
     267             : 
     268           0 :     dbret = dbus_message_iter_close_container(&iter, &iter_dict);
     269           0 :     if (!dbret) {
     270           0 :         return sbus_request_finish(ireq->dbus_req, NULL);
     271             :     }
     272             : 
     273           0 :     return sbus_request_finish(ireq->dbus_req, reply);
     274             : }
     275             : 
     276             : static void ifp_user_get_groups_process(struct tevent_req *req);
     277             : static errno_t ifp_user_get_groups_reply(struct sss_domain_info *domain,
     278             :                                          struct ifp_req *ireq,
     279             :                                          struct ldb_result *res);
     280             : 
     281           0 : int ifp_user_get_groups(struct sbus_request *dbus_req,
     282             :                          void *data, const char *arg_user)
     283             : {
     284             :     struct ifp_req *ireq;
     285             :     struct ifp_ctx *ifp_ctx;
     286             :     struct ifp_attr_req *group_req;
     287             :     struct tevent_req *req;
     288             :     errno_t ret;
     289             : 
     290           0 :     ifp_ctx = talloc_get_type(data, struct ifp_ctx);
     291           0 :     if (ifp_ctx == NULL) {
     292           0 :         DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
     293           0 :         return sbus_request_return_and_finish(dbus_req, DBUS_TYPE_INVALID);
     294             :     }
     295             : 
     296           0 :     ret = ifp_req_create(dbus_req, ifp_ctx, &ireq);
     297           0 :     if (ret != EOK) {
     298           0 :         return ifp_req_create_handle_failure(dbus_req, ret);
     299             :     }
     300             : 
     301           0 :     group_req = talloc_zero(ireq, struct ifp_attr_req);
     302           0 :     if (group_req == NULL) {
     303           0 :         return sbus_request_finish(dbus_req, NULL);
     304             :     }
     305           0 :     group_req->ireq = ireq;
     306           0 :     group_req->name = arg_user;
     307             : 
     308           0 :     group_req->attrs = talloc_zero_array(group_req, const char *, 2);
     309           0 :     if (group_req->attrs == NULL) {
     310           0 :         return sbus_request_finish(dbus_req, NULL);
     311             :     }
     312             : 
     313           0 :     group_req->attrs[0] = talloc_strdup(group_req->attrs, SYSDB_MEMBEROF);
     314           0 :     if (group_req->attrs[0] == NULL) {
     315           0 :         return sbus_request_finish(dbus_req, NULL);
     316             :     }
     317             : 
     318           0 :     DEBUG(SSSDBG_FUNC_DATA,
     319             :           "Looking up groups of user [%s] on behalf of %"PRIi64"\n",
     320             :           group_req->name, group_req->ireq->dbus_req->client);
     321             : 
     322           0 :     req = ifp_user_get_attr_send(ireq, ifp_ctx->rctx,
     323           0 :                                  ifp_ctx->rctx->ncache, SSS_DP_INITGROUPS,
     324             :                                  group_req->name, group_req->attrs);
     325           0 :     if (req == NULL) {
     326           0 :         return sbus_request_finish(dbus_req, NULL);
     327             :     }
     328           0 :     tevent_req_set_callback(req, ifp_user_get_groups_process, group_req);
     329           0 :     return EOK;
     330             : }
     331             : 
     332           0 : static void ifp_user_get_groups_process(struct tevent_req *req)
     333             : {
     334             :     struct ifp_attr_req *group_req;
     335             :     errno_t ret;
     336             :     struct ldb_result *res;
     337             :     struct sss_domain_info *dom;
     338             : 
     339           0 :     group_req = tevent_req_callback_data(req, struct ifp_attr_req);
     340             : 
     341           0 :     ret = ifp_user_get_attr_recv(group_req, req, &res, &dom);
     342           0 :     talloc_zfree(req);
     343           0 :     if (ret == ENOENT) {
     344           0 :         sbus_request_fail_and_finish(group_req->ireq->dbus_req,
     345           0 :                                sbus_error_new(group_req->ireq->dbus_req,
     346             :                                               DBUS_ERROR_FAILED,
     347             :                                               "No such user\n"));
     348           0 :         return;
     349           0 :     } else if (ret != EOK) {
     350           0 :         sbus_request_fail_and_finish(group_req->ireq->dbus_req,
     351           0 :                                sbus_error_new(group_req->ireq->dbus_req,
     352             :                                               DBUS_ERROR_FAILED,
     353             :                                               "Failed to read attribute\n"));
     354           0 :         return;
     355             :     }
     356             : 
     357           0 :     ret = ifp_user_get_groups_reply(dom, group_req->ireq, res);
     358           0 :     if (ret != EOK) {
     359           0 :         sbus_request_fail_and_finish(group_req->ireq->dbus_req,
     360           0 :                                sbus_error_new(group_req->ireq->dbus_req,
     361             :                                               DBUS_ERROR_FAILED,
     362             :                                               "Failed to build a reply\n"));
     363           0 :         return;
     364             :     }
     365             : }
     366             : 
     367             : static errno_t
     368           0 : ifp_user_get_groups_reply(struct sss_domain_info *domain,
     369             :                           struct ifp_req *ireq,
     370             :                           struct ldb_result *res)
     371             : {
     372             :     int i, num;
     373             :     const char *name;
     374             :     const char **groupnames;
     375             :     const char *tmpstr;
     376             : 
     377             :     /* one less, the first one is the user entry */
     378           0 :     num = res->count - 1;
     379           0 :     groupnames = talloc_zero_array(ireq, const char *, num);
     380           0 :     if (groupnames == NULL) {
     381           0 :         return sbus_request_finish(ireq->dbus_req, NULL);
     382             :     }
     383             : 
     384           0 :     for (i = 0; i < num; i++) {
     385           0 :         name = sss_view_ldb_msg_find_attr_as_string(domain,
     386           0 :                                                     res->msgs[i + 1],
     387             :                                                     SYSDB_NAME, NULL);
     388           0 :         if (name == NULL) {
     389           0 :             DEBUG(SSSDBG_MINOR_FAILURE, "Skipping a group with no name\n");
     390           0 :             continue;
     391             :         }
     392             : 
     393           0 :         if (ireq->ifp_ctx->rctx->override_space != '\0') {
     394           0 :             tmpstr = sss_replace_space(ireq, name,
     395           0 :                                        ireq->ifp_ctx->rctx->override_space);
     396           0 :             if (tmpstr == NULL) {
     397           0 :                 DEBUG(SSSDBG_MINOR_FAILURE, "Cannot normalize %s\n", name);
     398           0 :                 continue;
     399             :             }
     400             :         } else {
     401           0 :             tmpstr = name;
     402             :         }
     403             : 
     404           0 :         groupnames[i] = sss_get_cased_name(groupnames, tmpstr,
     405           0 :                                            domain->case_preserve);
     406           0 :         if (groupnames[i] == NULL) {
     407           0 :             DEBUG(SSSDBG_CRIT_FAILURE,
     408             :                   "sss_get_cased_name failed, skipping\n");
     409           0 :             continue;
     410             :         }
     411             : 
     412           0 :         DEBUG(SSSDBG_TRACE_FUNC, "Adding group %s\n", groupnames[i]);
     413             :     }
     414             : 
     415           0 :     return iface_ifp_GetUserGroups_finish(ireq->dbus_req, groupnames, num);
     416             : }
     417             : 
     418             : struct ifp_user_get_attr_state {
     419             :     const char *inp;
     420             :     const char **attrs;
     421             :     struct ldb_result *res;
     422             : 
     423             :     enum sss_dp_acct_type search_type;
     424             : 
     425             :     char *name;
     426             :     char *domname;
     427             : 
     428             :     struct sss_domain_info *dom;
     429             :     bool check_next;
     430             :     bool check_provider;
     431             : 
     432             :     struct resp_ctx *rctx;
     433             :     struct sss_nc_ctx *ncache;
     434             : };
     435             : 
     436             : static void ifp_user_get_attr_lookup(struct tevent_req *subreq);
     437             : static void ifp_user_get_attr_done(struct tevent_req *subreq);
     438             : 
     439             : static struct tevent_req *
     440           0 : ifp_user_get_attr_send(TALLOC_CTX *mem_ctx, struct resp_ctx *rctx,
     441             :                        struct sss_nc_ctx *ncache,
     442             :                        enum sss_dp_acct_type search_type,
     443             :                        const char *inp, const char **attrs)
     444             : {
     445             :     errno_t ret;
     446             :     struct tevent_req *req;
     447             :     struct tevent_req *subreq;
     448             :     struct ifp_user_get_attr_state *state;
     449             : 
     450           0 :     req = tevent_req_create(mem_ctx, &state, struct ifp_user_get_attr_state);
     451           0 :     if (req == NULL) {
     452           0 :          return NULL;
     453             :     }
     454           0 :     state->inp = inp;
     455           0 :     state->attrs = attrs;
     456           0 :     state->rctx = rctx;
     457           0 :     state->ncache = ncache;
     458           0 :     state->search_type = search_type;
     459             : 
     460           0 :     subreq = sss_parse_inp_send(req, rctx, inp);
     461           0 :     if (subreq == NULL) {
     462           0 :         ret = ENOMEM;
     463           0 :         goto done;
     464             :     }
     465           0 :     tevent_req_set_callback(subreq, ifp_user_get_attr_lookup, req);
     466             : 
     467           0 :     ret = EOK;
     468             : done:
     469           0 :     if (ret != EOK) {
     470           0 :         tevent_req_error(req, ret);
     471             :     }
     472           0 :     return req;
     473             : }
     474             : 
     475             : static void
     476           0 : ifp_user_get_attr_lookup(struct tevent_req *subreq)
     477             : {
     478           0 :     struct ifp_user_get_attr_state *state = NULL;
     479           0 :     struct tevent_req *req = NULL;
     480             :     struct cache_req_data *data;
     481             :     errno_t ret;
     482             : 
     483           0 :     req = tevent_req_callback_data(subreq, struct tevent_req);
     484           0 :     state = tevent_req_data(req, struct ifp_user_get_attr_state);
     485             : 
     486           0 :     ret = sss_parse_inp_recv(subreq, state, &state->name, &state->domname);
     487           0 :     talloc_zfree(subreq);
     488           0 :     if (ret != EOK) {
     489           0 :         tevent_req_error(req, ret);
     490           0 :         return;
     491             :     }
     492             : 
     493           0 :     switch (state->search_type) {
     494             :     case SSS_DP_USER:
     495           0 :         data = cache_req_data_name(state, CACHE_REQ_USER_BY_NAME, state->name);
     496           0 :         break;
     497             :     case SSS_DP_INITGROUPS:
     498           0 :         data = cache_req_data_name(state, CACHE_REQ_INITGROUPS, state->name);
     499           0 :         break;
     500             :     default:
     501           0 :         DEBUG(SSSDBG_CRIT_FAILURE, "Unsupported search type [%d]!\n",
     502             :               state->search_type);
     503           0 :         tevent_req_error(req, ERR_INTERNAL);
     504           0 :         return;
     505             :     }
     506             : 
     507           0 :     if (data == NULL) {
     508           0 :         tevent_req_error(req, ENOMEM);
     509           0 :         return;
     510             :     }
     511             : 
     512           0 :     subreq = cache_req_send(state, state->rctx->ev, state->rctx,
     513           0 :                             state->ncache, 0, state->domname, data);
     514           0 :     if (subreq == NULL) {
     515           0 :         tevent_req_error(req, ENOMEM);
     516           0 :         return;
     517             :     }
     518             : 
     519           0 :     tevent_req_set_callback(subreq, ifp_user_get_attr_done, req);
     520             : }
     521             : 
     522           0 : static void ifp_user_get_attr_done(struct tevent_req *subreq)
     523             : {
     524           0 :     struct ifp_user_get_attr_state *state = NULL;
     525           0 :     struct tevent_req *req = NULL;
     526             :     errno_t ret;
     527             : 
     528           0 :     req = tevent_req_callback_data(subreq, struct tevent_req);
     529           0 :     state = tevent_req_data(req, struct ifp_user_get_attr_state);
     530             : 
     531           0 :     ret = cache_req_recv(state, subreq, &state->res, &state->dom,  NULL);
     532           0 :     talloc_zfree(subreq);
     533           0 :     if (ret != EOK) {
     534           0 :         tevent_req_error(req, ret);
     535           0 :         return;
     536             :     }
     537             : 
     538           0 :     if (state->search_type == SSS_DP_USER) {
     539             :         /* throw away the result and perform attr search */
     540           0 :         talloc_zfree(state->res);
     541             : 
     542           0 :         ret = sysdb_get_user_attr_with_views(state, state->dom, state->name,
     543             :                                              state->attrs, &state->res);
     544           0 :         if (ret != EOK) {
     545           0 :             DEBUG(SSSDBG_CRIT_FAILURE, "sysdb_get_user_attr_with_views() "
     546             :                   "failed [%d]: %s\n", ret, sss_strerror(ret));
     547           0 :             tevent_req_error(req, ret);
     548           0 :             return;
     549           0 :         } else if (state->res->count == 0) {
     550           0 :             tevent_req_error(req, ENOENT);
     551           0 :             return;
     552           0 :         } else if (state->res->count != 1) {
     553           0 :             DEBUG(SSSDBG_CRIT_FAILURE, "sysdb_get_user_attr_with_views() "
     554             :                   "returned more than one result!\n");
     555           0 :             tevent_req_error(req, ENOENT);
     556           0 :             return;
     557             :         }
     558             :     }
     559             : 
     560           0 :     tevent_req_done(req);
     561             : }
     562             : 
     563             : static errno_t
     564           0 : ifp_user_get_attr_recv(TALLOC_CTX *mem_ctx,
     565             :                        struct tevent_req *req,
     566             :                        struct ldb_result **_res,
     567             :                        struct sss_domain_info **_domain)
     568             : {
     569           0 :     struct ifp_user_get_attr_state *state = tevent_req_data(req,
     570             :                                             struct ifp_user_get_attr_state);
     571             : 
     572           0 :     TEVENT_REQ_RETURN_ON_ERROR(req);
     573             : 
     574           0 :     if (state->res == NULL) {
     575             :         /* Did the request end with success but with no data? */
     576           0 :         return ENOENT;
     577             :     }
     578             : 
     579           0 :     if (_res) {
     580           0 :         *_res = talloc_steal(mem_ctx, state->res);
     581             :     }
     582             : 
     583           0 :     if (_domain) {
     584           0 :         *_domain = state->dom;
     585             :     }
     586             : 
     587           0 :     return EOK;
     588             : }
     589             : 
     590           0 : struct cli_protocol_version *register_cli_protocol_version(void)
     591             : {
     592             :     static struct cli_protocol_version ssh_cli_protocol_version[] = {
     593             :         {0, NULL, NULL}
     594             :     };
     595             : 
     596           0 :     return ssh_cli_protocol_version;
     597             : }
     598             : 
     599             : /* This is a throwaway method to ease the review of the patch.
     600             :  * It will be removed later */
     601           0 : int ifp_ping(struct sbus_request *dbus_req, void *data)
     602             : {
     603           0 :     struct ifp_ctx *ifp_ctx = talloc_get_type(data, struct ifp_ctx);
     604             :     static const char *pong = "PONG";
     605             :     const char *request;
     606             :     DBusError dberr;
     607             :     errno_t ret;
     608             :     struct ifp_req *ifp_req;
     609             : 
     610           0 :     if (ifp_ctx == NULL) {
     611           0 :         DEBUG(SSSDBG_CRIT_FAILURE, "Invalid pointer!\n");
     612           0 :         return sbus_request_return_and_finish(dbus_req, DBUS_TYPE_INVALID);
     613             :     }
     614             : 
     615           0 :     ret = ifp_req_create(dbus_req, ifp_ctx, &ifp_req);
     616           0 :     if (ret != EOK) {
     617           0 :         return ifp_req_create_handle_failure(dbus_req, ret);
     618             :     }
     619             : 
     620           0 :     if (!sbus_request_parse_or_finish(dbus_req,
     621             :                                       DBUS_TYPE_STRING, &request,
     622             :                                       DBUS_TYPE_INVALID)) {
     623           0 :         return EOK; /* handled */
     624             :     }
     625             : 
     626           0 :     DEBUG(SSSDBG_CONF_SETTINGS, "Got request for [%s]\n", request);
     627             : 
     628           0 :     if (strcasecmp(request, "ping") != 0) {
     629           0 :         dbus_error_init(&dberr);
     630           0 :         dbus_set_error_const(&dberr,
     631             :                              DBUS_ERROR_INVALID_ARGS,
     632             :                              "Ping() only accepts ping as a param\n");
     633           0 :         return sbus_request_fail_and_finish(dbus_req, &dberr);
     634             :     }
     635             : 
     636           0 :     return sbus_request_return_and_finish(dbus_req,
     637             :                                           DBUS_TYPE_STRING, &pong,
     638             :                                           DBUS_TYPE_INVALID);
     639             : }

Generated by: LCOV version 1.10