]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmb: Make cli_rename_send()/recv() smb2-capable
authorVolker Lendecke <vl@samba.org>
Fri, 13 Nov 2020 15:29:23 +0000 (16:29 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 16 Nov 2020 19:53:46 +0000 (19:53 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/clifile.c

index ee0b80ee37849fa645af1516f9a4b6087b4d42a1..c619b009ec4732f41072fb5a35cc237f24002428 100644 (file)
@@ -1383,6 +1383,7 @@ struct cli_rename_state {
 
 static void cli_rename_done1(struct tevent_req *subreq);
 static void cli_rename_done_cifs(struct tevent_req *subreq);
+static void cli_rename_done2(struct tevent_req *subreq);
 
 struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
                                   struct tevent_context *ev,
@@ -1399,6 +1400,16 @@ struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
+       if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
+               subreq = cli_smb2_rename_send(
+                       state, ev, cli, fname_src, fname_dst, replace);
+               if (tevent_req_nomem(subreq, req)) {
+                       return tevent_req_post(req, ev);
+               }
+               tevent_req_set_callback(subreq, cli_rename_done2, req);
+               return req;
+       }
+
        if (replace && smbXcli_conn_support_passthrough(cli->conn)) {
                subreq = cli_smb1_rename_send(
                        state, ev, cli, fname_src, fname_dst, replace);
@@ -1430,6 +1441,12 @@ static void cli_rename_done_cifs(struct tevent_req *subreq)
        tevent_req_simple_finish_ntstatus(subreq, status);
 }
 
+static void cli_rename_done2(struct tevent_req *subreq)
+{
+       NTSTATUS status = cli_smb2_rename_recv(subreq);
+       tevent_req_simple_finish_ntstatus(subreq, status);
+}
+
 NTSTATUS cli_rename_recv(struct tevent_req *req)
 {
        return tevent_req_simple_recv_ntstatus(req);
@@ -1445,10 +1462,6 @@ NTSTATUS cli_rename(struct cli_state *cli,
        struct tevent_req *req;
        NTSTATUS status = NT_STATUS_OK;
 
-       if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
-               return cli_smb2_rename(cli, fname_src, fname_dst, replace);
-       }
-
        frame = talloc_stackframe();
 
        if (smbXcli_conn_has_async_calls(cli->conn)) {