s3-libsmb: fail rename and replace inside cifs variant
authorUri Simchoni <uri@samba.org>
Sun, 26 Mar 2017 06:14:43 +0000 (09:14 +0300)
committerJeremy Allison <jra@samba.org>
Tue, 28 Mar 2017 15:45:19 +0000 (17:45 +0200)
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>
source3/libsmb/clifile.c
source3/libsmb/proto.h

index b5f29b62984d40d72d27bf0508eede9ab258e640..44fde38bc3aa8b745c6cf161b4b37294e01bc97b 100644 (file)
@@ -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;
index 57a45e3f3633c814d2595398d1cdf5ccb268c8e8..b453733fbdd5a5a702b864ee73f944d30b9be85b 100644 (file)
@@ -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,