Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4906356
Votes 0
Synopsis Add UnixFileOutputStream, UnixFile with permissions support
Category java:classes_io
Reported Against 1.4
Release Fixed
State 11-Closed, duplicate of 4313887, request for enhancement
Priority: 3-Medium
Related Bugs 4313887
Submit Date 13-AUG-2003
Description
Current Java file support does not include support for specifying UNIX permissions on files and directories that are created.

This leads to an easy pitfall for Java applications:  they can easily create files or directories with permissions looser than they should be.  I've just filed a P2 security bug against another Sun product the root cause of which was that it used the Java file support to create files and directories and did not take extra care to get their permissions set right.  Particularly vexing is the fact that it's actually somewhat hard to do right - the best theory I've come up with is to create the file or directory using JNI or an external program run through Runtime.exec, and then write to it using core Java.

Such Unix* classes might well live in com.sun.something, though it seems like 3rd parties will need these capabilities too.
Work Around
Create the file or directory using Runtime.exec() before operating on it using core Java methods.  It might even be possible to write the classes in the Suggested Fix this way, though of course it would be inefficient.
Evaluation
N/A
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang