mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
s3:libsmb: Pass memory context to cli_connect_nb()
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
This commit is contained in:
parent
4f62937dfa
commit
bbb21797bf
@ -6407,7 +6407,8 @@ static int do_message_op(struct cli_credentials *creds)
|
||||
return 1;
|
||||
}
|
||||
|
||||
status = cli_connect_nb(desthost, have_ip ? &dest_ss : NULL,
|
||||
status = cli_connect_nb(talloc_tos(),
|
||||
desthost, have_ip ? &dest_ss : NULL,
|
||||
port ? port : NBT_SMB_PORT, name_type,
|
||||
lp_netbios_name(),
|
||||
SMB_SIGNING_OFF,
|
||||
|
@ -2751,15 +2751,21 @@ static NTSTATUS cli_connect_nb_recv(struct tevent_req *req,
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
NTSTATUS cli_connect_nb(const char *host, const struct sockaddr_storage *dest_ss,
|
||||
uint16_t port, int name_type, const char *myname,
|
||||
enum smb_signing_setting signing_state, int flags, struct cli_state **pcli)
|
||||
NTSTATUS cli_connect_nb(TALLOC_CTX *mem_ctx,
|
||||
const char *host,
|
||||
const struct sockaddr_storage *dest_ss,
|
||||
uint16_t port,
|
||||
int name_type,
|
||||
const char *myname,
|
||||
enum smb_signing_setting signing_state,
|
||||
int flags,
|
||||
struct cli_state **pcli)
|
||||
{
|
||||
struct tevent_context *ev;
|
||||
struct tevent_req *req;
|
||||
NTSTATUS status = NT_STATUS_NO_MEMORY;
|
||||
|
||||
ev = samba_tevent_context_init(talloc_tos());
|
||||
ev = samba_tevent_context_init(mem_ctx);
|
||||
if (ev == NULL) {
|
||||
goto fail;
|
||||
}
|
||||
@ -2774,7 +2780,7 @@ NTSTATUS cli_connect_nb(const char *host, const struct sockaddr_storage *dest_ss
|
||||
if (!tevent_req_poll_ntstatus(req, ev, &status)) {
|
||||
goto fail;
|
||||
}
|
||||
status = cli_connect_nb_recv(req, NULL, pcli);
|
||||
status = cli_connect_nb_recv(req, mem_ctx, pcli);
|
||||
fail:
|
||||
TALLOC_FREE(ev);
|
||||
return status;
|
||||
|
@ -178,10 +178,20 @@ static NTSTATUS do_connect(TALLOC_CTX *ctx,
|
||||
return NT_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
status = cli_connect_nb(
|
||||
server, dest_ss, port, name_type, NULL,
|
||||
signing_state,
|
||||
flags, &c);
|
||||
/*
|
||||
* The functions cli_resolve_path() and cli_cm_open() might not create a
|
||||
* new cli context, but might return an already existing one. This
|
||||
* forces us to have a long lived cli allocated on the NULL context.
|
||||
*/
|
||||
status = cli_connect_nb(NULL,
|
||||
server,
|
||||
dest_ss,
|
||||
port,
|
||||
name_type,
|
||||
NULL,
|
||||
signing_state,
|
||||
flags,
|
||||
&c);
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
|
||||
|
@ -529,9 +529,15 @@ SMBC_server_internal(TALLOC_CTX *ctx,
|
||||
/*
|
||||
* Try 139 first for IPC$
|
||||
*/
|
||||
status = cli_connect_nb(server_n, NULL, NBT_SMB_PORT, 0x20,
|
||||
smbc_getNetbiosName(context),
|
||||
signing_state, flags, &c);
|
||||
status = cli_connect_nb(NULL,
|
||||
server_n,
|
||||
NULL,
|
||||
NBT_SMB_PORT,
|
||||
0x20,
|
||||
smbc_getNetbiosName(context),
|
||||
signing_state,
|
||||
flags,
|
||||
&c);
|
||||
}
|
||||
}
|
||||
|
||||
@ -539,9 +545,15 @@ SMBC_server_internal(TALLOC_CTX *ctx,
|
||||
/*
|
||||
* No IPC$ or 139 did not work
|
||||
*/
|
||||
status = cli_connect_nb(server_n, NULL, port, 0x20,
|
||||
status = cli_connect_nb(NULL,
|
||||
server_n,
|
||||
NULL,
|
||||
port,
|
||||
0x20,
|
||||
smbc_getNetbiosName(context),
|
||||
signing_state, flags, &c);
|
||||
signing_state,
|
||||
flags,
|
||||
&c);
|
||||
}
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
|
@ -44,8 +44,15 @@ NTSTATUS remote_password_change(const char *remote_machine,
|
||||
|
||||
*err_str = NULL;
|
||||
|
||||
result = cli_connect_nb(remote_machine, NULL, 0, 0x20, NULL,
|
||||
SMB_SIGNING_IPC_DEFAULT, 0, &cli);
|
||||
result = cli_connect_nb(talloc_tos(),
|
||||
remote_machine,
|
||||
NULL,
|
||||
0,
|
||||
0x20,
|
||||
NULL,
|
||||
SMB_SIGNING_IPC_DEFAULT,
|
||||
0,
|
||||
&cli);
|
||||
if (!NT_STATUS_IS_OK(result)) {
|
||||
if (NT_STATUS_EQUAL(result, NT_STATUS_NOT_SUPPORTED)) {
|
||||
if (asprintf(err_str, "Unable to connect to SMB server on "
|
||||
|
@ -82,9 +82,15 @@ NTSTATUS cli_tree_connect_creds(struct cli_state *cli,
|
||||
NTSTATUS cli_tree_connect(struct cli_state *cli, const char *share,
|
||||
const char *dev, const char *pass);
|
||||
NTSTATUS cli_tdis(struct cli_state *cli);
|
||||
NTSTATUS cli_connect_nb(const char *host, const struct sockaddr_storage *dest_ss,
|
||||
uint16_t port, int name_type, const char *myname,
|
||||
enum smb_signing_setting signing_state, int flags, struct cli_state **pcli);
|
||||
NTSTATUS cli_connect_nb(TALLOC_CTX *mem_ctx,
|
||||
const char *host,
|
||||
const struct sockaddr_storage *dest_ss,
|
||||
uint16_t port,
|
||||
int name_type,
|
||||
const char *myname,
|
||||
enum smb_signing_setting signing_state,
|
||||
int flags,
|
||||
struct cli_state **pcli);
|
||||
NTSTATUS cli_start_connection(struct cli_state **output_cli,
|
||||
const char *my_name,
|
||||
const char *dest_host,
|
||||
|
@ -84,9 +84,15 @@ static void sync_child(char *name, int nm_type,
|
||||
|
||||
in_addr_to_sockaddr_storage(&ss, ip);
|
||||
|
||||
status = cli_connect_nb(name, &ss, NBT_SMB_PORT, nm_type,
|
||||
get_local_machine_name(), SMB_SIGNING_DEFAULT,
|
||||
0, &cli);
|
||||
status = cli_connect_nb(talloc_tos(),
|
||||
name,
|
||||
&ss,
|
||||
NBT_SMB_PORT,
|
||||
nm_type,
|
||||
get_local_machine_name(),
|
||||
SMB_SIGNING_DEFAULT,
|
||||
0,
|
||||
&cli);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
return;
|
||||
}
|
||||
|
@ -157,8 +157,15 @@ static struct cli_state *open_nbt_connection(void)
|
||||
flags |= CLI_FULL_CONNECTION_FORCE_DOS_ERRORS;
|
||||
}
|
||||
|
||||
status = cli_connect_nb(host, NULL, port_to_use, 0x20, myname,
|
||||
signing_state, flags, &c);
|
||||
status = cli_connect_nb(NULL,
|
||||
host,
|
||||
NULL,
|
||||
port_to_use,
|
||||
0x20,
|
||||
myname,
|
||||
signing_state,
|
||||
flags,
|
||||
&c);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
printf("Failed to connect with %s. Error %s\n", host, nt_errstr(status) );
|
||||
return NULL;
|
||||
|
@ -7501,9 +7501,15 @@ bool net_rpc_check(struct net_context *c, unsigned flags)
|
||||
if (!net_find_server(c, NULL, flags, &server_ss, &server_name))
|
||||
return false;
|
||||
|
||||
status = cli_connect_nb(server_name, &server_ss, 0, 0x20,
|
||||
lp_netbios_name(), SMB_SIGNING_IPC_DEFAULT,
|
||||
0, &cli);
|
||||
status = cli_connect_nb(c,
|
||||
server_name,
|
||||
&server_ss,
|
||||
0,
|
||||
0x20,
|
||||
lp_netbios_name(),
|
||||
SMB_SIGNING_IPC_DEFAULT,
|
||||
0,
|
||||
&cli);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
|
||||
DBG_ERR("NetBIOS support disabled, unable to connect\n");
|
||||
|
@ -34,8 +34,15 @@ static time_t cli_servertime(const char *host,
|
||||
struct cli_state *cli = NULL;
|
||||
NTSTATUS status;
|
||||
|
||||
status = cli_connect_nb(host, dest_ss, 0, 0x20, lp_netbios_name(),
|
||||
SMB_SIGNING_DEFAULT, 0, &cli);
|
||||
status = cli_connect_nb(talloc_tos(),
|
||||
host,
|
||||
dest_ss,
|
||||
0,
|
||||
0x20,
|
||||
lp_netbios_name(),
|
||||
SMB_SIGNING_DEFAULT,
|
||||
0,
|
||||
&cli);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
|
||||
fprintf(stderr, "Can't contact server %s. NetBIOS support disabled,"
|
||||
|
Loading…
Reference in New Issue
Block a user