mirror of
https://github.com/samba-team/samba.git
synced 2025-09-23 01:44:20 +03:00
s3-libsmb: fail rename and replace inside cifs variant
Another refactoring step - fail request to rename and replace existing file from within the CIFS version, allowing the soon-to-be-added SMB version to succeed. Signed-off-by: Uri Simchoni <uri@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
committed by
Jeremy Allison
parent
3154c4cb70
commit
057aa39e6a
@@ -996,15 +996,18 @@ static struct tevent_req *cli_cifs_rename_send(TALLOC_CTX *mem_ctx,
|
|||||||
struct tevent_context *ev,
|
struct tevent_context *ev,
|
||||||
struct cli_state *cli,
|
struct cli_state *cli,
|
||||||
const char *fname_src,
|
const char *fname_src,
|
||||||
const char *fname_dst);
|
const char *fname_dst,
|
||||||
|
bool replace);
|
||||||
|
|
||||||
struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
|
struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
|
||||||
struct tevent_context *ev,
|
struct tevent_context *ev,
|
||||||
struct cli_state *cli,
|
struct cli_state *cli,
|
||||||
const char *fname_src,
|
const char *fname_src,
|
||||||
const char *fname_dst)
|
const char *fname_dst,
|
||||||
|
bool replace)
|
||||||
{
|
{
|
||||||
return cli_cifs_rename_send(mem_ctx, ev, cli, fname_src, fname_dst);
|
return cli_cifs_rename_send(mem_ctx, ev, cli, fname_src, fname_dst,
|
||||||
|
replace);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cli_cifs_rename_done(struct tevent_req *subreq);
|
static void cli_cifs_rename_done(struct tevent_req *subreq);
|
||||||
@@ -1017,7 +1020,8 @@ static struct tevent_req *cli_cifs_rename_send(TALLOC_CTX *mem_ctx,
|
|||||||
struct tevent_context *ev,
|
struct tevent_context *ev,
|
||||||
struct cli_state *cli,
|
struct cli_state *cli,
|
||||||
const char *fname_src,
|
const char *fname_src,
|
||||||
const char *fname_dst)
|
const char *fname_dst,
|
||||||
|
bool replace)
|
||||||
{
|
{
|
||||||
struct tevent_req *req = NULL, *subreq = NULL;
|
struct tevent_req *req = NULL, *subreq = NULL;
|
||||||
struct cli_cifs_rename_state *state = NULL;
|
struct cli_cifs_rename_state *state = NULL;
|
||||||
@@ -1030,6 +1034,14 @@ static struct tevent_req *cli_cifs_rename_send(TALLOC_CTX *mem_ctx,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (replace) {
|
||||||
|
/*
|
||||||
|
* CIFS doesn't support replace
|
||||||
|
*/
|
||||||
|
tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
|
||||||
|
return tevent_req_post(req, ev);
|
||||||
|
}
|
||||||
|
|
||||||
SSVAL(state->vwv+0, 0, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY);
|
SSVAL(state->vwv+0, 0, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY);
|
||||||
|
|
||||||
bytes = talloc_array(state, uint8_t, 1);
|
bytes = talloc_array(state, uint8_t, 1);
|
||||||
@@ -1113,21 +1125,13 @@ NTSTATUS cli_rename(struct cli_state *cli,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (replace) {
|
|
||||||
/*
|
|
||||||
* SMB1 doesn't support replace
|
|
||||||
*/
|
|
||||||
status = NT_STATUS_INVALID_PARAMETER;
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
ev = samba_tevent_context_init(frame);
|
ev = samba_tevent_context_init(frame);
|
||||||
if (ev == NULL) {
|
if (ev == NULL) {
|
||||||
status = NT_STATUS_NO_MEMORY;
|
status = NT_STATUS_NO_MEMORY;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
req = cli_rename_send(frame, ev, cli, fname_src, fname_dst);
|
req = cli_rename_send(frame, ev, cli, fname_src, fname_dst, replace);
|
||||||
if (req == NULL) {
|
if (req == NULL) {
|
||||||
status = NT_STATUS_NO_MEMORY;
|
status = NT_STATUS_NO_MEMORY;
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@@ -325,10 +325,11 @@ NTSTATUS cli_posix_chown(struct cli_state *cli,
|
|||||||
uid_t uid,
|
uid_t uid,
|
||||||
gid_t gid);
|
gid_t gid);
|
||||||
struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
|
struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
|
||||||
struct tevent_context *ev,
|
struct tevent_context *ev,
|
||||||
struct cli_state *cli,
|
struct cli_state *cli,
|
||||||
const char *fname_src,
|
const char *fname_src,
|
||||||
const char *fname_dst);
|
const char *fname_dst,
|
||||||
|
bool replace);
|
||||||
NTSTATUS cli_rename_recv(struct tevent_req *req);
|
NTSTATUS cli_rename_recv(struct tevent_req *req);
|
||||||
NTSTATUS cli_rename(struct cli_state *cli,
|
NTSTATUS cli_rename(struct cli_state *cli,
|
||||||
const char *fname_src,
|
const char *fname_src,
|
||||||
|
Reference in New Issue
Block a user