From: Stefan Metzmacher Date: Fri, 25 May 2018 14:30:13 +0000 (+0200) Subject: smbd: avoid calling set_current_user_info() twice with AS_USER (SMB1) X-Git-Tag: tevent-0.9.37~300 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60dbaa490c2b11047f5d7043ed48363164804d6f;p=thirdparty%2Fsamba.git smbd: avoid calling set_current_user_info() twice with AS_USER (SMB1) It will be called via change_to_user(). Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 88362711632..54f7753e736 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -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",