mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
Make processing of incoming stream rename paths common between reply_mv and ntrename. Ensure we don't depend on "./" in the streams module.
This commit is contained in:
parent
330b922bd6
commit
bb54f72b94
@ -661,7 +661,6 @@ static int streams_depot_rename(vfs_handle_struct *handle,
|
||||
{
|
||||
struct smb_filename *smb_fname_src_stream = NULL;
|
||||
struct smb_filename *smb_fname_dst_stream = NULL;
|
||||
struct smb_filename *smb_fname_dst_mod = NULL;
|
||||
bool src_is_stream, dst_is_stream;
|
||||
NTSTATUS status;
|
||||
int ret = -1;
|
||||
@ -692,23 +691,7 @@ static int streams_depot_rename(vfs_handle_struct *handle,
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle passing in a stream name without the base file. This is
|
||||
* exercised by the NTRENAME streams rename path.
|
||||
*/
|
||||
if (StrCaseCmp(smb_fname_dst->base_name, "./") == 0) {
|
||||
status = create_synthetic_smb_fname(talloc_tos(),
|
||||
smb_fname_src->base_name,
|
||||
smb_fname_dst->stream_name,
|
||||
NULL, &smb_fname_dst_mod);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
errno = map_errno_from_nt_status(status);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
status = stream_smb_fname(handle, (smb_fname_dst_mod ?
|
||||
smb_fname_dst_mod : smb_fname_dst),
|
||||
status = stream_smb_fname(handle, smb_fname_dst,
|
||||
&smb_fname_dst_stream, false);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
errno = map_errno_from_nt_status(status);
|
||||
@ -721,7 +704,6 @@ static int streams_depot_rename(vfs_handle_struct *handle,
|
||||
done:
|
||||
TALLOC_FREE(smb_fname_src_stream);
|
||||
TALLOC_FREE(smb_fname_dst_stream);
|
||||
TALLOC_FREE(smb_fname_dst_mod);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1495,6 +1495,7 @@ void reply_ntrename(struct smb_request *req)
|
||||
uint32_t ucf_flags_dst = 0;
|
||||
uint16 rename_type;
|
||||
TALLOC_CTX *ctx = talloc_tos();
|
||||
bool stream_rename = false;
|
||||
|
||||
START_PROFILE(SMBntrename);
|
||||
|
||||
@ -1527,10 +1528,16 @@ void reply_ntrename(struct smb_request *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* The newname must begin with a ':' if the oldname contains a ':'. */
|
||||
if (strchr_m(oldname, ':') && (newname[0] != ':')) {
|
||||
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
|
||||
goto out;
|
||||
if (!lp_posix_pathnames()) {
|
||||
/* The newname must begin with a ':' if the
|
||||
oldname contains a ':'. */
|
||||
if (strchr_m(oldname, ':')) {
|
||||
if (newname[0] != ':') {
|
||||
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
|
||||
goto out;
|
||||
}
|
||||
stream_rename = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1579,6 +1586,17 @@ void reply_ntrename(struct smb_request *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (stream_rename) {
|
||||
/* smb_fname_new must be the same as smb_fname_old. */
|
||||
TALLOC_FREE(smb_fname_new->base_name);
|
||||
smb_fname_new->base_name = talloc_strdup(smb_fname_new,
|
||||
smb_fname_old->base_name);
|
||||
if (!smb_fname_new->base_name) {
|
||||
reply_nterror(req, NT_STATUS_NO_MEMORY);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG(3,("reply_ntrename: %s -> %s\n",
|
||||
smb_fname_str_dbg(smb_fname_old),
|
||||
smb_fname_str_dbg(smb_fname_new)));
|
||||
|
@ -6532,6 +6532,7 @@ void reply_mv(struct smb_request *req)
|
||||
TALLOC_CTX *ctx = talloc_tos();
|
||||
struct smb_filename *smb_fname_src = NULL;
|
||||
struct smb_filename *smb_fname_dst = NULL;
|
||||
bool stream_rename = false;
|
||||
|
||||
START_PROFILE(SMBmv);
|
||||
|
||||
@ -6557,6 +6558,18 @@ void reply_mv(struct smb_request *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!lp_posix_pathnames()) {
|
||||
/* The newname must begin with a ':' if the
|
||||
name contains a ':'. */
|
||||
if (strchr_m(name, ':')) {
|
||||
if (newname[0] != ':') {
|
||||
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
|
||||
goto out;
|
||||
}
|
||||
stream_rename = true;
|
||||
}
|
||||
}
|
||||
|
||||
status = filename_convert(ctx,
|
||||
conn,
|
||||
req->flags2 & FLAGS2_DFS_PATHNAMES,
|
||||
@ -6593,6 +6606,18 @@ void reply_mv(struct smb_request *req)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (stream_rename) {
|
||||
/* smb_fname_dst->base_name must be the same as
|
||||
smb_fname_src->base_name. */
|
||||
TALLOC_FREE(smb_fname_dst->base_name);
|
||||
smb_fname_dst->base_name = talloc_strdup(smb_fname_dst,
|
||||
smb_fname_src->base_name);
|
||||
if (!smb_fname_dst->base_name) {
|
||||
reply_nterror(req, NT_STATUS_NO_MEMORY);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG(3,("reply_mv : %s -> %s\n", smb_fname_str_dbg(smb_fname_src),
|
||||
smb_fname_str_dbg(smb_fname_dst)));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user