Read ACLs from CIFS mounted file system in Java

551 views Asked by At

On a Linux box I mounted a CIFS file system with

mount ... cifs ...,cifsacl

and I am able to read out ACLs with /usr/bin/getcifsacl. Further, on a Windows box, reading out ACLs in Java works with:

AclFileAttributeView view = 
    Files.getFileAttributeView(path, AclFileAttributeView.class)

But when I apply the same Java code to the CIFS mount on Linux, the view is null.

Is there a chance to tweak the CIFS mount or the Java code such that I can read ACLs? (I know jCIFS, but need to do without any additional Java class library.)

An answer would likely help here too.

1

There are 1 answers

1
Stephen C On BEST ANSWER

Is there a chance to tweak ... the Java code such that I can read ACLs?

You could always download the OpenJDK source code, figure out how to build it, then develop changes to do what you want. But that's a bad idea. You are unlikely to find anyone who is willing to take on your changes, and most folks wouldn't be willing to run them.

For the record, "rt.jar" file in OpenJDK build for Linux does not include the Windows file attribute view provider classes. They are not there. So you wouldn't be able to use (hypothetical) reflective tweaks to use the Windows views. Maybe you could compile them and add them to the bootclasspath.


Note that if you are unwilling to use jCIFS for licensing reasons, the same reasoning should prevent you from "tweaking" OpenJDK. OpenJDK is licensed as GPLv2 (with the "classpath exception"), and your tweaks would be covered as well. (Note that jCIFS is LGPLv2.1 ... which should be less problematic than GPLv2.)