lib/param: use the correct path names again
[Samba/gebeck_regimport.git] / source3 / winbindd / winbindd_pam_chng_pswd_auth_crap.c
blob9133a91fa5032096e926b92894c2e760a3bdaa03
1 /*
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/>.
20 #include "includes.h"
21 #include "winbindd.h"
23 struct winbindd_pam_chng_pswd_auth_crap_state {
24 struct winbindd_request *request;
25 struct winbindd_response *response;
28 static void winbindd_pam_chng_pswd_auth_crap_done(struct tevent_req *subreq);
30 struct tevent_req *winbindd_pam_chng_pswd_auth_crap_send(
31 TALLOC_CTX *mem_ctx,
32 struct tevent_context *ev,
33 struct winbindd_cli_state *cli,
34 struct winbindd_request *request)
36 struct tevent_req *req, *subreq;
37 struct winbindd_pam_chng_pswd_auth_crap_state *state;
38 struct winbindd_domain *domain;
39 const char *domain_name;
41 req = tevent_req_create(mem_ctx, &state,
42 struct winbindd_pam_chng_pswd_auth_crap_state);
43 if (req == NULL) {
44 return NULL;
46 state->request = request;
48 /* Ensure null termination */
49 request->data.chng_pswd_auth_crap.user[
50 sizeof(request->data.chng_pswd_auth_crap.user)-1]='\0';
51 request->data.chng_pswd_auth_crap.domain[
52 sizeof(request->data.chng_pswd_auth_crap.domain)-1]=0;
54 DEBUG(3, ("[%5lu]: pam change pswd auth crap domain: %s user: %s\n",
55 (unsigned long)cli->pid,
56 request->data.chng_pswd_auth_crap.domain,
57 request->data.chng_pswd_auth_crap.user));
59 domain_name = NULL;
60 if (*state->request->data.chng_pswd_auth_crap.domain != '\0') {
61 domain_name = state->request->data.chng_pswd_auth_crap.domain;
62 } else if (lp_winbind_use_default_domain()) {
63 domain_name = lp_workgroup();
66 domain = NULL;
67 if (domain_name != NULL) {
68 domain = find_domain_from_name(domain_name);
71 if (domain == NULL) {
72 tevent_req_nterror(req, NT_STATUS_NO_SUCH_USER);
73 return tevent_req_post(req, ev);
76 subreq = wb_domain_request_send(state, winbind_event_context(),
77 domain, request);
78 if (tevent_req_nomem(subreq, req)) {
79 return tevent_req_post(req, ev);
81 tevent_req_set_callback(subreq, winbindd_pam_chng_pswd_auth_crap_done,
82 req);
83 return req;
86 static void winbindd_pam_chng_pswd_auth_crap_done(struct tevent_req *subreq)
88 struct tevent_req *req = tevent_req_callback_data(
89 subreq, struct tevent_req);
90 struct winbindd_pam_chng_pswd_auth_crap_state *state = tevent_req_data(
91 req, struct winbindd_pam_chng_pswd_auth_crap_state);
92 int res, err;
94 res = wb_domain_request_recv(subreq, state, &state->response, &err);
95 TALLOC_FREE(subreq);
96 if (res == -1) {
97 tevent_req_nterror(req, map_nt_error_from_unix(err));
98 return;
100 tevent_req_done(req);
103 NTSTATUS winbindd_pam_chng_pswd_auth_crap_recv(
104 struct tevent_req *req,
105 struct winbindd_response *response)
107 struct winbindd_pam_chng_pswd_auth_crap_state *state = tevent_req_data(
108 req, struct winbindd_pam_chng_pswd_auth_crap_state);
109 NTSTATUS status;
111 if (tevent_req_is_nterror(req, &status)) {
112 set_auth_errors(response, status);
113 return status;
115 *response = *state->response;
116 response->result = WINBINDD_PENDING;
117 state->response = talloc_move(response, &state->response);
119 return NT_STATUS(response->data.auth.nt_status);