s3:smbd: create a connection_struct in SMB2 Tree Connect
authorStefan Metzmacher <metze@samba.org>
Wed, 27 May 2009 16:40:42 +0000 (18:40 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 3 Jun 2009 15:54:38 +0000 (17:54 +0200)
metze

source3/smbd/globals.h
source3/smbd/server.c
source3/smbd/smb2_sesssetup.c
source3/smbd/smb2_tcon.c

index cd0cb4d2460fdc386b642a41d4efee5a55f0ce12..e8821d71a4b855af5057b07cee49b6c7d89aaeca 100644 (file)
@@ -286,6 +286,7 @@ struct smbd_smb2_tcon {
        struct smbd_smb2_session *session;
        uint32_t tid;
        int snum;
+       connection_struct *compat_conn;
 };
 
 struct pending_auth_data;
index 77e487ac68cf6f20a7aed6c64a471f915b56c741..a022f3e8683fc38d112fcbbc295a205444e28e22 100644 (file)
@@ -827,6 +827,15 @@ static void exit_server_common(enum server_exit_reason how,
        locking_end();
        printing_end();
 
+       /*
+        * we need to force the order of freeing the following,
+        * because smbd_msg_ctx is not a talloc child of smbd_server_conn.
+        */
+       sconn = NULL;
+       TALLOC_FREE(smbd_server_conn);
+       TALLOC_FREE(smbd_msg_ctx);
+       TALLOC_FREE(smbd_event_ctx);
+
        if (how != SERVER_EXIT_NORMAL) {
                int oldlevel = DEBUGLEVEL;
 
index eb88a60420bc33658d633fc07ee703f61d848ecf..0f0a90003e0b5827609710eacbb8ab8e6bf9f556 100644 (file)
@@ -172,7 +172,7 @@ static NTSTATUS smbd_smb2_session_setup(struct smbd_smb2_request *req,
                if (session->tcons.idtree == NULL) {
                        return NT_STATUS_NO_MEMORY;
                }
-               session->tcons.limit = 0x00FFFFFF;
+               session->tcons.limit = 0x0000FFFE;
                session->tcons.list = NULL;
 
                DLIST_ADD_END(req->conn->smb2.sessions.list, session,
index f74d1bcca75f2580aa4c63a9afd63238d24518fd..4f305e01d529d7ea3eebd62afa43dc1171643695 100644 (file)
@@ -110,6 +110,9 @@ static int smbd_smb2_tcon_destructor(struct smbd_smb2_tcon *tcon)
        idr_remove(tcon->session->tcons.idtree, tcon->tid);
        DLIST_REMOVE(tcon->session->tcons.list, tcon);
 
+       conn_free(tcon->session->conn, tcon->compat_conn);
+
+       tcon->compat_conn = NULL;
        tcon->tid = 0;
        tcon->session = NULL;
 
@@ -125,6 +128,7 @@ static NTSTATUS smbd_smb2_tree_connect(struct smbd_smb2_request *req,
        int snum = -1;
        struct smbd_smb2_tcon *tcon;
        int id;
+       NTSTATUS status;
 
        if (strncmp(share, "\\\\", 2) == 0) {
                const char *p = strchr(share+2, '\\');
@@ -158,6 +162,7 @@ static NTSTATUS smbd_smb2_tree_connect(struct smbd_smb2_request *req,
                                tcon,
                                req->session->tcons.limit);
        if (id == -1) {
+               TALLOC_FREE(tcon);
                return NT_STATUS_INSUFFICIENT_RESOURCES;
        }
        tcon->tid = id;
@@ -168,6 +173,16 @@ static NTSTATUS smbd_smb2_tree_connect(struct smbd_smb2_request *req,
        tcon->session = req->session;
        talloc_set_destructor(tcon, smbd_smb2_tcon_destructor);
 
+       tcon->compat_conn = make_connection_snum(req->conn,
+                                       snum, req->session->compat_vuser,
+                                       data_blob_null, "???",
+                                       &status);
+       if (tcon->compat_conn == NULL) {
+               TALLOC_FREE(tcon);
+               return status;
+       }
+       tcon->compat_conn->cnum = tcon->tid;
+
        *out_tree_id = tcon->tid;
        return NT_STATUS_OK;
 }
@@ -191,6 +206,10 @@ NTSTATUS smbd_smb2_request_check_tcon(struct smbd_smb2_request *req)
        }
        tcon = talloc_get_type_abort(p, struct smbd_smb2_tcon);
 
+       if (!change_to_user(tcon->compat_conn,req->session->vuid)) {
+               return NT_STATUS_ACCESS_DENIED;
+       }
+
        req->tcon = tcon;
        return NT_STATUS_OK;
 }