1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-25 17:57:42 +03:00

s3:libsmb: Pass cli_credentials to cli_cm_open()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Andreas Schneider 2020-08-18 17:26:54 +02:00 committed by Jeremy Allison
parent c834911124
commit df1623abd7
4 changed files with 42 additions and 28 deletions

View File

@ -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);

View File

@ -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)) {

View File

@ -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,

View File

@ -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,