s3/libsmb: Generalise cli_state in smb2 logoff calls
authorLuk Claes <luk@debian.org>
Thu, 10 May 2012 16:39:11 +0000 (18:39 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 11 May 2012 23:01:33 +0000 (01:01 +0200)
Signed-off-by: Luk Claes <luk@debian.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
source3/libsmb/smb2cli.h
source3/libsmb/smb2cli_session.c
source3/torture/test_smb2.c

index 6fa77f4ff3cdb5351a281c84b6621c51989b0a63..bd6b13166963dc55bac64865a90b48f6940cafaa 100644 (file)
@@ -26,9 +26,13 @@ struct cli_state;
 
 struct tevent_req *smb2cli_logoff_send(TALLOC_CTX *mem_ctx,
                                       struct tevent_context *ev,
-                                      struct cli_state *cli);
+                                      struct smbXcli_conn *conn,
+                                      uint32_t timeout_msec,
+                                      struct smbXcli_session *session);
 NTSTATUS smb2cli_logoff_recv(struct tevent_req *req);
-NTSTATUS smb2cli_logoff(struct cli_state *cli);
+NTSTATUS smb2cli_logoff(struct smbXcli_conn *conn,
+                       uint32_t timeout_msec,
+                       struct smbXcli_session *session);
 
 struct tevent_req *smb2cli_tcon_send(TALLOC_CTX *mem_ctx,
                                     struct tevent_context *ev,
index 0de82f6d83747e9c776cb6f78261c09e3ada8e25..077ba9a52eb706d18f1c5eced22106dd8490137a 100644 (file)
@@ -28,7 +28,6 @@
 #include "../auth/ntlmssp/ntlmssp.h"
 
 struct smb2cli_logoff_state {
-       struct cli_state *cli;
        uint8_t fixed[4];
 };
 
@@ -36,7 +35,9 @@ static void smb2cli_logoff_done(struct tevent_req *subreq);
 
 struct tevent_req *smb2cli_logoff_send(TALLOC_CTX *mem_ctx,
                                       struct tevent_context *ev,
-                                      struct cli_state *cli)
+                                      struct smbXcli_conn *conn,
+                                      uint32_t timeout_msec,
+                                      struct smbXcli_session *session)
 {
        struct tevent_req *req, *subreq;
        struct smb2cli_logoff_state *state;
@@ -46,16 +47,15 @@ struct tevent_req *smb2cli_logoff_send(TALLOC_CTX *mem_ctx,
        if (req == NULL) {
                return NULL;
        }
-       state->cli = cli;
        SSVAL(state->fixed, 0, 4);
 
        subreq = smb2cli_req_send(state, ev,
-                                 cli->conn, SMB2_OP_LOGOFF,
+                                 conn, SMB2_OP_LOGOFF,
                                  0, 0, /* flags */
-                                 cli->timeout,
-                                 cli->smb2.pid,
+                                 timeout_msec,
+                                 0xFEFF, /* pid */
                                  0, /* tid */
-                                 cli->smb2.session,
+                                 session,
                                  state->fixed, sizeof(state->fixed),
                                  NULL, 0);
        if (tevent_req_nomem(subreq, req)) {
@@ -85,7 +85,6 @@ static void smb2cli_logoff_done(struct tevent_req *subreq)
        status = smb2cli_req_recv(subreq, state, &iov,
                                  expected, ARRAY_SIZE(expected));
        TALLOC_FREE(subreq);
-       TALLOC_FREE(state->cli->smb2.session);
        if (tevent_req_nterror(req, status)) {
                return;
        }
@@ -97,14 +96,16 @@ NTSTATUS smb2cli_logoff_recv(struct tevent_req *req)
        return tevent_req_simple_recv_ntstatus(req);
 }
 
-NTSTATUS smb2cli_logoff(struct cli_state *cli)
+NTSTATUS smb2cli_logoff(struct smbXcli_conn *conn,
+                       uint32_t timeout_msec,
+                       struct smbXcli_session *session)
 {
        TALLOC_CTX *frame = talloc_stackframe();
        struct event_context *ev;
        struct tevent_req *req;
        NTSTATUS status = NT_STATUS_NO_MEMORY;
 
-       if (cli_has_async_calls(cli)) {
+       if (smbXcli_conn_has_async_calls(conn)) {
                /*
                 * Can't use sync call while an async call is in flight
                 */
@@ -115,7 +116,7 @@ NTSTATUS smb2cli_logoff(struct cli_state *cli)
        if (ev == NULL) {
                goto fail;
        }
-       req = smb2cli_logoff_send(frame, ev, cli);
+       req = smb2cli_logoff_send(frame, ev, conn, timeout_msec, session);
        if (req == NULL) {
                goto fail;
        }
index 12f32aa07f09ec9d19f07e1d3c93401fed9c4ede..8aff588cc7e6595ea6f289f644f06a8126701143 100644 (file)
@@ -183,7 +183,7 @@ bool run_smb2_basic(int dummy)
        }
 
        saved_uid = smb2cli_session_current_id(cli->smb2.session);
-       status = smb2cli_logoff(cli);
+       status = smb2cli_logoff(cli->conn, cli->timeout, cli->smb2.session);
        if (!NT_STATUS_IS_OK(status)) {
                printf("smb2cli_logoff returned %s\n", nt_errstr(status));
                return false;
@@ -197,7 +197,7 @@ bool run_smb2_basic(int dummy)
 
        smb2cli_session_set_id_and_flags(cli->smb2.session, saved_uid, 0);
 
-       status = smb2cli_logoff(cli);
+       status = smb2cli_logoff(cli->conn, cli->timeout, cli->smb2.session);
        if (!NT_STATUS_EQUAL(status, NT_STATUS_USER_SESSION_DELETED)) {
                printf("2nd smb2cli_logoff returned %s\n", nt_errstr(status));
                return false;