From: Andreas Schneider Date: Tue, 18 Aug 2020 15:26:54 +0000 (+0200) Subject: s3:libsmb: Pass cli_credentials to cli_cm_open() X-Git-Tag: talloc-2.3.2~278 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=df1623abd7267916696e2e60c146ef8fa6c9dfc9;p=thirdparty%2Fsamba.git s3:libsmb: Pass cli_credentials to cli_cm_open() Signed-off-by: Andreas Schneider Reviewed-by: Jeremy Allison --- diff --git a/source3/client/client.c b/source3/client/client.c index d5d5e157b29..8575ef40904 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -5545,6 +5545,8 @@ static int process_command_string(const char *cmd_in) TALLOC_CTX *ctx = talloc_tos(); char *cmd = talloc_strdup(ctx, cmd_in); int rc = 0; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); if (!cmd) { return 1; @@ -5556,7 +5558,8 @@ static int process_command_string(const char *cmd_in) status = cli_cm_open(talloc_tos(), NULL, desthost, - service, popt_get_cmdline_auth_info(), + service, + creds, max_protocol, have_ip ? &dest_ss : NULL, port, name_type, @@ -5997,10 +6000,13 @@ static int process(const char *base_directory) { int rc = 0; NTSTATUS status; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); status = cli_cm_open(talloc_tos(), NULL, desthost, - service, popt_get_cmdline_auth_info(), + service, + creds, max_protocol, have_ip ? &dest_ss : NULL, port, name_type, &cli); @@ -6035,10 +6041,13 @@ static int process(const char *base_directory) static int do_host_query(const char *query_host) { NTSTATUS status; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); status = cli_cm_open(talloc_tos(), NULL, query_host, - "IPC$", popt_get_cmdline_auth_info(), + "IPC$", + creds, max_protocol, have_ip ? &dest_ss : NULL, port, name_type, &cli); @@ -6085,7 +6094,8 @@ static int do_host_query(const char *query_host) d_printf("Reconnecting with SMB1 for workgroup listing.\n"); status = cli_cm_open(talloc_tos(), NULL, query_host, - "IPC$", popt_get_cmdline_auth_info(), + "IPC$", + creds, max_proto, have_ip ? &dest_ss : NULL, NBT_SMB_PORT, name_type, &cli); @@ -6112,6 +6122,8 @@ static int do_tar_op(const char *base_directory) { struct tar *tar_ctx = tar_get_ctx(); int ret = 0; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); /* do we already have a connection? */ if (!cli) { @@ -6119,7 +6131,8 @@ static int do_tar_op(const char *base_directory) status = cli_cm_open(talloc_tos(), NULL, desthost, - service, popt_get_cmdline_auth_info(), + service, + creds, max_protocol, have_ip ? &dest_ss : NULL, port, name_type, &cli); diff --git a/source3/lib/netapi/cm.c b/source3/lib/netapi/cm.c index 0fd31ef3d5a..943f7498e8c 100644 --- a/source3/lib/netapi/cm.c +++ b/source3/lib/netapi/cm.c @@ -71,6 +71,7 @@ static WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx, struct cli_state *cli_ipc = NULL; struct client_ipc_connection *p; NTSTATUS status; + struct cli_credentials *creds = NULL; if (!ctx || !pp || !server_name) { return WERR_INVALID_PARAMETER; @@ -106,10 +107,11 @@ static WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx, if (ctx->use_ccache) { set_cmdline_auth_info_use_ccache(auth_info, true); } + creds = get_cmdline_auth_info_creds(auth_info); status = cli_cm_open(ctx, NULL, server_name, "IPC$", - auth_info, + creds, lp_client_ipc_max_protocol(), NULL, 0, 0x20, &cli_ipc); if (!NT_STATUS_IS_OK(status)) { diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c index a2c6f5fe5ec..ef75fb36a45 100644 --- a/source3/libsmb/clidfs.c +++ b/source3/libsmb/clidfs.c @@ -384,19 +384,18 @@ static struct cli_state *cli_cm_find(struct cli_state *cli, ****************************************************************************/ NTSTATUS cli_cm_open(TALLOC_CTX *ctx, - struct cli_state *referring_cli, - const char *server, - const char *share, - const struct user_auth_info *auth_info, - int max_protocol, - const struct sockaddr_storage *dest_ss, - int port, - int name_type, - struct cli_state **pcli) + struct cli_state *referring_cli, + const char *server, + const char *share, + struct cli_credentials *creds, + int max_protocol, + const struct sockaddr_storage *dest_ss, + int port, + int name_type, + struct cli_state **pcli) { /* Try to reuse an existing connection in this list. */ struct cli_state *c = cli_cm_find(referring_cli, server, share); - struct cli_credentials *creds = get_cmdline_auth_info_creds(auth_info); NTSTATUS status; if (c) { @@ -404,11 +403,11 @@ NTSTATUS cli_cm_open(TALLOC_CTX *ctx, return NT_STATUS_OK; } - if (auth_info == NULL) { + if (creds == NULL) { /* Can't do a new connection * without auth info. */ d_printf("cli_cm_open() Unable to open connection [\\%s\\%s] " - "without auth info\n", + "without client credentials\n", server, share ); return NT_STATUS_INVALID_PARAMETER; } @@ -966,7 +965,7 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx, rootcli, smbXcli_conn_remote_name(rootcli->conn), "IPC$", - dfs_auth_info, + creds, smbXcli_conn_protocol(rootcli->conn), NULL, /* dest_ss not needed, we reuse the transport */ 0, diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h index e636fc96f50..c8b81a37c08 100644 --- a/source3/libsmb/proto.h +++ b/source3/libsmb/proto.h @@ -124,15 +124,15 @@ struct cli_state *get_ipc_connect_master_ip(TALLOC_CTX *ctx, /* The following definitions come from libsmb/clidfs.c */ NTSTATUS cli_cm_open(TALLOC_CTX *ctx, - struct cli_state *referring_cli, - const char *server, - const char *share, - const struct user_auth_info *auth_info, - int max_protocol, - const struct sockaddr_storage *dest_ss, - int port, - int name_type, - struct cli_state **pcli); + struct cli_state *referring_cli, + const char *server, + const char *share, + struct cli_credentials *creds, + int max_protocol, + const struct sockaddr_storage *dest_ss, + int port, + int name_type, + struct cli_state **pcli); void cli_cm_display(struct cli_state *c); struct client_dfs_referral; NTSTATUS cli_dfs_get_referral_ex(TALLOC_CTX *ctx,