1
0
mirror of https://github.com/samba-team/samba.git synced 2025-10-07 03:33:18 +03:00

s3: libsmb: Add cli_smb2_setpathinfo(), to be called by cli_setpathinfo_basic().

Fix to prevent libsmbclient from accidently making SMB1 calls inside an SMB2
connection.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12913

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Jeremy Allison
2017-07-21 12:41:11 -07:00
committed by Ralph Boehme
parent 812006fa8f
commit 2a15c70603
3 changed files with 89 additions and 0 deletions

View File

@@ -1645,6 +1645,75 @@ NTSTATUS cli_smb2_qpathinfo_streams(struct cli_state *cli,
return status;
}
/***************************************************************
Wrapper that allows SMB2 to set SMB_FILE_BASIC_INFORMATION on
a pathname.
Synchronous only.
***************************************************************/
NTSTATUS cli_smb2_setpathinfo(struct cli_state *cli,
const char *name,
uint8_t in_info_type,
uint8_t in_file_info_class,
const DATA_BLOB *p_in_data)
{
NTSTATUS status;
uint16_t fnum = 0xffff;
struct smb2_hnd *ph = NULL;
TALLOC_CTX *frame = talloc_stackframe();
if (smbXcli_conn_has_async_calls(cli->conn)) {
/*
* Can't use sync call while an async call is in flight
*/
status = NT_STATUS_INVALID_PARAMETER;
goto fail;
}
if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) {
status = NT_STATUS_INVALID_PARAMETER;
goto fail;
}
status = get_fnum_from_path(cli,
name,
FILE_WRITE_ATTRIBUTES,
&fnum);
if (!NT_STATUS_IS_OK(status)) {
goto fail;
}
status = map_fnum_to_smb2_handle(cli,
fnum,
&ph);
if (!NT_STATUS_IS_OK(status)) {
goto fail;
}
status = smb2cli_set_info(cli->conn,
cli->timeout,
cli->smb2.session,
cli->smb2.tcon,
in_info_type,
in_file_info_class,
p_in_data, /* in_input_buffer */
0, /* in_additional_info */
ph->fid_persistent,
ph->fid_volatile);
fail:
if (fnum != 0xffff) {
cli_smb2_close_fnum(cli, fnum);
}
cli->raw_status = status;
TALLOC_FREE(frame);
return status;
}
/***************************************************************
Wrapper that allows SMB2 to set pathname attributes.
Synchronous only.
@@ -1752,6 +1821,7 @@ NTSTATUS cli_smb2_setatr(struct cli_state *cli,
return status;
}
/***************************************************************
Wrapper that allows SMB2 to set file handle times.
Synchronous only.

View File

@@ -114,6 +114,11 @@ NTSTATUS cli_smb2_qpathinfo_streams(struct cli_state *cli,
TALLOC_CTX *mem_ctx,
unsigned int *pnum_streams,
struct stream_struct **pstreams);
NTSTATUS cli_smb2_setpathinfo(struct cli_state *cli,
const char *name,
uint8_t in_info_type,
uint8_t in_file_info_class,
const DATA_BLOB *p_in_data);
NTSTATUS cli_smb2_setatr(struct cli_state *cli,
const char *fname,
uint16_t attr,

View File

@@ -29,6 +29,7 @@
#include "libsmb/clirap.h"
#include "trans2.h"
#include "../libcli/smb/smbXcli_base.h"
#include "cli_smb2_fnum.h"
#define PIPE_LANMAN "\\PIPE\\LANMAN"
@@ -751,6 +752,19 @@ NTSTATUS cli_setpathinfo_basic(struct cli_state *cli, const char *fname,
data_len = PTR_DIFF(p, data);
if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
DATA_BLOB in_data = data_blob_const(data, data_len);
/*
* Split out SMB2 here as we need to select
* the correct info type and level.
*/
return cli_smb2_setpathinfo(cli,
fname,
1, /* SMB2_SETINFO_FILE */
SMB_FILE_BASIC_INFORMATION - 1000,
&in_data);
}
return cli_setpathinfo(cli, SMB_FILE_BASIC_INFORMATION, fname,
(uint8_t *)data, data_len);
}