File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Linux / UNIX and the fly likes unix/ias/java help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "unix/ias/java help" Watch "unix/ias/java help" New topic

unix/ias/java help

Geoff Humphris

Joined: Aug 21, 2003
Posts: 2
Can anyone help me with the problem below
I have a small java application that takes image data from a d/b and formats it as a bmp to write to a directory on a unix box to be used by other applications. (for reporting etc). This runs via the oracle 9ias application server.
The original version of this app only provided an image in png format for display on screen (for reports etc) but we have since found that some reports for external customers required the image as a saved version on the file system.
To this end I produced a new version of the image retriever that now produces the image for report display and writes a .bmp version of the image to the file system for use by external reports etc.
The problem I'm having is that when the bmp is created it is only has permissions for user and group to read (e.g. -rw-r-----). The external reports are run using another user id which then does not have permissions to read the file.
The first thing I tried was to change the umask for the user running ias so that files created by that user have default permissions with read access for all users, however this did not work and the permission remained as that above.
I have also tried changing the java code to override default permissions using FilePermission, this works in that you can change the permissions of the file being created but only for the user and group part of the permission (e.g. -rwxrwx---)
I am not sure whether these default permissions are caused by
a) the Unix environment for the ias user
b) 9ias itself
c) something I am missing in the java code
Any help would be gratefully recieved.
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
I'm going to pass this to the Unix/Linux forum, hopefully someone there has seen this issue and can you help you with the problem.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

Yep, Odds are that the file's being created owned by the appserver and with limited rights for security purposes. I don't think access rights are portable enough to be part of Java, so you'll have to do some external magic.
The simplest way is to simply add the consumers to the group under which the file is produced. This is clean, requires no programming, and in harmony with how Unix/Linux file access rights are intended to be used.
However, if the list of consumers is large and/or fluid, more extreme measures may be called for. The next easiest way would be to invoke runtime.exec to execute the chmod shell command.
Finally, you may be able to find a JNI package that manages file rights for you. This will be less portable, but probably less overhead.
You can also do some variants, if they fit well, such as making the images downloadable via HTTP or FTP.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: unix/ias/java help
It's not a secret anymore!