LCOV - code coverage report
Current view: top level - source3/winbindd - winbindd_change_machine_acct.c (source / functions) Hit Total Coverage
Test: coverage report for master 2b515b7d Lines: 23 33 69.7 %
Date: 2024-02-28 12:06:22 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    async implementation of WINBINDD_CHANGE_MACHINE_ACCT
       4             :    Copyright (C) Volker Lendecke 2009
       5             :    Copyright (C) Guenther Deschner 2009
       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             : struct winbindd_change_machine_acct_state {
      26             :         uint8_t dummy;
      27             : };
      28             : 
      29             : static void winbindd_change_machine_acct_done(struct tevent_req *subreq);
      30             : 
      31          18 : struct tevent_req *winbindd_change_machine_acct_send(TALLOC_CTX *mem_ctx,
      32             :                                                      struct tevent_context *ev,
      33             :                                                      struct winbindd_cli_state *cli,
      34             :                                                      struct winbindd_request *request)
      35             : {
      36           0 :         struct tevent_req *req, *subreq;
      37           0 :         struct winbindd_change_machine_acct_state *state;
      38           0 :         struct winbindd_domain *domain;
      39          18 :         const char *dcname = NULL;
      40             : 
      41          18 :         req = tevent_req_create(mem_ctx, &state,
      42             :                                 struct winbindd_change_machine_acct_state);
      43          18 :         if (req == NULL) {
      44           0 :                 return NULL;
      45             :         }
      46             : 
      47          18 :         if (request->data.init_conn.dcname[0] != '\0') {
      48           2 :                 dcname = request->data.init_conn.dcname;
      49             :         }
      50             : 
      51          18 :         domain = find_domain_from_name(request->domain_name);
      52          18 :         if (domain == NULL) {
      53           0 :                 tevent_req_nterror(req, NT_STATUS_NO_SUCH_DOMAIN);
      54           0 :                 return tevent_req_post(req, ev);
      55             :         }
      56          18 :         if (domain->internal) {
      57             :                 /*
      58             :                  * Internal domains are passdb based, we can always
      59             :                  * contact them.
      60             :                  *
      61             :                  * This also protects us from changing the password on
      62             :                  * the AD DC without updating all the right databases.
      63             :                  * Do not remove this until that code is fixed.
      64             :                  */
      65           2 :                 tevent_req_done(req);
      66           2 :                 return tevent_req_post(req, ev);
      67             :         }
      68             : 
      69          16 :         subreq = dcerpc_wbint_ChangeMachineAccount_send(state, ev,
      70             :                                                         dom_child_handle(domain),
      71             :                                                         dcname);
      72          16 :         if (tevent_req_nomem(subreq, req)) {
      73           0 :                 return tevent_req_post(req, ev);
      74             :         }
      75          16 :         tevent_req_set_callback(subreq, winbindd_change_machine_acct_done, req);
      76          16 :         return req;
      77             : }
      78             : 
      79          16 : static void winbindd_change_machine_acct_done(struct tevent_req *subreq)
      80             : {
      81          16 :         struct tevent_req *req = tevent_req_callback_data(
      82             :                 subreq, struct tevent_req);
      83          16 :         struct winbindd_change_machine_acct_state *state = tevent_req_data(
      84             :                 req, struct winbindd_change_machine_acct_state);
      85           0 :         NTSTATUS status, result;
      86             : 
      87          16 :         status = dcerpc_wbint_ChangeMachineAccount_recv(subreq, state, &result);
      88          16 :         if (any_nt_status_not_ok(status, result, &status)) {
      89           0 :                 tevent_req_nterror(req, status);
      90           0 :                 return;
      91             :         }
      92          16 :         tevent_req_done(req);
      93             : }
      94             : 
      95          18 : NTSTATUS winbindd_change_machine_acct_recv(struct tevent_req *req,
      96             :                                            struct winbindd_response *presp)
      97             : {
      98          18 :         return tevent_req_simple_recv_ntstatus(req);
      99             : }

Generated by: LCOV version 1.14