r11759: fix up the SEC_SHARE handling, when we want to support that later
authorStefan Metzmacher <metze@samba.org>
Thu, 17 Nov 2005 12:52:40 +0000 (12:52 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:46:24 +0000 (13:46 -0500)
we need to fake a smbsrv_session for each smbsrv_tcon...

metze
(This used to be commit 5b5fb1772034fbfebbb7174df235c8c11d4819fe)

source4/smb_server/receive.c
source4/smb_server/session.c
source4/smb_server/smb_server.h

index b339f1391a6c268044ac6ec59fa59e9ee1831c48..371333b64720f23e6b2c03f91171ab8d2f5d5f41 100644 (file)
@@ -459,7 +459,6 @@ static void switch_message(int type, struct smbsrv_request *req)
 {
        int flags;
        struct smbsrv_connection *smb_conn = req->smb_conn;
-       uint16_t session_tag;
        NTSTATUS status;
 
        type &= 0xff;
@@ -476,24 +475,19 @@ static void switch_message(int type, struct smbsrv_request *req)
 
        req->tcon = smbsrv_tcon_find(smb_conn, SVAL(req->in.hdr,HDR_TID));
 
-       if (req->session == NULL) {
+       if (!req->session) {
                /* setup the user context for this request if it
                   hasn't already been initialised (to cope with SMB
                   chaining) */
 
                /* In share mode security we must ignore the vuid. */
                if (smb_conn->config.security == SEC_SHARE) {
-                       session_tag = UID_FIELD_INVALID;
-               } else {
-                       session_tag = SVAL(req->in.hdr,HDR_UID);
+                       if (req->tcon) {
+                               req->session = req->tcon->sec_share.session;
+                       }
+               } else {
+                       req->session = smbsrv_session_find(req->smb_conn, SVAL(req->in.hdr,HDR_UID));
                }
-
-               req->session = smbsrv_session_find(req->smb_conn, session_tag);
-               if (req->session) {
-                       req->session->vuid = session_tag;
-               }
-       } else {
-               session_tag = req->session->vuid;
        }
 
        DEBUG(3,("switch message %s (task_id %d)\n",smb_fn_name(type), req->smb_conn->connection->server_id));
index 0bee536b9378a42ad120aa3a16f4d298f89aeca3..50bea16ee27fbf596541231f0afd1e72ad82654d 100644 (file)
@@ -106,9 +106,7 @@ struct smbsrv_session *smbsrv_register_session(struct smbsrv_connection *smb_con
        int i;
 
        /* Ensure no vuid gets registered in share level security. */
-       /* TODO: replace lp_security with a flag in smbsrv_connection */
-       if (lp_security() == SEC_SHARE)
-               return UID_FIELD_INVALID;
+       if (smb_conn->config.security == SEC_SHARE) return NULL;
 
        sess = talloc(smb_conn, struct smbsrv_session);
        if (sess == NULL) {
@@ -120,7 +118,7 @@ struct smbsrv_session *smbsrv_register_session(struct smbsrv_connection *smb_con
 
        i = idr_get_new_random(smb_conn->sessions.idtree_vuid, sess, UINT16_MAX);
        if (i == -1) {
-               DEBUG(1,("ERROR! Out of connection structures\n"));            
+               DEBUG(1,("ERROR! Out of connection structures\n"));
                talloc_free(sess);
                return NULL;
        }
index 4ab7637558afc9969bed7733b8cceb03c92150bc..4b2f65d14acfc583179135f406669de053917903 100644 (file)
@@ -80,6 +80,12 @@ struct smbsrv_tcon {
        /* the reported device type */
        char *dev_type;
 
+       /* some stuff to support share level security */
+       struct {
+               /* in share level security we need to fake up a session */
+               struct smbsrv_session *session;
+       } sec_share;
+
        struct timeval connect_time;
 };