]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmb: Add "in_cblobs" to cli_smb2_unlink
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 unlink 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 1ba95bb0760c22e837cd071d7cab986f35d6ff55..76eec6b3a0b013e95896b44af6faf51181147766 100644 (file)
@@ -923,6 +923,7 @@ struct cli_smb2_unlink_state {
        struct tevent_context *ev;
        struct cli_state *cli;
        const char *fname;
+       const struct smb2_create_blobs *in_cblobs;
 };
 
 static void cli_smb2_unlink_opened1(struct tevent_req *subreq);
@@ -933,7 +934,8 @@ struct tevent_req *cli_smb2_unlink_send(
        TALLOC_CTX *mem_ctx,
        struct tevent_context *ev,
        struct cli_state *cli,
-       const char *fname)
+       const char *fname,
+       const struct smb2_create_blobs *in_cblobs)
 {
        struct tevent_req *req = NULL, *subreq = NULL;
        struct cli_smb2_unlink_state *state = NULL;
@@ -945,6 +947,7 @@ struct tevent_req *cli_smb2_unlink_send(
        state->ev = ev;
        state->cli = cli;
        state->fname = fname;
+       state->in_cblobs = in_cblobs;
 
        if (smbXcli_conn_protocol(cli->conn) < PROTOCOL_SMB2_02) {
                tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
@@ -965,7 +968,7 @@ struct tevent_req *cli_smb2_unlink_send(
                FILE_SHARE_DELETE, /* share_access */
                FILE_OPEN,              /* create_disposition */
                FILE_DELETE_ON_CLOSE,   /* create_options */
-               NULL);                  /* in_cblobs */
+               state->in_cblobs);      /* in_cblobs */
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
@@ -1007,7 +1010,7 @@ static void cli_smb2_unlink_opened1(struct tevent_req *subreq)
                        FILE_OPEN,              /* create_disposition */
                        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;
                }
@@ -1059,7 +1062,10 @@ NTSTATUS cli_smb2_unlink_recv(struct tevent_req *req)
        return tevent_req_simple_recv_ntstatus(req);
 }
 
-NTSTATUS cli_smb2_unlink(struct cli_state *cli, const char *fname)
+NTSTATUS cli_smb2_unlink(
+       struct cli_state *cli,
+       const char *fname,
+       const struct smb2_create_blobs *in_cblobs)
 {
        TALLOC_CTX *frame = talloc_stackframe();
        struct tevent_context *ev;
@@ -1078,7 +1084,7 @@ NTSTATUS cli_smb2_unlink(struct cli_state *cli, const char *fname)
        if (ev == NULL) {
                goto fail;
        }
-       req = cli_smb2_unlink_send(frame, ev, cli, fname);
+       req = cli_smb2_unlink_send(frame, ev, cli, fname, in_cblobs);
        if (req == NULL) {
                goto fail;
        }
index 9a7b31abc0083307e6167ef10a13bbfe683b5b12..c39c8e9098329b5b8d321e75097f085313c6773b 100644 (file)
@@ -89,9 +89,13 @@ struct tevent_req *cli_smb2_unlink_send(
        TALLOC_CTX *mem_ctx,
        struct tevent_context *ev,
        struct cli_state *cli,
-       const char *fname);
+       const char *fname,
+       const struct smb2_create_blobs *in_cblobs);
 NTSTATUS cli_smb2_unlink_recv(struct tevent_req *req);
-NTSTATUS cli_smb2_unlink(struct cli_state *cli,const char *fname);
+NTSTATUS cli_smb2_unlink(
+       struct cli_state *cli,
+       const char *fname,
+       const struct smb2_create_blobs *in_cblobs);
 NTSTATUS cli_smb2_list(struct cli_state *cli,
                        const char *pathname,
                        uint16_t attribute,
index 695ab5e5d8498a31d7c8c18db11df0bb4b11f29d..501b7d9b4eff603d6775a36d7d84b0434c9cbefe 100644 (file)
@@ -1528,7 +1528,7 @@ NTSTATUS cli_unlink(struct cli_state *cli, const char *fname, uint16_t mayhave_a
        NTSTATUS status = NT_STATUS_OK;
 
        if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
-               return cli_smb2_unlink(cli, fname);
+               return cli_smb2_unlink(cli, fname, NULL);
        }
 
        frame = talloc_stackframe();