smbd: avoid calling set_current_user_info() twice with AS_USER (SMB1)
authorStefan Metzmacher <metze@samba.org>
Fri, 25 May 2018 14:30:13 +0000 (16:30 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 18 Jun 2018 06:59:17 +0000 (08:59 +0200)
It will be called via change_to_user().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/process.c

index 88362711632b9f365d539d10c22ce35cf6cef1df..54f7753e736cfaaae22be12a3989793243baba90 100644 (file)
@@ -1571,9 +1571,16 @@ static connection_struct *switch_message(uint8_t type, struct smb_request *req)
                }
        }
 
-       if (session != NULL) {
+       if (session != NULL && !(flags & AS_USER)) {
                struct user_struct *vuser = session->compat;
 
+               /*
+                * change_to_user() implies set_current_user_info()
+                * and chdir_connect_service().
+                *
+                * So we only call set_current_user_info if
+                * we don't have AS_USER specified.
+                */
                if (vuser) {
                        set_current_user_info(
                                vuser->session_info->unix_info->sanitized_username,
@@ -1601,6 +1608,10 @@ static connection_struct *switch_message(uint8_t type, struct smb_request *req)
 
                set_current_case_sensitive(conn, SVAL(req->inbuf,smb_flg));
 
+               /*
+                * change_to_user() implies set_current_user_info()
+                * and chdir_connect_service().
+                */
                if (!change_to_user(conn,session_tag)) {
                        DEBUG(0, ("Error: Could not change to user. Removing "
                                "deferred open, mid=%llu.\n",