server: Don't use the cached file mode when setting the security descriptor.
diff --git a/server/change.c b/server/change.c
index 2b940fe..06d9e37 100644
--- a/server/change.c
+++ b/server/change.c
@@ -342,6 +342,7 @@
 {
     struct dir *dir = (struct dir *)obj;
     const SID *owner;
+    struct stat st;
     mode_t mode;
     int unix_fd;
 
@@ -349,7 +350,7 @@
 
     unix_fd = get_dir_unix_fd( dir );
 
-    if (unix_fd == -1) return 1;
+    if (unix_fd == -1 || fstat( unix_fd, &st ) == -1) return 1;
 
     if (set_info & OWNER_SECURITY_INFORMATION)
     {
@@ -372,18 +373,13 @@
     if (set_info & DACL_SECURITY_INFORMATION)
     {
         /* keep the bits that we don't map to access rights in the ACL */
-        mode = dir->mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXG);
+        mode = st.st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXG);
         mode |= sd_to_mode( sd, owner );
 
-        if (dir->mode != mode)
+        if (st.st_mode != mode && fchmod( unix_fd, mode ) == -1)
         {
-            if (fchmod( unix_fd, mode ) == -1)
-            {
-                file_set_error();
-                return 0;
-            }
-
-            dir->mode = mode;
+            file_set_error();
+            return 0;
         }
     }
     return 1;