Fix bug #7987 - ACL can get lost when files are being renamed.
authorJeremy Allison <jra@samba.org>
Wed, 6 Apr 2011 00:26:00 +0000 (17:26 -0700)
committerKarolin Seeger <kseeger@samba.org>
Tue, 14 Jun 2011 10:57:12 +0000 (12:57 +0200)
There is no reason for smbd with Windows ACLs to use chmod
or fchmod unless it's a file opened with UNIX extensions or
with posix pathnames.
(cherry picked from commit bea18a55252a06fd1da005a4f57d4d4dd89acaaf)

source3/modules/vfs_acl_common.c
source3/modules/vfs_acl_tdb.c
source3/modules/vfs_acl_xattr.c

index eee322d5eae92dd98194b681917395887b19d89c..3f02e7f3016ef6db983b5aada75e0cba2144a768 100644 (file)
@@ -1012,3 +1012,43 @@ static int unlink_acl_common(struct vfs_handle_struct *handle,
                                        smb_fname->base_name,
                                        false);
 }
+
+static int chmod_acl_module_common(struct vfs_handle_struct *handle,
+                       const char *path, mode_t mode)
+{
+       if (lp_posix_pathnames()) {
+               /* Only allow this on POSIX pathnames. */
+               return SMB_VFS_NEXT_CHMOD(handle, path, mode);
+       }
+       return 0;
+}
+
+static int fchmod_acl_module_common(struct vfs_handle_struct *handle,
+                       struct files_struct *fsp, mode_t mode)
+{
+       if (fsp->posix_open) {
+               /* Only allow this on POSIX opens. */
+               return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
+       }
+       return 0;
+}
+
+static int chmod_acl_acl_module_common(struct vfs_handle_struct *handle,
+                       const char *name, mode_t mode)
+{
+       if (lp_posix_pathnames()) {
+               /* Only allow this on POSIX pathnames. */
+               return SMB_VFS_NEXT_CHMOD_ACL(handle, name, mode);
+       }
+       return 0;
+}
+
+static int fchmod_acl_acl_module_common(struct vfs_handle_struct *handle,
+                       struct files_struct *fsp, mode_t mode)
+{
+       if (fsp->posix_open) {
+               /* Only allow this on POSIX opens. */
+               return SMB_VFS_NEXT_FCHMOD_ACL(handle, fsp, mode);
+       }
+       return 0;
+}
index b26208c377d745310fb149fd1db0c0c8ba3aedde..4a05b9c456982aa28ab5cd84ad7bb53792ac60d8 100644 (file)
@@ -397,13 +397,17 @@ static struct vfs_fn_pointers vfs_acl_tdb_fns = {
        .disconnect = disconnect_acl_tdb,
        .opendir = opendir_acl_common,
        .mkdir = mkdir_acl_common,
+       .rmdir = rmdir_acl_tdb,
        .open = open_acl_common,
        .create_file = create_file_acl_common,
        .unlink = unlink_acl_tdb,
-       .rmdir = rmdir_acl_tdb,
+       .chmod = chmod_acl_module_common,
+       .fchmod = fchmod_acl_module_common,
        .fget_nt_acl = fget_nt_acl_common,
        .get_nt_acl = get_nt_acl_common,
        .fset_nt_acl = fset_nt_acl_common,
+       .chmod_acl = chmod_acl_acl_module_common,
+       .fchmod_acl = fchmod_acl_acl_module_common,
        .sys_acl_set_file = sys_acl_set_file_tdb,
        .sys_acl_set_fd = sys_acl_set_fd_tdb
 };
index 46e282d349d2144f50b9fa7b7f19fa17d08405e4..5937fac84e00d7d4e2f80f1f7a3558d9a8648055 100644 (file)
@@ -207,9 +207,13 @@ static struct vfs_fn_pointers vfs_acl_xattr_fns = {
        .open = open_acl_common,
        .create_file = create_file_acl_common,
        .unlink = unlink_acl_common,
+       .chmod = chmod_acl_module_common,
+       .fchmod = fchmod_acl_module_common,
        .fget_nt_acl = fget_nt_acl_common,
        .get_nt_acl = get_nt_acl_common,
        .fset_nt_acl = fset_nt_acl_common,
+       .chmod_acl = chmod_acl_acl_module_common,
+       .fchmod_acl = fchmod_acl_acl_module_common,
        .sys_acl_set_file = sys_acl_set_file_xattr,
        .sys_acl_set_fd = sys_acl_set_fd_xattr
 };