zhongjingxiong edited a comment on pull request #4036:
URL: https://github.com/apache/hadoop/pull/4036#issuecomment-1080612022


   ```java
   File tempFile = File.createTempFile("test-unzip", ".txt");
   
   Files.setPosixFilePermissions(tempFile.toPath(), permissionsFromMode(0700));
   UserPrincipalLookupService lookupService = 
FileSystems.getDefault().getUserPrincipalLookupService();
   GroupPrincipal groupPrincipal = 
lookupService.lookupPrincipalByGroupName("staff");
   UserPrincipal userPrincipal = lookupService.lookupPrincipalByName("cooper");
   PosixFileAttributeView view = Files.getFileAttributeView(tempFile.toPath(), 
PosixFileAttributeView.class);
   view.setGroup(groupPrincipal);
   readTargetPermission(tempFile.toPath());
   // This is going to fail because it's just a normal user
   view.setOwner(userPrincipal);
   
   readTargetPermission(tempFile.toPath());
   assertTrue("file lacks execute permissions", tempFile.canExecute());
   assertTrue("file lacks write permissions", tempFile.canWrite());
   assertTrue("file lacks read permissions", tempFile.canRead());```
   I tried to change the current user, but failed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to