Ensure when creating a directory, if we make any changes due to inheritance parameter...
authorJeremy Allison <jra@samba.org>
Wed, 8 Jun 2011 21:36:12 +0000 (14:36 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 8 Jun 2011 22:46:38 +0000 (00:46 +0200)
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Thu Jun  9 00:46:39 CEST 2011 on sn-devel-104

source3/smbd/open.c

index b7e5276a8a85c85b8a2c88f47f793bbdfdf8a394..06de8ab4320f539fd28e53959c2a3feff6ff8f93 100644 (file)
@@ -2568,6 +2568,7 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
        char *parent_dir;
        NTSTATUS status;
        bool posix_open = false;
+       bool need_re_stat = false;
 
        if(!CAN_WRITE(conn)) {
                DEBUG(5,("mkdir_internal: failing create on read-only share "
@@ -2622,6 +2623,7 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
        if (lp_inherit_perms(SNUM(conn))) {
                inherit_access_posix_acl(conn, parent_dir,
                                         smb_dname->base_name, mode);
+               need_re_stat = true;
        }
 
        if (!posix_open) {
@@ -2636,6 +2638,7 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
                        SMB_VFS_CHMOD(conn, smb_dname->base_name,
                                      (smb_dname->st.st_ex_mode |
                                          (mode & ~smb_dname->st.st_ex_mode)));
+                       need_re_stat = true;
                }
        }
 
@@ -2644,6 +2647,15 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
                change_dir_owner_to_parent(conn, parent_dir,
                                           smb_dname->base_name,
                                           &smb_dname->st);
+               need_re_stat = true;
+       }
+
+       if (need_re_stat) {
+               if (SMB_VFS_LSTAT(conn, smb_dname) == -1) {
+                       DEBUG(2, ("Could not stat directory '%s' just created: %s\n",
+                         smb_fname_str_dbg(smb_dname), strerror(errno)));
+                       return map_nt_error_from_unix(errno);
+               }
        }
 
        notify_fname(conn, NOTIFY_ACTION_ADDED, FILE_NOTIFY_CHANGE_DIR_NAME,