Fixup the change_to_user_by_session() case as called from become_user_by_session()
authorJeremy Allison <jra@samba.org>
Tue, 8 Jan 2013 19:02:16 +0000 (11:02 -0800)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 9 Jan 2013 04:29:47 +0000 (15:29 +1100)
Use inside source3/printing/nt_printing.c:get_correct_cversion().

Allow check_user_ok() to be called with vuid==UID_FIELD_INVALID.
All this should do is throw away one entry in the vuid cache.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/smbd/uid.c

index b2fe39c..a795eef 100644 (file)
@@ -191,6 +191,13 @@ static bool check_user_ok(connection_struct *conn,
        for (i=0; i<VUID_CACHE_SIZE; i++) {
                ent = &conn->vuid_cache->array[i];
                if (ent->vuid == vuid) {
+                       if (vuid == UID_FIELD_INVALID) {
+                               /*
+                                * Slow path, we don't care
+                                * about the array traversal.
+                               */
+                               continue;
+                       }
                        free_conn_session_info_if_unused(conn);
                        conn->session_info = ent->session_info;
                        conn->read_only = ent->read_only;
@@ -232,11 +239,26 @@ static bool check_user_ok(connection_struct *conn,
                return false;
        }
 
+       /*
+        * It's actually OK to call check_user_ok() with
+        * vuid == UID_FIELD_INVALID as called from change_to_user_by_session().
+        * All this will do is throw away one entry in the cache.
+        */
+
        ent->vuid = vuid;
        ent->read_only = readonly_share;
        ent->share_access = share_access;
        free_conn_session_info_if_unused(conn);
        conn->session_info = ent->session_info;
+       if (vuid == UID_FIELD_INVALID) {
+               /*
+                * Not strictly needed, just make it really
+                * clear this entry is actually an unused one.
+                */
+               ent->read_only = false;
+               ent->share_access = 0;
+               ent->session_info = NULL;
+       }
 
        conn->read_only = readonly_share;
        conn->share_access = share_access;