]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smbd: call apply_new_nt_acl() already in mkdir_internals()
authorStefan Metzmacher <metze@samba.org>
Fri, 9 Aug 2024 15:52:25 +0000 (17:52 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 21 Aug 2024 08:02:30 +0000 (08:02 +0000)
We should have preparation steps as close as possible together.

We could move it for files as well, but that's a task for another
day...

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15693

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/open.c

index 5dfb6f9a38936de9a1fa68783999f96bb3b7595e..f0059117d7913523215af5c314129757d40e07af 100644 (file)
@@ -4604,6 +4604,7 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
                               struct smb_filename *parent_dir_fname, /* parent. */
                               struct smb_filename *smb_fname_atname, /* atname relative to parent. */
                               struct smb_filename *smb_dname, /* full pathname from root of share. */
+                              struct security_descriptor *sd,
                               uint32_t file_attributes,
                               struct files_struct *fsp)
 {
@@ -4730,6 +4731,18 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
                }
        }
 
+       if (lp_nt_acl_support(SNUM(conn))) {
+               status = apply_new_nt_acl(parent_dir_fname->fsp,
+                                         fsp,
+                                         sd);
+               if (!NT_STATUS_IS_OK(status)) {
+                       DBG_WARNING("apply_new_nt_acl() failed for %s with %s\n",
+                                   fsp_str_dbg(fsp),
+                                   nt_errstr(status));
+                       return status;
+               }
+       }
+
        notify_fname(conn, NOTIFY_ACTION_ADDED, FILE_NOTIFY_CHANGE_DIR_NAME,
                     smb_dname->base_name);
 
@@ -4749,6 +4762,7 @@ static NTSTATUS open_directory(connection_struct *conn,
                               uint32_t file_attributes,
                               struct smb_filename *parent_dir_fname,
                               struct smb_filename *smb_fname_atname,
+                              struct security_descriptor *sd,
                               int *pinfo,
                               struct files_struct *fsp)
 {
@@ -4838,6 +4852,7 @@ static NTSTATUS open_directory(connection_struct *conn,
                                                parent_dir_fname,
                                                smb_fname_atname,
                                                smb_dname,
+                                               sd,
                                                file_attributes,
                                                fsp);
 
@@ -4869,6 +4884,7 @@ static NTSTATUS open_directory(connection_struct *conn,
                                                        parent_dir_fname,
                                                        smb_fname_atname,
                                                        smb_dname,
+                                                       sd,
                                                        file_attributes,
                                                        fsp);
 
@@ -6375,6 +6391,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
                                        file_attributes,
                                        dirfsp->fsp_name,
                                        smb_fname_atname,
+                                       sd,
                                        &info,
                                        fsp);
        } else {
@@ -6431,6 +6448,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
                                                file_attributes,
                                                dirfsp->fsp_name,
                                                smb_fname_atname,
+                                               sd,
                                                &info,
                                                fsp);
                }
@@ -6478,6 +6496,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
        }
 
        if ((info == FILE_WAS_CREATED) &&
+           !S_ISDIR(fsp->fsp_name->st.st_ex_mode) &&
            lp_nt_acl_support(SNUM(conn)) &&
            !fsp_is_alternate_stream(fsp)) {
                status = apply_new_nt_acl(dirfsp, fsp, sd);