From 2b9d6d3d9b6766ba2e48523b005a7eecf3e05412 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 23 Sep 2014 14:19:35 -0700 Subject: [PATCH] s3:libsmb: Remove unused password copy stored in cli_state Change-Id: Ia6b33a25628ae08be8a8c6baeb71ce390315cb45 Signed-off-by: Andrew Bartlett Reviewed-by: Stefan Metzmacher --- source3/include/client.h | 1 - source3/lib/netapi/cm.c | 1 - source3/libsmb/cliconnect.c | 6 ++---- source3/libsmb/clidfs.c | 4 ++-- source3/libsmb/clientgen.c | 22 ++-------------------- source3/libsmb/libsmb_server.c | 2 +- source3/libsmb/passchange.c | 6 +++--- source3/libsmb/proto.h | 3 +-- source3/winbindd/winbindd_cm.c | 4 ++-- 9 files changed, 13 insertions(+), 36 deletions(-) diff --git a/source3/include/client.h b/source3/include/client.h index 59fb104cae5..c19a7755c41 100644 --- a/source3/include/client.h +++ b/source3/include/client.h @@ -55,7 +55,6 @@ struct cli_state { /* The credentials used to open the cli_state connection. */ char *domain; char *user_name; - char *password; /* Can be null to force use of zero NTLMSSP session key. */ /* * The following strings are the diff --git a/source3/lib/netapi/cm.c b/source3/lib/netapi/cm.c index 801e61f4a45..cad84aa18d2 100644 --- a/source3/lib/netapi/cm.c +++ b/source3/lib/netapi/cm.c @@ -115,7 +115,6 @@ static WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx, 0, 0x20, &cli_ipc); if (NT_STATUS_IS_OK(status)) { cli_set_username(cli_ipc, ctx->username); - cli_set_password(cli_ipc, ctx->password); cli_set_domain(cli_ipc, ctx->workgroup); } else { cli_ipc = NULL; diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index e1fc4e903cc..1960fe7e60b 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -3389,8 +3389,7 @@ static void cli_full_connection_sess_set_up(struct tevent_req *subreq) return; } - status = cli_init_creds(state->cli, state->user, state->domain, - state->password); + status = cli_init_creds(state->cli, state->user, state->domain); if (tevent_req_nterror(req, status)) { return; } @@ -3410,8 +3409,7 @@ static void cli_full_connection_done(struct tevent_req *subreq) if (tevent_req_nterror(req, status)) { return; } - status = cli_init_creds(state->cli, state->user, state->domain, - state->password); + status = cli_init_creds(state->cli, state->user, state->domain); if (tevent_req_nterror(req, status)) { return; } diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c index 93f04c50746..e679d9dbd8e 100644 --- a/source3/libsmb/clidfs.c +++ b/source3/libsmb/clidfs.c @@ -207,9 +207,9 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx, return status; } d_printf("Anonymous login successful\n"); - status = cli_init_creds(c, "", lp_workgroup(), ""); + status = cli_init_creds(c, "", lp_workgroup()); } else { - status = cli_init_creds(c, username, lp_workgroup(), password); + status = cli_init_creds(c, username, lp_workgroup()); } if (!NT_STATUS_IS_OK(status)) { diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index 71ec1dcc99a..1f03560f8a6 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -89,29 +89,11 @@ NTSTATUS cli_set_username(struct cli_state *cli, const char *username) return NT_STATUS_OK; } -NTSTATUS cli_set_password(struct cli_state *cli, const char *password) -{ - TALLOC_FREE(cli->password); - - /* Password can be NULL. */ - if (password) { - cli->password = talloc_strdup(cli, password); - if (cli->password == NULL) { - return NT_STATUS_NO_MEMORY; - } - } else { - /* Use zero NTLMSSP hashes and session key. */ - cli->password = NULL; - } - - return NT_STATUS_OK; -} - /**************************************************************************** Initialise credentials of a client structure. ****************************************************************************/ -NTSTATUS cli_init_creds(struct cli_state *cli, const char *username, const char *domain, const char *password) +NTSTATUS cli_init_creds(struct cli_state *cli, const char *username, const char *domain) { NTSTATUS status = cli_set_username(cli, username); if (!NT_STATUS_IS_OK(status)) { @@ -123,7 +105,7 @@ NTSTATUS cli_init_creds(struct cli_state *cli, const char *username, const char } DEBUG(10,("cli_init_creds: user %s domain %s\n", cli->user_name, cli->domain)); - return cli_set_password(cli, password); + return NT_STATUS_OK; } /**************************************************************************** diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c index d89b9ec9dc3..2d8eebbb339 100644 --- a/source3/libsmb/libsmb_server.c +++ b/source3/libsmb/libsmb_server.c @@ -489,7 +489,7 @@ SMBC_server_internal(TALLOC_CTX *ctx, } status = cli_init_creds(c, username_used, - *pp_workgroup, *pp_password); + *pp_workgroup); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); cli_shutdown(c); diff --git a/source3/libsmb/passchange.c b/source3/libsmb/passchange.c index 8acd432cc34..344f2a4aa35 100644 --- a/source3/libsmb/passchange.c +++ b/source3/libsmb/passchange.c @@ -123,13 +123,13 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam return result; } - result = cli_init_creds(cli, "", "", NULL); + result = cli_init_creds(cli, "", ""); if (!NT_STATUS_IS_OK(result)) { cli_shutdown(cli); return result; } } else { - result = cli_init_creds(cli, user, domain, old_passwd); + result = cli_init_creds(cli, user, domain); if (!NT_STATUS_IS_OK(result)) { cli_shutdown(cli); return result; @@ -222,7 +222,7 @@ NTSTATUS remote_password_change(const char *remote_machine, const char *user_nam TALLOC_FREE(pipe_hnd); /* Try anonymous NTLMSSP... */ - result = cli_init_creds(cli, "", "", NULL); + result = cli_init_creds(cli, "", ""); if (!NT_STATUS_IS_OK(result)) { cli_shutdown(cli); return result; diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h index 2efb2083982..7693106101f 100644 --- a/source3/libsmb/proto.h +++ b/source3/libsmb/proto.h @@ -163,8 +163,7 @@ bool cli_set_backup_intent(struct cli_state *cli, bool flag); void cli_setup_packet_buf(struct cli_state *cli, char *buf); NTSTATUS cli_set_domain(struct cli_state *cli, const char *domain); NTSTATUS cli_set_username(struct cli_state *cli, const char *username); -NTSTATUS cli_set_password(struct cli_state *cli, const char *password); -NTSTATUS cli_init_creds(struct cli_state *cli, const char *username, const char *domain, const char *password); +NTSTATUS cli_init_creds(struct cli_state *cli, const char *username, const char *domain); extern struct GUID cli_state_client_guid; struct cli_state *cli_state_create(TALLOC_CTX *mem_ctx, int fd, diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c index 7c466820d91..8d1af8967e3 100644 --- a/source3/winbindd/winbindd_cm.c +++ b/source3/winbindd/winbindd_cm.c @@ -1116,7 +1116,7 @@ static NTSTATUS cm_prepare_connection(struct winbindd_domain *domain, if (NT_STATUS_IS_OK(result)) { if (krb5_state != CRED_MUST_USE_KERBEROS) { /* Ensure creds are stored for NTLMSSP authenticated pipe access. */ - result = cli_init_creds(*cli, machine_account, machine_domain, machine_password); + result = cli_init_creds(*cli, machine_account, machine_domain); if (!NT_STATUS_IS_OK(result)) { goto done; } @@ -1215,7 +1215,7 @@ static NTSTATUS cm_prepare_connection(struct winbindd_domain *domain, if (NT_STATUS_IS_OK(result)) { /* Ensure creds are stored for NTLMSSP authenticated pipe access. */ - result = cli_init_creds(*cli, machine_account, machine_domain, machine_password); + result = cli_init_creds(*cli, machine_account, machine_domain); if (!NT_STATUS_IS_OK(result)) { goto done; } -- 2.11.4.GIT