Skip to content

Commit 1c38668

Browse files
authored
Merge pull request #8098 from dCache/issue8035-11.1
chimera: applying attributes to newly created file should skip permis…
2 parents 15905de + b859292 commit 1c38668

2 files changed

Lines changed: 53 additions & 1 deletion

File tree

modules/dcache-chimera/src/main/java/org/dcache/chimera/namespace/ChimeraNameSpaceProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ public FileAttributes createFile(Subject subject, String path,
370370
if (assignAttributes.getDefinedAttributes().isEmpty()) {
371371
fileAttributes = getFileAttributes(inode, requestedAttributes);
372372
} else {
373-
fileAttributes = setFileAttributes(subject, inode.getPnfsId(),
373+
// skip permission check on create by using ROOT subject.
374+
fileAttributes = setFileAttributes(Subjects.ROOT, inode.getPnfsId(),
374375
assignAttributes, requestedAttributes);
375376
}
376377

modules/dcache-chimera/src/test/java/diskCacheV111/namespace/PnfsManagerTest.java

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@
5555
import liquibase.database.DatabaseFactory;
5656
import liquibase.database.jvm.JdbcConnection;
5757
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;
5863
import org.dcache.auth.Subjects;
5964
import org.dcache.auth.attributes.Restrictions;
6065
import org.dcache.chimera.ChimeraFsException;
@@ -66,8 +71,11 @@
6671
import org.dcache.chimera.namespace.ChimeraNameSpaceProvider;
6772
import org.dcache.chimera.namespace.ChimeraOsmStorageInfoExtractor;
6873
import org.dcache.chimera.posix.Stat;
74+
import org.dcache.namespace.ACLPermissionHandler;
75+
import org.dcache.namespace.ChainedPermissionHandler;
6976
import org.dcache.namespace.CreateOption;
7077
import org.dcache.namespace.FileAttribute;
78+
import org.dcache.namespace.PermissionHandler;
7179
import org.dcache.namespace.PosixPermissionHandler;
7280
import org.dcache.util.Checksum;
7381
import org.dcache.util.ChecksumType;
@@ -775,6 +783,49 @@ public void testNoAtimeUpdateOnGetFileAttributesNegativeGap() throws ChimeraFsEx
775783
stat_after.getATime() == stat_before.getATime());
776784
}
777785

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+
778829
private void assertNotExists(String path) throws ChimeraFsException {
779830
try {
780831
_fs.path2inode(path);

0 commit comments

Comments
 (0)