]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmb: Add "in_cblobs" to cli_smb2_rmdir
authorVolker Lendecke <vl@samba.org>
Mon, 4 Mar 2019 19:40:14 +0000 (20:40 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 8 Mar 2019 18:20:10 +0000 (18:20 +0000)
This reveals the fact that rmdir is an open/close in smb2 through the
API. This is not nice, but it's an internal API with currently only
one user. And it enables posix semantics for the open easily.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/cli_smb2_fnum.c
source3/libsmb/cli_smb2_fnum.h
source3/libsmb/clifile.c

index 12f36d9b0923292dc2724feed8713af413e9c823..1ba95bb0760c22e837cd071d7cab986f35d6ff55 100644 (file)
@@ -707,6 +707,7 @@ struct cli_smb2_rmdir_state {
        struct tevent_context *ev;
        struct cli_state *cli;
        const char *dname;
+       const struct smb2_create_blobs *in_cblobs;
        uint16_t fnum;
        NTSTATUS status;
 };
@@ -716,10 +717,12 @@ static void cli_smb2_rmdir_opened2(struct tevent_req *subreq);
 static void cli_smb2_rmdir_disp_set(struct tevent_req *subreq);
 static void cli_smb2_rmdir_closed(struct tevent_req *subreq);
 
-struct tevent_req *cli_smb2_rmdir_send(TALLOC_CTX *mem_ctx,
-                                      struct tevent_context *ev,
-                                      struct cli_state *cli,
-                                      const char *dname)
+struct tevent_req *cli_smb2_rmdir_send(
+       TALLOC_CTX *mem_ctx,
+       struct tevent_context *ev,
+       struct cli_state *cli,
+       const char *dname,
+       const struct smb2_create_blobs *in_cblobs)
 {
        struct tevent_req *req = NULL, *subreq = NULL;
        struct cli_smb2_rmdir_state *state = NULL;
@@ -731,6 +734,7 @@ struct tevent_req *cli_smb2_rmdir_send(TALLOC_CTX *mem_ctx,
        state->ev = ev;
        state->cli = cli;
        state->dname = dname;
+       state->in_cblobs = in_cblobs;
 
        if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) {
                tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
@@ -749,7 +753,7 @@ struct tevent_req *cli_smb2_rmdir_send(TALLOC_CTX *mem_ctx,
                FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */
                FILE_OPEN,              /* create_disposition */
                FILE_DIRECTORY_FILE,    /* create_options */
-               NULL);                  /* in_cblobs */
+               state->in_cblobs);      /* in_cblobs */
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
@@ -790,7 +794,7 @@ static void cli_smb2_rmdir_opened1(struct tevent_req *subreq)
                        FILE_DIRECTORY_FILE|
                        FILE_DELETE_ON_CLOSE|
                        FILE_OPEN_REPARSE_POINT, /* create_options */
-                       NULL);                           /* in_cblobs */
+                       state->in_cblobs);       /* in_cblobs */
                if (tevent_req_nomem(subreq, req)) {
                        return;
                }
@@ -873,7 +877,10 @@ NTSTATUS cli_smb2_rmdir_recv(struct tevent_req *req)
        return state->status;
 }
 
-NTSTATUS cli_smb2_rmdir(struct cli_state *cli, const char *dname)
+NTSTATUS cli_smb2_rmdir(
+       struct cli_state *cli,
+       const char *dname,
+       const struct smb2_create_blobs *in_cblobs)
 {
        TALLOC_CTX *frame = talloc_stackframe();
        struct tevent_context *ev;
@@ -892,7 +899,7 @@ NTSTATUS cli_smb2_rmdir(struct cli_state *cli, const char *dname)
        if (ev == NULL) {
                goto fail;
        }
-       req = cli_smb2_rmdir_send(frame, ev, cli, dname);
+       req = cli_smb2_rmdir_send(frame, ev, cli, dname, in_cblobs);
        if (req == NULL) {
                goto fail;
        }
index 15a271d3655c8965abe5a2661e1387a3e380e9dc..9a7b31abc0083307e6167ef10a13bbfe683b5b12 100644 (file)
@@ -74,12 +74,17 @@ struct tevent_req *cli_smb2_delete_on_close_send(TALLOC_CTX *mem_ctx,
 NTSTATUS cli_smb2_delete_on_close_recv(struct tevent_req *req);
 NTSTATUS cli_smb2_delete_on_close(struct cli_state *cli, uint16_t fnum, bool flag);
 NTSTATUS cli_smb2_mkdir(struct cli_state *cli, const char *dirname);
-struct tevent_req *cli_smb2_rmdir_send(TALLOC_CTX *mem_ctx,
-                                      struct tevent_context *ev,
-                                      struct cli_state *cli,
-                                      const char *dname);
+struct tevent_req *cli_smb2_rmdir_send(
+       TALLOC_CTX *mem_ctx,
+       struct tevent_context *ev,
+       struct cli_state *cli,
+       const char *dname,
+       const struct smb2_create_blobs *in_cblobs);
 NTSTATUS cli_smb2_rmdir_recv(struct tevent_req *req);
-NTSTATUS cli_smb2_rmdir(struct cli_state *cli, const char *dirname);
+NTSTATUS cli_smb2_rmdir(
+       struct cli_state *cli,
+       const char *dname,
+       const struct smb2_create_blobs *in_cblobs);
 struct tevent_req *cli_smb2_unlink_send(
        TALLOC_CTX *mem_ctx,
        struct tevent_context *ev,
index 49e58c0d252acad6498e7abb6560dee98bae19e5..695ab5e5d8498a31d7c8c18db11df0bb4b11f29d 100644 (file)
@@ -1758,7 +1758,7 @@ NTSTATUS cli_rmdir(struct cli_state *cli, const char *dname)
        NTSTATUS status = NT_STATUS_OK;
 
        if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
-               return cli_smb2_rmdir(cli, dname);
+               return cli_smb2_rmdir(cli, dname, NULL);
        }
 
        frame = talloc_stackframe();