]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: avoid become_user_without_service() in close_directory()
authorRalph Boehme <slow@samba.org>
Tue, 7 Apr 2020 07:55:35 +0000 (09:55 +0200)
committerJeremy Allison <jra@samba.org>
Sat, 30 May 2020 01:17:36 +0000 (01:17 +0000)
Here we called become_user_without_service() just in order to be able to fetch
the nt_token and unix_token subsequently via get_current_[nt|u]tok(conn). The
same can be achieved by fetching the session_info with
smbXsrv_session_info_lookup().

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/close.c

index 97e5b033c831862c2a466b9e4780ad01b4d32807..da28559e49b9c5fb09091c1a8993b3950509cdae 100644 (file)
@@ -1138,25 +1138,25 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
        }
 
        if (fsp->fsp_flags.initial_delete_on_close) {
-               bool became_user = False;
+               struct auth_session_info *session_info = NULL;
 
                /* Initial delete on close was set - for
                 * directories we don't care if anyone else
                 * wrote a real delete on close. */
 
-               if (get_current_vuid(fsp->conn) != fsp->vuid) {
-                       become_user_without_service(fsp->conn, fsp->vuid);
-                       became_user = True;
+               status = smbXsrv_session_info_lookup(fsp->conn->sconn->client,
+                                                    fsp->vuid,
+                                                    &session_info);
+               if (!NT_STATUS_IS_OK(status)) {
+                       return NT_STATUS_INTERNAL_ERROR;
                }
+
                send_stat_cache_delete_message(fsp->conn->sconn->msg_ctx,
                                               fsp->fsp_name->base_name);
                set_delete_on_close_lck(fsp, lck,
-                               get_current_nttok(fsp->conn),
-                               get_current_utok(fsp->conn));
+                                       session_info->security_token,
+                                       session_info->unix_token);
                fsp->fsp_flags.delete_on_close = true;
-               if (became_user) {
-                       unbecome_user_without_service();
-               }
        }
 
        delete_dir = get_delete_on_close_token(