|
55 | 55 | import liquibase.database.DatabaseFactory; |
56 | 56 | import liquibase.database.jvm.JdbcConnection; |
57 | 57 | import liquibase.resource.ClassLoaderResourceAccessor; |
| 58 | +import org.dcache.acl.ACE; |
| 59 | +import org.dcache.acl.enums.AccessMask; |
| 60 | +import org.dcache.acl.enums.AceFlags; |
| 61 | +import org.dcache.acl.enums.AceType; |
| 62 | +import org.dcache.acl.enums.Who; |
58 | 63 | import org.dcache.auth.Subjects; |
59 | 64 | import org.dcache.auth.attributes.Restrictions; |
60 | 65 | import org.dcache.chimera.ChimeraFsException; |
|
66 | 71 | import org.dcache.chimera.namespace.ChimeraNameSpaceProvider; |
67 | 72 | import org.dcache.chimera.namespace.ChimeraOsmStorageInfoExtractor; |
68 | 73 | import org.dcache.chimera.posix.Stat; |
| 74 | +import org.dcache.namespace.ACLPermissionHandler; |
| 75 | +import org.dcache.namespace.ChainedPermissionHandler; |
69 | 76 | import org.dcache.namespace.CreateOption; |
70 | 77 | import org.dcache.namespace.FileAttribute; |
| 78 | +import org.dcache.namespace.PermissionHandler; |
71 | 79 | import org.dcache.namespace.PosixPermissionHandler; |
72 | 80 | import org.dcache.util.Checksum; |
73 | 81 | import org.dcache.util.ChecksumType; |
@@ -775,6 +783,49 @@ public void testNoAtimeUpdateOnGetFileAttributesNegativeGap() throws ChimeraFsEx |
775 | 783 | stat_after.getATime() == stat_before.getATime()); |
776 | 784 | } |
777 | 785 |
|
| 786 | + @Test |
| 787 | + public void testCreateFileWithXattrAndInheritedACLs() throws ChimeraFsException { |
| 788 | + |
| 789 | + var permissionHandler = new ChainedPermissionHandler( |
| 790 | + new ACLPermissionHandler(), |
| 791 | + new PosixPermissionHandler() |
| 792 | + ); |
| 793 | + |
| 794 | + _pnfsManager.setPermissionHandler(permissionHandler); |
| 795 | + ((ChimeraNameSpaceProvider) _pnfsManager.getNameSpaceProvider()).setPermissionHandler(permissionHandler); |
| 796 | + ((ChimeraNameSpaceProvider) _pnfsManager.getNameSpaceProvider()).setAclEnabled(true); |
| 797 | + |
| 798 | + var rootInode = _fs.path2inode("/"); |
| 799 | + FsInode dir = _fs.mkdir(rootInode, "dir", 1, 2, 0755); |
| 800 | + |
| 801 | + var acl = List.of( |
| 802 | + new ACE(AceType.ACCESS_DENIED_ACE_TYPE, |
| 803 | + AceFlags.INHERIT_ONLY_ACE.getValue() | AceFlags.FILE_INHERIT_ACE.getValue(), |
| 804 | + AccessMask.WRITE_ATTRIBUTES.getValue(), |
| 805 | + Who.EVERYONE, -1), |
| 806 | + |
| 807 | + new ACE(AceType.ACCESS_DENIED_ACE_TYPE, |
| 808 | + AceFlags.INHERIT_ONLY_ACE.getValue() | AceFlags.FILE_INHERIT_ACE.getValue(), |
| 809 | + AccessMask.WRITE_DATA.getValue(), |
| 810 | + Who.EVERYONE, -1) |
| 811 | + ); |
| 812 | + |
| 813 | + _fs.setACL(dir, acl); |
| 814 | + |
| 815 | + var pnfsCreateEntryMessage = new PnfsCreateEntryMessage("/dir/file1", |
| 816 | + FileAttributes.of() |
| 817 | + .fileType(REGULAR) |
| 818 | + .mode(0600) |
| 819 | + .uid(1) |
| 820 | + .gid(2) |
| 821 | + .xattr("foo", "bar") |
| 822 | + .build()); |
| 823 | + |
| 824 | + pnfsCreateEntryMessage.setSubject(Subjects.of(1, 2, new int[]{1})); |
| 825 | + _pnfsManager.createEntry(pnfsCreateEntryMessage); |
| 826 | + assertThat(pnfsCreateEntryMessage.getReturnCode(), is(0)); |
| 827 | + } |
| 828 | + |
778 | 829 | private void assertNotExists(String path) throws ChimeraFsException { |
779 | 830 | try { |
780 | 831 | _fs.path2inode(path); |
|
0 commit comments