]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmb: Use cli_smb2_qpathinfo() in cli_qpathinfo2()
authorVolker Lendecke <vl@samba.org>
Fri, 18 Aug 2023 14:07:56 +0000 (16:07 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 22 Aug 2023 16:45:31 +0000 (16:45 +0000)
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/clirap.c

index 14fa8ae2708327e0b2f61cd27f3087d0cf487aa6..76eeaff42b3df7ec6a9673d2ecb6844aca7d2110 100644 (file)
@@ -2451,166 +2451,6 @@ NTSTATUS cli_smb2_getatr(struct cli_state *cli,
        return status;
 }
 
-struct cli_smb2_qpathinfo2_state {
-       struct tevent_context *ev;
-       struct cli_state *cli;
-       uint16_t fnum;
-
-       NTSTATUS queryinfo_status;
-       struct timespec create_time;
-       struct timespec access_time;
-       struct timespec write_time;
-       struct timespec change_time;
-       off_t size;
-       uint32_t attr;
-       SMB_INO_T ino;
-};
-
-static void cli_smb2_qpathinfo2_opened(struct tevent_req *subreq);
-static void cli_smb2_qpathinfo2_done(struct tevent_req *subreq);
-static void cli_smb2_qpathinfo2_closed(struct tevent_req *subreq);
-
-struct tevent_req *cli_smb2_qpathinfo2_send(TALLOC_CTX *mem_ctx,
-                                           struct tevent_context *ev,
-                                           struct cli_state *cli,
-                                           const char *fname)
-{
-       struct tevent_req *req = NULL, *subreq = NULL;
-       struct cli_smb2_qpathinfo2_state *state = NULL;
-
-       req = tevent_req_create(mem_ctx,
-                               &state,
-                               struct cli_smb2_qpathinfo2_state);
-       if (req == NULL) {
-               return NULL;
-       }
-       state->ev = ev;
-       state->cli = cli;
-
-       subreq = get_fnum_from_path_send(mem_ctx,
-                                        ev,
-                                        cli,
-                                        fname,
-                                        FILE_READ_ATTRIBUTES);
-       if (tevent_req_nomem(subreq, req)) {
-               return tevent_req_post(req, ev);
-       }
-       tevent_req_set_callback(subreq, cli_smb2_qpathinfo2_opened, req);
-       return req;
-}
-
-static void cli_smb2_qpathinfo2_opened(struct tevent_req *subreq)
-{
-       struct tevent_req *req =
-               tevent_req_callback_data(subreq, struct tevent_req);
-       struct cli_smb2_qpathinfo2_state *state =
-               tevent_req_data(req, struct cli_smb2_qpathinfo2_state);
-       NTSTATUS status;
-
-       status = get_fnum_from_path_recv(subreq, &state->fnum);
-       TALLOC_FREE(subreq);
-       if (tevent_req_nterror(req, status)) {
-               return;
-       }
-
-       subreq = cli_qfileinfo_basic_send(state,
-                                         state->ev,
-                                         state->cli,
-                                         state->fnum);
-       if (tevent_req_nomem(subreq, req)) {
-               return;
-       }
-       tevent_req_set_callback(subreq, cli_smb2_qpathinfo2_done, req);
-}
-
-static void cli_smb2_qpathinfo2_done(struct tevent_req *subreq)
-{
-       struct tevent_req *req =
-               tevent_req_callback_data(subreq, struct tevent_req);
-       struct cli_smb2_qpathinfo2_state *state =
-               tevent_req_data(req, struct cli_smb2_qpathinfo2_state);
-
-       state->queryinfo_status = cli_qfileinfo_basic_recv(subreq,
-                                                          &state->attr,
-                                                          &state->size,
-                                                          &state->create_time,
-                                                          &state->access_time,
-                                                          &state->write_time,
-                                                          &state->change_time,
-                                                          &state->ino);
-       TALLOC_FREE(subreq);
-
-       subreq = cli_smb2_close_fnum_send(state,
-                                         state->ev,
-                                         state->cli,
-                                         state->fnum);
-       if (tevent_req_nomem(subreq, req)) {
-               return;
-       }
-       tevent_req_set_callback(subreq, cli_smb2_qpathinfo2_closed, req);
-}
-
-static void cli_smb2_qpathinfo2_closed(struct tevent_req *subreq)
-{
-       struct tevent_req *req =
-               tevent_req_callback_data(subreq, struct tevent_req);
-       struct cli_smb2_qpathinfo2_state *state =
-               tevent_req_data(req, struct cli_smb2_qpathinfo2_state);
-       NTSTATUS status;
-
-       status = cli_smb2_close_fnum_recv(subreq);
-       TALLOC_FREE(subreq);
-       if (tevent_req_nterror(req, status)) {
-               return;
-       }
-       if (tevent_req_nterror(req, state->queryinfo_status)) {
-               return;
-       }
-       tevent_req_done(req);
-}
-
-NTSTATUS cli_smb2_qpathinfo2_recv(struct tevent_req *req,
-                                 struct timespec *create_time,
-                                 struct timespec *access_time,
-                                 struct timespec *write_time,
-                                 struct timespec *change_time,
-                                 off_t *size,
-                                 uint32_t *attr,
-                                 SMB_INO_T *ino)
-{
-       struct cli_smb2_qpathinfo2_state *state =
-               tevent_req_data(req, struct cli_smb2_qpathinfo2_state);
-       NTSTATUS status;
-
-       if (tevent_req_is_nterror(req, &status)) {
-               return status;
-       }
-
-       if (create_time != NULL) {
-               *create_time = state->create_time;
-       }
-       if (access_time != NULL) {
-               *access_time = state->access_time;
-       }
-       if (write_time != NULL) {
-               *write_time = state->write_time;
-       }
-       if (change_time != NULL) {
-               *change_time = state->change_time;
-       }
-       if (attr != NULL) {
-               *attr = state->attr;
-       }
-       if (size != NULL) {
-               *size = state->size;
-       }
-       if (ino) {
-               *ino = state->ino;
-       }
-
-       return NT_STATUS_OK;
-}
-
 /***************************************************************
  Wrapper that allows SMB2 to set SMB_FILE_BASIC_INFORMATION on
  a pathname.
index 1068165dcdb934e425df5f73b83dfe61b5528bf7..ed8da5b9c33d18ed8ee547c639aed94e6602f354 100644 (file)
@@ -175,18 +175,6 @@ NTSTATUS cli_smb2_getatr(struct cli_state *cli,
                        uint32_t *pattr,
                        off_t *size,
                        time_t *write_time);
-struct tevent_req *cli_smb2_qpathinfo2_send(TALLOC_CTX *mem_ctx,
-                                           struct tevent_context *ev,
-                                           struct cli_state *cli,
-                                           const char *fname);
-NTSTATUS cli_smb2_qpathinfo2_recv(struct tevent_req *req,
-                                 struct timespec *create_time,
-                                 struct timespec *access_time,
-                                 struct timespec *write_time,
-                                 struct timespec *change_time,
-                                 off_t *size,
-                                 uint32_t *attr,
-                                 SMB_INO_T *ino);
 NTSTATUS cli_smb2_setpathinfo(struct cli_state *cli,
                        const char *name,
                        uint8_t in_info_type,
index ebe97d8c0e5cb1c44988a492186fa1accc895271..e7a4a3232a892dadbb08f6b41fe7e1fb8ab3f785 100644 (file)
@@ -933,7 +933,13 @@ struct tevent_req *cli_qpathinfo2_send(TALLOC_CTX *mem_ctx,
                return NULL;
        }
        if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
-               subreq = cli_smb2_qpathinfo2_send(state, ev, cli, fname);
+               subreq = cli_smb2_qpathinfo_send(state,
+                                                ev,
+                                                cli,
+                                                fname,
+                                                FSCC_FILE_ALL_INFORMATION,
+                                                0x60,
+                                                UINT16_MAX);
                if (tevent_req_nomem(subreq, req)) {
                        return tevent_req_post(req, ev);
                }
@@ -956,20 +962,23 @@ static void cli_qpathinfo2_done2(struct tevent_req *subreq)
                tevent_req_callback_data(subreq, struct tevent_req);
        struct cli_qpathinfo2_state *state =
                tevent_req_data(req, struct cli_qpathinfo2_state);
+       uint8_t *rdata = NULL;
+       uint32_t num_rdata;
        NTSTATUS status;
 
-       status = cli_smb2_qpathinfo2_recv(subreq,
-                                         &state->create_time,
-                                         &state->access_time,
-                                         &state->write_time,
-                                         &state->change_time,
-                                         &state->size,
-                                         &state->attr,
-                                         &state->ino);
+       status = cli_smb2_qpathinfo_recv(subreq, state, &rdata, &num_rdata);
        TALLOC_FREE(subreq);
        if (tevent_req_nterror(req, status)) {
                return;
        }
+       state->create_time = interpret_long_date((const char *)rdata + 0x0);
+       state->access_time = interpret_long_date((const char *)rdata + 0x8);
+       state->write_time = interpret_long_date((const char *)rdata + 0x10);
+       state->change_time = interpret_long_date((const char *)rdata + 0x18);
+       state->attr = PULL_LE_U32(rdata, 0x20);
+       state->size = PULL_LE_U64(rdata, 0x30);
+       state->ino = PULL_LE_U64(rdata, 0x40);
+
        tevent_req_done(req);
 }