From fcdd6092b10a4b4406af47b989dcf1a9d693580e Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 8 Jan 2013 11:02:16 -0800 Subject: [PATCH] Fixup the change_to_user_by_session() case as called from become_user_by_session() 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 Reviewed-by: Andrew Bartlett --- source3/smbd/uid.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/source3/smbd/uid.c b/source3/smbd/uid.c index b2fe39cb9c1..a795eef8af8 100644 --- a/source3/smbd/uid.c +++ b/source3/smbd/uid.c @@ -191,6 +191,13 @@ static bool check_user_ok(connection_struct *conn, for (i=0; ivuid_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; -- 2.11.4.GIT