LCOV - code coverage report
Current view: top level - source3/winbindd - wb_query_group_list.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 23 33 69.7 %
Date: 2024-04-21 15:09:00 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    async query_group_list
       4             :    Copyright (C) Volker Lendecke 2009
       5             :    Copyright (C) Michael Adam 2015
       6             : 
       7             :    This program is free software; you can redistribute it and/or modify
       8             :    it under the terms of the GNU General Public License as published by
       9             :    the Free Software Foundation; either version 3 of the License, or
      10             :    (at your option) any later version.
      11             : 
      12             :    This program is distributed in the hope that it will be useful,
      13             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15             :    GNU General Public License for more details.
      16             : 
      17             :    You should have received a copy of the GNU General Public License
      18             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      19             : */
      20             : 
      21             : #include "includes.h"
      22             : #include "winbindd.h"
      23             : #include "librpc/gen_ndr/ndr_winbind_c.h"
      24             : 
      25             : 
      26             : struct wb_query_group_list_state {
      27             :         struct wbint_Principals groups;
      28             : };
      29             : 
      30             : static void wb_query_group_list_done(struct tevent_req *subreq);
      31             : 
      32          70 : struct tevent_req *wb_query_group_list_send(TALLOC_CTX *mem_ctx,
      33             :                                             struct tevent_context *ev,
      34             :                                             struct winbindd_domain *domain)
      35             : {
      36           0 :         struct tevent_req *req, *subreq;
      37           0 :         struct wb_query_group_list_state *state;
      38             : 
      39          70 :         req = tevent_req_create(mem_ctx, &state,
      40             :                                 struct wb_query_group_list_state);
      41          70 :         if (req == NULL) {
      42           0 :                 return NULL;
      43             :         }
      44             : 
      45          70 :         D_INFO("WB command group_list start.\nQuery domain %s\n", domain->name);
      46          70 :         subreq = dcerpc_wbint_QueryGroupList_send(state, ev,
      47             :                                                   dom_child_handle(domain),
      48          70 :                                                   &state->groups);
      49          70 :         if (tevent_req_nomem(subreq, req)) {
      50           0 :                 return tevent_req_post(req, ev);
      51             :         }
      52             : 
      53          70 :         tevent_req_set_callback(subreq, wb_query_group_list_done, req);
      54          70 :         return req;
      55             : }
      56             : 
      57          70 : static void wb_query_group_list_done(struct tevent_req *subreq)
      58             : {
      59          70 :         struct tevent_req *req = tevent_req_callback_data(
      60             :                 subreq, struct tevent_req);
      61          70 :         struct wb_query_group_list_state *state = tevent_req_data(
      62             :                 req, struct wb_query_group_list_state);
      63           0 :         NTSTATUS status, result;
      64             : 
      65          70 :         status = dcerpc_wbint_QueryGroupList_recv(subreq, state, &result);
      66          70 :         TALLOC_FREE(subreq);
      67          70 :         if (any_nt_status_not_ok(status, result, &status)) {
      68           0 :                 tevent_req_nterror(req, status);
      69           0 :                 return;
      70             :         }
      71             : 
      72          70 :         tevent_req_done(req);
      73             : }
      74             : 
      75          70 : NTSTATUS wb_query_group_list_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
      76             :                                   uint32_t *num_groups,
      77             :                                   struct wbint_Principal **groups)
      78             : {
      79          70 :         struct wb_query_group_list_state *state = tevent_req_data(
      80             :                 req, struct wb_query_group_list_state);
      81           0 :         NTSTATUS status;
      82             : 
      83          70 :         if (tevent_req_is_nterror(req, &status)) {
      84           0 :                 D_WARNING("Failed with: %s\n", nt_errstr(status));
      85           0 :                 return status;
      86             :         }
      87             : 
      88          70 :         *num_groups = state->groups.num_principals;
      89          70 :         *groups = talloc_move(mem_ctx, &state->groups.principals);
      90             : 
      91          70 :         D_INFO("WB command group_list end.\n"
      92             :                "Returning %"PRIu32" group(s).\n", *num_groups);
      93          70 :         return NT_STATUS_OK;
      94             : }

Generated by: LCOV version 1.14