mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
s3: libsmb: For SMB2 opens on a DFS share, convert to a DFS path if not already done.
Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Noel Power <npower@samba.org>
This commit is contained in:
parent
26b4a6951b
commit
dd9cdfb3b1
@ -153,6 +153,42 @@ static uint8_t flags_to_smb2_oplock(uint32_t create_flags)
|
||||
return SMB2_OPLOCK_LEVEL_NONE;
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
If we're on a DFS share, ensure we convert to a full DFS path
|
||||
if this hasn't already been done.
|
||||
***************************************************************/
|
||||
|
||||
static const char *smb2_dfs_share_path(TALLOC_CTX *ctx,
|
||||
struct cli_state *cli,
|
||||
const char *path)
|
||||
{
|
||||
bool is_dfs = smbXcli_conn_dfs_supported(cli->conn) &&
|
||||
smbXcli_tcon_is_dfs_share(cli->smb2.tcon);
|
||||
bool is_already_dfs_path = false;
|
||||
|
||||
if (!is_dfs) {
|
||||
return path;
|
||||
}
|
||||
is_already_dfs_path = cli_dfs_is_already_full_path(cli, path);
|
||||
if (is_already_dfs_path) {
|
||||
return path;
|
||||
}
|
||||
if (path[0] == '\0') {
|
||||
return talloc_asprintf(ctx,
|
||||
"%s\\%s",
|
||||
smbXcli_conn_remote_name(cli->conn),
|
||||
cli->share);
|
||||
}
|
||||
while (*path == '\\') {
|
||||
path++;
|
||||
}
|
||||
return talloc_asprintf(ctx,
|
||||
"%s\\%s\\%s",
|
||||
smbXcli_conn_remote_name(cli->conn),
|
||||
cli->share,
|
||||
path);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
Small wrapper that allows SMB2 create to return a uint16_t fnum.
|
||||
***************************************************************/
|
||||
@ -254,6 +290,11 @@ struct tevent_req *cli_smb2_create_fnum_send(
|
||||
}
|
||||
}
|
||||
|
||||
fname = smb2_dfs_share_path(state, cli, fname);
|
||||
if (tevent_req_nomem(fname, req)) {
|
||||
return tevent_req_post(req, ev);
|
||||
}
|
||||
|
||||
/* SMB2 is pickier about pathnames. Ensure it doesn't
|
||||
start in a '\' */
|
||||
if (*fname == '\\') {
|
||||
|
Loading…
Reference in New Issue
Block a user