]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmb: Add async cli_smb2_chkpath_send/recv()
authorVolker Lendecke <vl@samba.org>
Tue, 26 May 2020 20:21:14 +0000 (22:21 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 28 May 2020 19:11:39 +0000 (19:11 +0000)
Not converting the sync version to use it, it will go away very soon

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

index 40a4c82708e4704e1b6b4a6548429b3c11b2f2b3..be610a390aa2aedc55318786d451b93f3a105a89 100644 (file)
@@ -1540,6 +1540,87 @@ NTSTATUS cli_smb2_qpathinfo_basic(struct cli_state *cli,
        return status;
 }
 
+struct cli_smb2_chkpath_state {
+       struct tevent_context *ev;
+       struct cli_state *cli;
+};
+
+static void cli_smb2_chkpath_opened(struct tevent_req *subreq);
+static void cli_smb2_chkpath_closed(struct tevent_req *subreq);
+
+struct tevent_req *cli_smb2_chkpath_send(
+       TALLOC_CTX *mem_ctx,
+       struct tevent_context *ev,
+       struct cli_state *cli,
+       const char *name)
+{
+       struct tevent_req *req = NULL, *subreq = NULL;
+       struct cli_smb2_chkpath_state *state = NULL;
+
+       req = tevent_req_create(
+               mem_ctx, &state, struct cli_smb2_chkpath_state);
+       if (req == NULL) {
+               return NULL;
+       }
+       state->ev = ev;
+       state->cli = cli;
+
+       /* Ensure this is a directory. */
+       subreq = cli_smb2_create_fnum_send(
+               state,                             /* mem_ctx */
+               ev,                                /* ev */
+               cli,                               /* cli */
+               name,                              /* fname */
+               0,                                 /* create_flags */
+               SMB2_IMPERSONATION_IMPERSONATION,  /* impersonation_level */
+               FILE_READ_ATTRIBUTES,              /* desired_access */
+               FILE_ATTRIBUTE_DIRECTORY,          /* file_attributes */
+               FILE_SHARE_READ|
+               FILE_SHARE_WRITE|
+               FILE_SHARE_DELETE,                 /* share_access */
+               FILE_OPEN,                         /* create_disposition */
+               FILE_DIRECTORY_FILE,               /* create_options */
+               NULL);                             /* in_cblobs */
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq, cli_smb2_chkpath_opened, req);
+       return req;
+}
+
+static void cli_smb2_chkpath_opened(struct tevent_req *subreq)
+{
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+       struct cli_smb2_chkpath_state *state = tevent_req_data(
+               req, struct cli_smb2_chkpath_state);
+       NTSTATUS status;
+       uint16_t fnum;
+
+       status = cli_smb2_create_fnum_recv(subreq, &fnum, NULL, NULL, NULL);
+       TALLOC_FREE(subreq);
+       if (tevent_req_nterror(req, status)) {
+               return;
+       }
+
+       subreq = cli_smb2_close_fnum_send(state, state->ev, state->cli, fnum);
+       if (tevent_req_nomem(subreq, req)) {
+               return;
+       }
+       tevent_req_set_callback(subreq, cli_smb2_chkpath_closed, req);
+}
+
+static void cli_smb2_chkpath_closed(struct tevent_req *subreq)
+{
+       NTSTATUS status = cli_smb2_close_fnum_recv(subreq);
+       tevent_req_simple_finish_ntstatus(subreq, status);
+}
+
+NTSTATUS cli_smb2_chkpath_recv(struct tevent_req *req)
+{
+       return tevent_req_simple_recv_ntstatus(req);
+}
+
 /***************************************************************
  Wrapper that allows SMB2 to check if a path is a directory.
  Synchronous only.
index 78e219c923cf3fdc005be519ae1af20f86b1852e..61a17cd6a97989e6135bb07e49f1f3a07c3bffe5 100644 (file)
@@ -103,6 +103,12 @@ NTSTATUS cli_smb2_qpathinfo_basic(struct cli_state *cli,
 NTSTATUS cli_smb2_qpathinfo_alt_name(struct cli_state *cli,
                        const char *name,
                        fstring alt_name);
+struct tevent_req *cli_smb2_chkpath_send(
+       TALLOC_CTX *mem_ctx,
+       struct tevent_context *ev,
+       struct cli_state *cli,
+       const char *name);
+NTSTATUS cli_smb2_chkpath_recv(struct tevent_req *req);
 NTSTATUS cli_smb2_chkpath(struct cli_state *cli,
                        const char *name);
 struct tevent_req *cli_smb2_query_info_fnum_send(