0

we have a dfs server where the results of automation run are stored. for some weird reason of late the permissions of different folder created by same process and same user have started varying.

the directory is created using Files mkdir .to ensure same permission I tried to set permission using setfacl .

setfacl is working fine when i run this from unix machine on dfs server directories however I need this to be working from java process running on windows os.

from cygwin the setfacl works fine as well.

however when ran through Java it is not able to set the permission

here is the difference when ran from cygwin and java process

CygWin

setfacl.exe --set user::---,group::rwx,other::--x acl.txt
output:-----rwx--x 1 user group 0 Nov 18 21:43 acl.txt
correct

Java

String commandLine ="C:/tools/cygwin/bin/setfacl.exe --set user::--
 -,group::rwx,other::--x" +" " + dir.getAbsolutePath();
List<String> commandList = Arrays.asList(commandLine.split(" "));

ProcessBuilder processBuilderCommand = new ProcessBuilder(commandList);
Process process = processBuilderCommand.start();
process.waitFor();

  output:-
    drwxrwx---+ 1 useradmin group    0 Nov 18 21:52 acl
  incorrect

Notice the difference in user got changed to administrator not sure if thats the reason for discrepancy

the trouble is java is not setting the permission which I am trying to set from the processbuilder using setfacl

getfacl has different outputs for java and shell.

java:- (incorrect)

$ getfacl acl
# file: acl
# owner: Administrators
# group: group
user::rwx
group::---
group:Authenticated Users:rwx
group:SYSTEM:rwx
group:Users:r-x
mask:rwx
other:---
default:user::rwx
default:group::---
default:group:Authenticated Users:rwx
default:group:SYSTEM:rwx
default:group:Users:r-x
default:mask:rwx
default:other:---

Cygwin

$ getfacl acl
# file: acl
# owner: Administrators
# group: group
user::---
group::rwx
other:--x
  • 1
    Before calling processBuilderCommand.start(), add `processBuilderCommand.inheritIO();`. It probably won’t fix your problem, but it will show the error output from the process, so you’ll know if something has gone wrong. – VGR Nov 18 '17 at 16:39
  • I tried redirecting the error and output to a file ,both got generated empty also the exit value of the command=0 .here is output command=[C:/tools/cygwin/bin/setfacl.exe, --set, user::-- -,group::rwx,other::--x, c:\acl] exit value=0 – Rahul Kumar Nov 18 '17 at 17:21
  • How did you redirect the error and output? – VGR Nov 18 '17 at 17:22
  • ProcessBuilder processBuilderCommand = new ProcessBuilder(commandList).inheritIO().redirectOutput(new File("c:\\output.txt")); – Rahul Kumar Nov 18 '17 at 17:23
  • That only redirects standard output, not standard error. You may want to use `new Processbuilder(commandList).redirectErrorStream(true).redirectOutput(new File("c:\\output.txt"));` so you’ll see both. Also, try changing process.waitFor() to `int exitCode = process.waitFor(); System.out.println(exitCode);`. If exitCode is not zero, the command failed, and there should be some text on standard error. – VGR Nov 18 '17 at 17:28
  • I had done both,and got the exit code also, process.exitCode(). as i mentioned the exit code=0 . I doubt the java is somehow restricted the setting of permission? or maybe cygwin is not displaying correctly? getfacl on the dir acl has different outputs ,updating the question with same – Rahul Kumar Nov 18 '17 at 17:49

0 Answers0