diff --git a/libntfs-3g/acls.c b/libntfs-3g/acls.c index a995f6b7..621a727b 100644 --- a/libntfs-3g/acls.c +++ b/libntfs-3g/acls.c @@ -1065,9 +1065,7 @@ struct POSIX_SECURITY *ntfs_build_inherited_posix( sizeof(struct POSIX_SECURITY) + count*sizeof(struct POSIX_ACE)); if (pydesc) { /* - * Copy inherited tags - * and, for a plain file, remove execution right - * from owner, other and mask + * Copy inherited tags and adapt perms */ tagsset = 0; defcnt = (pxdesc ? pxdesc->defcnt : 0); @@ -1076,10 +1074,17 @@ struct POSIX_SECURITY *ntfs_build_inherited_posix( *pyace = pxdesc->acl.ace[pxdesc->firstdef + i]; switch (pyace->tag) { case POSIX_ACL_USER_OBJ : + pyace->perms &= (mode >> 6) & 7; + break; + case POSIX_ACL_GROUP_OBJ : + if (!(tagsset & POSIX_ACL_MASK)) + pyace->perms &= (mode >> 3) & 7; + break; case POSIX_ACL_OTHER : + pyace->perms &= mode & 7; + break; case POSIX_ACL_MASK : - if (!isdir) - pyace->perms &= 6; + pyace->perms &= (mode >> 3) & 7; break; default : break;