]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: avoid become_user_without_service() in close_remove_share_mode()
authorRalph Boehme <slow@samba.org>
Tue, 7 Apr 2020 07:54:24 +0000 (09:54 +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 05882392ce1cf2c8e9156bd36e1f2a198bc14f3c..97e5b033c831862c2a466b9e4780ad01b4d32807 100644 (file)
@@ -341,22 +341,21 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
 
        if (fsp->fsp_flags.initial_delete_on_close &&
                        !is_delete_on_close_set(lck, fsp->name_hash)) {
-               bool became_user = False;
+               struct auth_session_info *session_info = NULL;
 
                /* Initial delete on close was set and no one else
                 * wrote a real delete on close. */
 
-               if (get_current_vuid(conn) != fsp->vuid) {
-                       become_user_without_service(conn, fsp->vuid);
-                       became_user = True;
+               status = smbXsrv_session_info_lookup(conn->sconn->client,
+                                                    fsp->vuid,
+                                                    &session_info);
+               if (!NT_STATUS_IS_OK(status)) {
+                       return NT_STATUS_INTERNAL_ERROR;
                }
                fsp->fsp_flags.delete_on_close = true;
                set_delete_on_close_lck(fsp, lck,
-                               get_current_nttok(conn),
-                               get_current_utok(conn));
-               if (became_user) {
-                       unbecome_user_without_service();
-               }
+                                       session_info->security_token,
+                                       session_info->unix_token);
        }
 
        delete_file = is_delete_on_close_set(lck, fsp->name_hash) &&