]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmb: Move cli_qpathinfo1() to torture3
authorVolker Lendecke <vl@samba.org>
Mon, 21 Aug 2023 10:59:10 +0000 (12:59 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 22 Aug 2023 16:45:31 +0000 (16:45 +0000)
It's only used there, and it clutters general code. Re-adding the
async flavor is trivial should it ever be required.

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

index e7a4a3232a892dadbb08f6b41fe7e1fb8ab3f785..688a8a14f5f6ed749a5165ef360476de309dc1f6 100644 (file)
@@ -552,137 +552,6 @@ done:
        return (cli->rap_error == 0);
 }
 
-/****************************************************************************
- Send a qpathinfo call.
-****************************************************************************/
-
-struct cli_qpathinfo1_state {
-       struct cli_state *cli;
-       uint32_t num_data;
-       uint8_t *data;
-};
-
-static void cli_qpathinfo1_done(struct tevent_req *subreq);
-
-struct tevent_req *cli_qpathinfo1_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_qpathinfo1_state *state = NULL;
-
-       req = tevent_req_create(mem_ctx, &state, struct cli_qpathinfo1_state);
-       if (req == NULL) {
-               return NULL;
-       }
-       state->cli = cli;
-       subreq = cli_qpathinfo_send(state, ev, cli, fname, SMB_INFO_STANDARD,
-                                   22, CLI_BUFFER_SIZE);
-       if (tevent_req_nomem(subreq, req)) {
-               return tevent_req_post(req, ev);
-       }
-       tevent_req_set_callback(subreq, cli_qpathinfo1_done, req);
-       return req;
-}
-
-static void cli_qpathinfo1_done(struct tevent_req *subreq)
-{
-       struct tevent_req *req = tevent_req_callback_data(
-               subreq, struct tevent_req);
-       struct cli_qpathinfo1_state *state = tevent_req_data(
-               req, struct cli_qpathinfo1_state);
-       NTSTATUS status;
-
-       status = cli_qpathinfo_recv(subreq, state, &state->data,
-                                   &state->num_data);
-       TALLOC_FREE(subreq);
-       if (!NT_STATUS_IS_OK(status)) {
-               tevent_req_nterror(req, status);
-               return;
-       }
-       tevent_req_done(req);
-}
-
-NTSTATUS cli_qpathinfo1_recv(struct tevent_req *req,
-                            time_t *change_time,
-                            time_t *access_time,
-                            time_t *write_time,
-                            off_t *size,
-                            uint32_t *pattr)
-{
-       struct cli_qpathinfo1_state *state = tevent_req_data(
-               req, struct cli_qpathinfo1_state);
-       NTSTATUS status;
-
-       time_t (*date_fn)(const void *buf, int serverzone);
-
-       if (tevent_req_is_nterror(req, &status)) {
-               return status;
-       }
-
-       if (state->cli->win95) {
-               date_fn = make_unix_date;
-       } else {
-               date_fn = make_unix_date2;
-       }
-
-       if (change_time) {
-               *change_time = date_fn(state->data+0, smb1cli_conn_server_time_zone(state->cli->conn));
-       }
-       if (access_time) {
-               *access_time = date_fn(state->data+4, smb1cli_conn_server_time_zone(state->cli->conn));
-       }
-       if (write_time) {
-               *write_time = date_fn(state->data+8, smb1cli_conn_server_time_zone(state->cli->conn));
-       }
-       if (size) {
-               *size = IVAL(state->data, 12);
-       }
-       if (pattr) {
-               *pattr = SVAL(state->data, l1_attrFile);
-       }
-       return NT_STATUS_OK;
-}
-
-NTSTATUS cli_qpathinfo1(struct cli_state *cli,
-                       const char *fname,
-                       time_t *change_time,
-                       time_t *access_time,
-                       time_t *write_time,
-                       off_t *size,
-                       uint32_t *pattr)
-{
-       TALLOC_CTX *frame = talloc_stackframe();
-       struct tevent_context *ev;
-       struct tevent_req *req;
-       NTSTATUS status = NT_STATUS_NO_MEMORY;
-
-       if (smbXcli_conn_has_async_calls(cli->conn)) {
-               /*
-                * Can't use sync call while an async call is in flight
-                */
-               status = NT_STATUS_INVALID_PARAMETER;
-               goto fail;
-       }
-       ev = samba_tevent_context_init(frame);
-       if (ev == NULL) {
-               goto fail;
-       }
-       req = cli_qpathinfo1_send(frame, ev, cli, fname);
-       if (req == NULL) {
-               goto fail;
-       }
-       if (!tevent_req_poll_ntstatus(req, ev, &status)) {
-               goto fail;
-       }
-       status = cli_qpathinfo1_recv(req, change_time, access_time,
-                                    write_time, size, pattr);
- fail:
-       TALLOC_FREE(frame);
-       return status;
-}
-
 static void prep_basic_information_buf(
        uint8_t buf[40],
        struct timespec create_time,
index c54df3ffe3759f477ac273d0893b4a6b05798b22..8f351e42ff2af8cf0df1b361b9f5bf1c9bbad3da 100644 (file)
@@ -40,23 +40,6 @@ bool cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32_t stype,
                       void *state);
 bool cli_oem_change_password(struct cli_state *cli, const char *user, const char *new_password,
                              const char *old_password);
