summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorUri Simchoni <uri@samba.org>2017-03-26 09:14:43 +0300
committerJeremy Allison <jra@samba.org>2017-03-28 17:45:19 +0200
commit057aa39e6abea241a3785458460eaef8c30f8659 (patch)
treeea105b67a0c31d143724e1bcd2b90bb493e0f5ed /source3
parent3154c4cb701950d777766bbef1410182bb2569c4 (diff)
downloadsamba-057aa39e6abea241a3785458460eaef8c30f8659.tar.gz
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>
Diffstat (limited to 'source3')
-rw-r--r--source3/libsmb/clifile.c30
-rw-r--r--source3/libsmb/proto.h9
2 files changed, 22 insertions, 17 deletions
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index b5f29b62984..44fde38bc3a 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -996,15 +996,18 @@ static struct tevent_req *cli_cifs_rename_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct cli_state *cli,
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_context *ev,
struct cli_state *cli,
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);
@@ -1017,7 +1020,8 @@ static struct tevent_req *cli_cifs_rename_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct cli_state *cli,
const char *fname_src,
- const char *fname_dst)
+ const char *fname_dst,
+ bool replace)
{
struct tevent_req *req = NULL, *subreq = 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;
}
+ 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);
bytes = talloc_array(state, uint8_t, 1);
@@ -1113,21 +1125,13 @@ NTSTATUS cli_rename(struct cli_state *cli,
goto fail;
}
- if (replace) {
- /*
- * SMB1 doesn't support replace
- */
- status = NT_STATUS_INVALID_PARAMETER;
- goto fail;
- }
-
ev = samba_tevent_context_init(frame);
if (ev == NULL) {
status = NT_STATUS_NO_MEMORY;
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) {
status = NT_STATUS_NO_MEMORY;
goto fail;
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index 57a45e3f363..b453733fbdd 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -325,10 +325,11 @@ NTSTATUS cli_posix_chown(struct cli_state *cli,
uid_t uid,
gid_t gid);
struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct cli_state *cli,
- const char *fname_src,
- const char *fname_dst);
+ struct tevent_context *ev,
+ struct cli_state *cli,
+ const char *fname_src,
+ const char *fname_dst,
+ bool replace);
NTSTATUS cli_rename_recv(struct tevent_req *req);
NTSTATUS cli_rename(struct cli_state *cli,
const char *fname_src,