- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- incorrect file permissions after Java createNewFil...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2008 11:01 AM
тАО12-18-2008 11:01 AM
incorrect file permissions after Java createNewFile
myFile = new File("/tmp/testFile.txt");
myFile.createNewFile();
For some reason on HP-UX this always creates a file with permissions:
-rwxrwxr-x
However if I perform "touch /tmp/testFile.txt" on HP-UX the file is created with permissions:
-rw-rw-r--
Also, the same java code above will create a file on Solaris, Linux, etc. with permissions:
-rw-rw-r--
My umask is set to:
2
java version 1.5.0.09
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0.09-_18_aug_2007_07_52)
Java HotSpot(TM) Server VM (build 1.5.0.09 jinteg:08.18.07-13:19 IA64, mixed mode)
- Tags:
- Java
- Permission
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2008 11:11 AM
тАО12-18-2008 11:11 AM
Re: incorrect file permissions after Java createNewFile
When HP-UX creates a file via HP-UX commands (touch, vi, cat, etc.) it is created with permissions of 666 (rw-rw-rw-) and then the umask is applied to get the permissions you expect. In your case the umask of 002 yields 664 (rw-rw-r--).
It appears that Java is starting off with permissions of 777 (rwxrwxrwx) for the file and then applying the umask. So a umask of 002 yields 775 (rwxrwxr-x).
2 things I can think of to try are:
1) Change the permissions of the file to what you want in your java program.
2) Try a newer version of Java and see if that fixes the issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2008 11:30 AM
тАО12-18-2008 11:30 AM
Re: incorrect file permissions after Java createNewFile
That is the default umask setting on the system of the user that starts java hot spot. You can alter it by altering the start up script.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Tags:
- umask
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2008 12:26 PM
тАО12-18-2008 12:26 PM
Re: incorrect file permissions after Java createNewFile
Is there another parm to File where you can provide the default permissions?
The system call creat(2) has one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2008 01:14 PM
тАО12-18-2008 01:14 PM
Re: incorrect file permissions after Java createNewFile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2008 01:52 PM
тАО12-18-2008 01:52 PM
Re: incorrect file permissions after Java createNewFile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2008 03:15 PM
тАО12-18-2008 03:15 PM
Re: incorrect file permissions after Java createNewFile
> I also tried this (on behalf of Joyce on behalf of me) with Java 6 and see the same behavior. Permissions are still set as -rwxrwxr-x
This suggests that the process using 'creat()' to create a file has supplied a 'mode' argument of '0777' when you use a umask of '0002'.
Two things come into play when a file is created. First, when a 'creat()' system call is performed, the code has the option of specifying an octal permissions value. The shell uses 666 for files. Whatever value is supplied, though, is subject to the application of the 'umaask' of the process. Hence if the 'umask' is 022 and the default permissions for the 'create()' are 666, the "subtraction" of the two means that the created file will have permissions of 644. With a creation mask of 666 and a 'umask' of 000, the file has permissions of 666.
If the code performing the file creation uses a creation mask of 644 (instead of 666), then even with a 'umask' of 000, a resulting file will have permissions of 644.
Hence, the creating code has the "upper limit" of the least restrictive permissions that will apply.
You can evaluate this behavior with this small Perl script:
# cat ./mymodes
#!/usr/bin/perl
use strict;
use Fcntl;
my $file = '/tmp/myfile';
unlink $file;
sysopen( FH, $file, O_CREAT, 0777 ) or die "Error: $!\n";
print "$file created\n";
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2008 04:58 AM
тАО12-19-2008 04:58 AM
Re: incorrect file permissions after Java createNewFile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-19-2008 05:44 AM
тАО12-19-2008 05:44 AM
Re: incorrect file permissions after Java createNewFile
Then you should be talking to the Response Center and see what they say.