2 Unix SMB/CIFS implementation.
3 async implementation of WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP
4 Copyright (C) Volker Lendecke 2010
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "lib/global_contexts.h"
24 struct winbindd_pam_chng_pswd_auth_crap_state
{
25 struct winbindd_request
*request
;
26 struct winbindd_response
*response
;
29 static void winbindd_pam_chng_pswd_auth_crap_done(struct tevent_req
*subreq
);
31 struct tevent_req
*winbindd_pam_chng_pswd_auth_crap_send(
33 struct tevent_context
*ev
,
34 struct winbindd_cli_state
*cli
,
35 struct winbindd_request
*request
)
37 struct tevent_req
*req
, *subreq
;
38 struct winbindd_pam_chng_pswd_auth_crap_state
*state
;
39 struct winbindd_domain
*domain
;
40 const char *domain_name
;
42 req
= tevent_req_create(mem_ctx
, &state
,
43 struct winbindd_pam_chng_pswd_auth_crap_state
);
47 state
->request
= request
;
49 /* Ensure null termination */
50 request
->data
.chng_pswd_auth_crap
.user
[
51 sizeof(request
->data
.chng_pswd_auth_crap
.user
)-1]='\0';
52 request
->data
.chng_pswd_auth_crap
.domain
[
53 sizeof(request
->data
.chng_pswd_auth_crap
.domain
)-1]=0;
55 DEBUG(3, ("[%5lu]: pam change pswd auth crap domain: %s user: %s\n",
56 (unsigned long)cli
->pid
,
57 request
->data
.chng_pswd_auth_crap
.domain
,
58 request
->data
.chng_pswd_auth_crap
.user
));
61 if (*state
->request
->data
.chng_pswd_auth_crap
.domain
!= '\0') {
62 domain_name
= state
->request
->data
.chng_pswd_auth_crap
.domain
;
63 } else if (lp_winbind_use_default_domain()) {
64 domain_name
= lp_workgroup();
68 if (domain_name
!= NULL
) {
69 domain
= find_domain_from_name(domain_name
);
73 tevent_req_nterror(req
, NT_STATUS_NO_SUCH_USER
);
74 return tevent_req_post(req
, ev
);
77 subreq
= wb_domain_request_send(state
, global_event_context(),
79 if (tevent_req_nomem(subreq
, req
)) {
80 return tevent_req_post(req
, ev
);
82 tevent_req_set_callback(subreq
, winbindd_pam_chng_pswd_auth_crap_done
,
87 static void winbindd_pam_chng_pswd_auth_crap_done(struct tevent_req
*subreq
)
89 struct tevent_req
*req
= tevent_req_callback_data(
90 subreq
, struct tevent_req
);
91 struct winbindd_pam_chng_pswd_auth_crap_state
*state
= tevent_req_data(
92 req
, struct winbindd_pam_chng_pswd_auth_crap_state
);
95 res
= wb_domain_request_recv(subreq
, state
, &state
->response
, &err
);
98 tevent_req_nterror(req
, map_nt_error_from_unix(err
));
101 tevent_req_done(req
);
104 NTSTATUS
winbindd_pam_chng_pswd_auth_crap_recv(
105 struct tevent_req
*req
,
106 struct winbindd_response
*response
)
108 struct winbindd_pam_chng_pswd_auth_crap_state
*state
= tevent_req_data(
109 req
, struct winbindd_pam_chng_pswd_auth_crap_state
);
112 if (tevent_req_is_nterror(req
, &status
)) {
113 set_auth_errors(response
, status
);
116 *response
= *state
->response
;
117 response
->result
= WINBINDD_PENDING
;
118 state
->response
= talloc_move(response
, &state
->response
);
120 return NT_STATUS(response
->data
.auth
.nt_status
);