-struct tevent_req *cli_qpathinfo1_send(TALLOC_CTX *mem_ctx,
-                                      struct tevent_context *ev,
-                                      struct cli_state *cli,
-                                      const char *fname);
-NTSTATUS cli_qpathinfo1_recv(struct tevent_req *req,
-                            time_t *change_time,
-                            time_t *access_time,
-                            time_t *write_time,
-                            off_t *size,
-                            uint32_t *pattr);
-NTSTATUS cli_qpathinfo1(struct cli_state *cli,
-                       const char *fname,
-                       time_t *change_time,
-                       time_t *access_time,
-                       time_t *write_time,
-                       off_t *size,
-                       uint32_t *pattr);
 NTSTATUS cli_setpathinfo_ext(struct cli_state *cli, const char *fname,
                             struct timespec create_time,
                             struct timespec access_time,
index 93d0727e93615bfdcde781ea453226ea90101e70..071e0d451031f53dc8da4004608717137123e856 100644 (file)
@@ -76,6 +76,14 @@ NTSTATUS torture_setup_unix_extensions(struct cli_state *cli);
 void torture_conn_set_sockopt(struct cli_state *cli);
 void torture_deltree(struct cli_state *cli, const char *dname);
 
+NTSTATUS cli_qpathinfo1(struct cli_state *cli,
+                       const char *fname,
+                       time_t *change_time,
+                       time_t *access_time,
+                       time_t *write_time,
+                       off_t *size,
+                       uint32_t *pattr);
+
 /* The following definitions come from torture/utable.c  */
 
 bool torture_utable(int dummy);
index 6904e07f4e4317d63537c7f38f60ad1a51a6c140..62b27d7437ba1cbd773ed35519eff1b26c19fcfc 100644 (file)
@@ -656,6 +656,54 @@ static bool check_error(int line, NTSTATUS status,
        return True;
 }
 
+NTSTATUS cli_qpathinfo1(struct cli_state *cli,
+                       const char *fname,
+                       time_t *change_time,
+                       time_t *access_time,
+                       time_t *write_time,
+                       off_t *size,
+                       uint32_t *pattr)
+{
+       int timezone = smb1cli_conn_server_time_zone(cli->conn);
+       time_t (*date_fn)(const void *buf, int serverzone) = NULL;
+       uint8_t *rdata = NULL;
+       uint32_t num_rdata;
+       NTSTATUS status;
+
+       status = cli_qpathinfo(talloc_tos(),
+                              cli,
+                              fname,
+                              SMB_INFO_STANDARD,
+                              22,
+                              CLI_BUFFER_SIZE,
+                              &rdata,
+                              &num_rdata);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+       if (cli->win95) {
+               date_fn = make_unix_date;
+       } else {
+               date_fn = make_unix_date2;
+       }
+
+       if (change_time) {
+               *change_time = date_fn(rdata + 0, timezone);
+       }
+       if (access_time) {
+               *access_time = date_fn(rdata + 4, timezone);
+       }
+       if (write_time) {
+               *write_time = date_fn(rdata + 8, timezone);
+       }
+       if (size) {
+               *size = PULL_LE_U32(rdata, 12);
+       }
+       if (pattr) {
+               *pattr = PULL_LE_U16(rdata, l1_attrFile);
+       }
+       return NT_STATUS_OK;
+}
 
 static bool wait_lock(struct cli_state *c, int fnum, uint32_t offset, uint32_t len)
 {