]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: open_fake_file(). Move the smbd_calculate_access_mask() check until after...
authorJeremy Allison <jra@samba.org>
Tue, 8 Jun 2021 00:21:04 +0000 (17:21 -0700)
committerRalph Boehme <slow@samba.org>
Wed, 9 Jun 2021 13:14:31 +0000 (13:14 +0000)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/fake_file.c

index c4c81dd19f9a3f6477e978b6eb28f12f52adb869..0b4f8abc4413e1605c752e0980cd4e108efb980d 100644 (file)
@@ -131,21 +131,6 @@ NTSTATUS open_fake_file(struct smb_request *req, connection_struct *conn,
        files_struct *fsp = NULL;
        NTSTATUS status;
 
-       status = smbd_calculate_access_mask(conn,
-                                       conn->cwd_fsp,
-                                       smb_fname,
-                                       false,
-                                       access_mask,
-                                       &access_mask);
-       if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(10, ("open_fake_file: smbd_calculate_access_mask "
-                       "on service[%s] file[%s] returned %s\n",
-                       lp_servicename(talloc_tos(), lp_sub, SNUM(conn)),
-                       smb_fname_str_dbg(smb_fname),
-                       nt_errstr(status)));
-               return status;
-       }
-
        /* access check */
        if (geteuid() != sec_initial_uid()) {
                DEBUG(3, ("open_fake_file_shared: access_denied to "
@@ -185,6 +170,22 @@ NTSTATUS open_fake_file(struct smb_request *req, connection_struct *conn,
                return NT_STATUS_NO_MEMORY;
        }
 
+       status = smbd_calculate_access_mask(conn,
+                                       conn->cwd_fsp,
+                                       smb_fname,
+                                       false,
+                                       access_mask,
+                                       &access_mask);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(10, ("open_fake_file: smbd_calculate_access_mask "
+                       "on service[%s] file[%s] returned %s\n",
+                       lp_servicename(talloc_tos(), lp_sub, SNUM(conn)),
+                       smb_fname_str_dbg(smb_fname),
+                       nt_errstr(status)));
+               file_free(req, fsp);
+               return status;
+       }
+
        *result = fsp;
        return NT_STATUS_OK;
 }