• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

UNIX file permissions

 
Greenhorn
Posts: 1
Mac OS X Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings Everyone!

I am working on a vulnerability assessment/compliance UNIX project covering multiple *nix platforms and have a question. One aspect of the assessment is file permissions (SUID, SGID, world-writeable, etc.). From the research I've done the standard permissions (ugo/rwx) and possibly file ACLs are available through the java.nio.file.attribute package, but the SUID, SGID, and sticky bits are too UNIX-specific and Java does not return these.

Therefore my questions are:
1) Is my research is accurate?
2) If it is accurate then is there a relatively easy way to determine the SUID/SGID permissions code-wise through Java? I really do not want to exec out to the OS to run a long file listing (ls -l) and parse the output if I can help it. If I have to do that I will, but that leads to another question - would it then be better to parse the entire file permissions mask manually and not use the java.nio.file.attribute package?
3) If it is not accurate, what package(s)/Java tricks am I missing?

Thank you for any insight you can give.

jc
 
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

I agree with your research. The closest Java has was Java 7's Posix view, but it doesn't have that level of detail. I think you'll have to use exec. And yes, if you are using exec, you might as well have UNIX code do the whole thing. It isn't as if your code is going to be operating system agnostic. The only advantage to using the NIO classes is to minimize the parsing logic. But if you have to do it anyway...
 
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or mix in some JNI.
 
reply
    Bookmark Topic Watch Topic
  • New Topic