From: Jeremy Allison Date: Tue, 8 Jun 2021 00:21:04 +0000 (-0700) Subject: s3: smbd: open_fake_file(). Move the smbd_calculate_access_mask() check until after... X-Git-Tag: tevent-0.11.0~537 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1146fb3826cf737ffd339eedd188c0d205000f9d;p=thirdparty%2Fsamba.git s3: smbd: open_fake_file(). Move the smbd_calculate_access_mask() check until after we've initialized the file handle. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index c4c81dd19f9..0b4f8abc441 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -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; }