summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/Makefile.in1
-rw-r--r--source3/winbindd/winbindd.c7
-rw-r--r--source3/winbindd/winbindd_pam.c42
-rw-r--r--source3/winbindd/winbindd_pam_chng_pswd_auth_crap.c120
-rw-r--r--source3/winbindd/winbindd_proto.h10
5 files changed, 133 insertions, 47 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 78c81c40d7..5551ee4510 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -1242,6 +1242,7 @@ WINBINDD_OBJ1 = \
winbindd/winbindd_pam_auth.o \
winbindd/winbindd_pam_auth_crap.o \
winbindd/winbindd_pam_chauthtok.o \
+ winbindd/winbindd_pam_chng_pswd_auth_crap.o \
winbindd/winbindd_pam_logoff.o \
auth/token_util.o \
auth/check_samsec.o \
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 3bd2ad7c09..4d00269970 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -442,10 +442,6 @@ static struct winbindd_dispatch_table {
const char *winbindd_cmd_name;
} dispatch_table[] = {
- /* PAM auth functions */
-
- { WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP, winbindd_pam_chng_pswd_auth_crap, "CHNG_PSWD_AUTH_CRAP" },
-
/* Enumeration functions */
{ WINBINDD_LIST_TRUSTDOM, winbindd_list_trusted_domains,
@@ -554,6 +550,9 @@ static struct winbindd_async_dispatch_table async_nonpriv_table[] = {
winbindd_pam_logoff_send, winbindd_pam_logoff_recv },
{ WINBINDD_PAM_CHAUTHTOK, "PAM_CHAUTHTOK",
winbindd_pam_chauthtok_send, winbindd_pam_chauthtok_recv },
+ { WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP, "PAM_CHNG_PSWD_AUTH_CRAP",
+ winbindd_pam_chng_pswd_auth_crap_send,
+ winbindd_pam_chng_pswd_auth_crap_recv },
{ 0, NULL, NULL, NULL }
};
diff --git a/source3/winbindd/winbindd_pam.c b/source3/winbindd/winbindd_pam.c
index 3f350e3fb2..ae7a363924 100644
--- a/source3/winbindd/winbindd_pam.c
+++ b/source3/winbindd/winbindd_pam.c
@@ -2127,48 +2127,6 @@ process_result:
/* Change user password with auth crap*/
-void winbindd_pam_chng_pswd_auth_crap(struct winbindd_cli_state *state)
-{
- struct winbindd_domain *domain = NULL;
- const char *domain_name = NULL;
-
- /* Ensure null termination */
- state->request->data.chng_pswd_auth_crap.user[
- sizeof(state->request->data.chng_pswd_auth_crap.user)-1]=0;
- state->request->data.chng_pswd_auth_crap.domain[
- sizeof(state->request->data.chng_pswd_auth_crap.domain)-1]=0;
-
- DEBUG(3, ("[%5lu]: pam change pswd auth crap domain: %s user: %s\n",
- (unsigned long)state->pid,
- state->request->data.chng_pswd_auth_crap.domain,
- state->request->data.chng_pswd_auth_crap.user));
-
- if (*state->request->data.chng_pswd_auth_crap.domain != '\0') {
- domain_name = state->request->data.chng_pswd_auth_crap.domain;
- } else if (lp_winbind_use_default_domain()) {
- domain_name = lp_workgroup();
- }
-
- if (domain_name != NULL)
- domain = find_domain_from_name(domain_name);
-
- if (domain != NULL) {
- DEBUG(7, ("[%5lu]: pam auth crap changing pswd in domain: "
- "%s\n", (unsigned long)state->pid,domain->name));
- sendto_domain(state, domain);
- return;
- }
-
- set_auth_errors(state->response, NT_STATUS_NO_SUCH_USER);
- DEBUG(5, ("CRAP change password for %s\\%s returned %s (PAM: %d)\n",
- state->request->data.chng_pswd_auth_crap.domain,
- state->request->data.chng_pswd_auth_crap.user,
- state->response->data.auth.nt_status_string,
- state->response->data.auth.pam_error));
- request_error(state);
- return;
-}
-
enum winbindd_result winbindd_dual_pam_chng_pswd_auth_crap(struct winbindd_domain *domainSt, struct winbindd_cli_state *state)
{
NTSTATUS result;
diff --git a/source3/winbindd/winbindd_pam_chng_pswd_auth_crap.c b/source3/winbindd/winbindd_pam_chng_pswd_auth_crap.c
new file mode 100644
index 0000000000..9133a91fa5
--- /dev/null
+++ b/source3/winbindd/winbindd_pam_chng_pswd_auth_crap.c
@@ -0,0 +1,120 @@
+/*
+ Unix SMB/CIFS implementation.
+ async implementation of WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP
+ Copyright (C) Volker Lendecke 2010
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "winbindd.h"
+
+struct winbindd_pam_chng_pswd_auth_crap_state {
+ struct winbindd_request *request;
+ struct winbindd_response *response;
+};
+
+static void winbindd_pam_chng_pswd_auth_crap_done(struct tevent_req *subreq);
+
+struct tevent_req *winbindd_pam_chng_pswd_auth_crap_send(
+ TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct winbindd_cli_state *cli,
+ struct winbindd_request *request)
+{
+ struct tevent_req *req, *subreq;
+ struct winbindd_pam_chng_pswd_auth_crap_state *state;
+ struct winbindd_domain *domain;
+ const char *domain_name;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct winbindd_pam_chng_pswd_auth_crap_state);
+ if (req == NULL) {
+ return NULL;
+ }
+ state->request = request;
+
+ /* Ensure null termination */
+ request->data.chng_pswd_auth_crap.user[
+ sizeof(request->data.chng_pswd_auth_crap.user)-1]='\0';
+ request->data.chng_pswd_auth_crap.domain[
+ sizeof(request->data.chng_pswd_auth_crap.domain)-1]=0;
+
+ DEBUG(3, ("[%5lu]: pam change pswd auth crap domain: %s user: %s\n",
+ (unsigned long)cli->pid,
+ request->data.chng_pswd_auth_crap.domain,
+ request->data.chng_pswd_auth_crap.user));
+
+ domain_name = NULL;
+ if (*state->request->data.chng_pswd_auth_crap.domain != '\0') {
+ domain_name = state->request->data.chng_pswd_auth_crap.domain;
+ } else if (lp_winbind_use_default_domain()) {
+ domain_name = lp_workgroup();
+ }
+
+ domain = NULL;
+ if (domain_name != NULL) {
+ domain = find_domain_from_name(domain_name);
+ }
+
+ if (domain == NULL) {
+ tevent_req_nterror(req, NT_STATUS_NO_SUCH_USER);
+ return tevent_req_post(req, ev);
+ }
+
+ subreq = wb_domain_request_send(state, winbind_event_context(),
+ domain, request);
+ if (tevent_req_nomem(subreq, req)) {
+ return tevent_req_post(req, ev);
+ }
+ tevent_req_set_callback(subreq, winbindd_pam_chng_pswd_auth_crap_done,
+ req);
+ return req;
+}
+
+static void winbindd_pam_chng_pswd_auth_crap_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct winbindd_pam_chng_pswd_auth_crap_state *state = tevent_req_data(
+ req, struct winbindd_pam_chng_pswd_auth_crap_state);
+ int res, err;
+
+ res = wb_domain_request_recv(subreq, state, &state->response, &err);
+ TALLOC_FREE(subreq);
+ if (res == -1) {
+ tevent_req_nterror(req, map_nt_error_from_unix(err));
+ return;
+ }
+ tevent_req_done(req);
+}
+
+NTSTATUS winbindd_pam_chng_pswd_auth_crap_recv(
+ struct tevent_req *req,
+ struct winbindd_response *response)
+{
+ struct winbindd_pam_chng_pswd_auth_crap_state *state = tevent_req_data(
+ req, struct winbindd_pam_chng_pswd_auth_crap_state);
+ NTSTATUS status;
+
+ if (tevent_req_is_nterror(req, &status)) {
+ set_auth_errors(response, status);
+ return status;
+ }
+ *response = *state->response;
+ response->result = WINBINDD_PENDING;
+ state->response = talloc_move(response, &state->response);
+
+ return NT_STATUS(response->data.auth.nt_status);
+}
diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h
index 221c51ed85..2bf33cbc1e 100644
--- a/source3/winbindd/winbindd_proto.h
+++ b/source3/winbindd/winbindd_proto.h
@@ -391,7 +391,6 @@ enum winbindd_result winbindd_dual_pam_chauthtok(struct winbindd_domain *contact
struct winbindd_cli_state *state);
enum winbindd_result winbindd_dual_pam_logoff(struct winbindd_domain *domain,
struct winbindd_cli_state *state) ;
-void winbindd_pam_chng_pswd_auth_crap(struct winbindd_cli_state *state);
enum winbindd_result winbindd_dual_pam_chng_pswd_auth_crap(struct winbindd_domain *domainSt, struct winbindd_cli_state *state);
/* The following definitions come from winbindd/winbindd_util.c */
@@ -879,4 +878,13 @@ struct tevent_req *winbindd_pam_logoff_send(TALLOC_CTX *mem_ctx,
NTSTATUS winbindd_pam_logoff_recv(struct tevent_req *req,
struct winbindd_response *response);
+struct tevent_req *winbindd_pam_chng_pswd_auth_crap_send(
+ TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct winbindd_cli_state *cli,
+ struct winbindd_request *request);
+NTSTATUS winbindd_pam_chng_pswd_auth_crap_recv(
+ struct tevent_req *req,
+ struct winbindd_response *response);
+
#endif /* _WINBINDD_PROTO_H_ */