<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: incorrect file permissions after Java createNewFile in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/incorrect-file-permissions-after-java-createnewfile/m-p/4326177#M683389</link>
    <description>&amp;gt;we posted here because the behavior seems to be unique to HP environment; same code sequence yields different/expected results on other platforms.&lt;BR /&gt;&lt;BR /&gt;Then you should be talking to the Response Center and see what they say.</description>
    <pubDate>Fri, 19 Dec 2008 13:44:11 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2008-12-19T13:44:11Z</dc:date>
    <item>
      <title>incorrect file permissions after Java createNewFile</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/incorrect-file-permissions-after-java-createnewfile/m-p/4326169#M683381</link>
      <description>We're creating a file in Java using a very simple program:&lt;BR /&gt;  myFile = new File("/tmp/testFile.txt");&lt;BR /&gt;  myFile.createNewFile();&lt;BR /&gt;&lt;BR /&gt;For some reason on HP-UX this always creates a file with permissions: &lt;BR /&gt;-rwxrwxr-x&lt;BR /&gt;&lt;BR /&gt;However if I perform "touch /tmp/testFile.txt" on HP-UX the file is created with permissions:&lt;BR /&gt;-rw-rw-r--&lt;BR /&gt;&lt;BR /&gt;Also, the same java code above will create a file on Solaris, Linux, etc. with permissions:&lt;BR /&gt;-rw-rw-r--&lt;BR /&gt;&lt;BR /&gt;My umask is set to:&lt;BR /&gt;2&lt;BR /&gt;&lt;BR /&gt;java version 1.5.0.09&lt;BR /&gt;Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0.09-_18_aug_2007_07_52)&lt;BR /&gt;Java HotSpot(TM) Server VM (build 1.5.0.09 jinteg:08.18.07-13:19 IA64, mixed mode)</description>
      <pubDate>Thu, 18 Dec 2008 19:01:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/incorrect-file-permissions-after-java-createnewfile/m-p/4326169#M683381</guid>
      <dc:creator>Joyce Esker_1</dc:creator>
      <dc:date>2008-12-18T19:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: incorrect file permissions after Java createNewFile</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/incorrect-file-permissions-after-java-createnewfile/m-p/4326170#M683382</link>
      <description>Apparently Java ignores the usual HP-UX conventions when creating files.&lt;BR /&gt;&lt;BR /&gt;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--).&lt;BR /&gt;&lt;BR /&gt;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).&lt;BR /&gt;&lt;BR /&gt;2 things I can think of to try are:&lt;BR /&gt;&lt;BR /&gt;1) Change the permissions of the file to what you want in your java program.&lt;BR /&gt;&lt;BR /&gt;2) Try a newer version of Java and see if that fixes the issue.</description>
      <pubDate>Thu, 18 Dec 2008 19:11:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/incorrect-file-permissions-after-java-createnewfile/m-p/4326170#M683382</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2008-12-18T19:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: incorrect file permissions after Java createNewFile</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/incorrect-file-permissions-after-java-createnewfile/m-p/4326171#M683383</link>
      <description>Shalom,&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Thu, 18 Dec 2008 19:30:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/incorrect-file-permissions-after-java-createnewfile/m-p/4326171#M683383</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2008-12-18T19:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: incorrect file permissions after Java createNewFile</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/incorrect-file-permissions-after-java-createnewfile/m-p/4326172#M683384</link>
      <description>&amp;gt;myFile = new File("/tmp/testFile.txt");&lt;BR /&gt;&lt;BR /&gt;Is there another parm to File where you can provide the default permissions?&lt;BR /&gt;The system call creat(2) has one.</description>
      <pubDate>Thu, 18 Dec 2008 20:26:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/incorrect-file-permissions-after-java-createnewfile/m-p/4326172#M683384</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-12-18T20:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: incorrect file permissions after Java createNewFile</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/incorrect-file-permissions-after-java-createnewfile/m-p/4326173#M683385</link>
      <description>There is no way to specify permissions in Java 5.  Java 6 allows you to set read/write/execute for user and all, but not at the granularity of user/group/other.</description>
      <pubDate>Thu, 18 Dec 2008 21:14:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/incorrect-file-permissions-after-java-createnewfile/m-p/4326173#M683385</guid>
      <dc:creator>Michael J Mole</dc:creator>
      <dc:date>2008-12-18T21:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: incorrect file permissions after Java createNewFile</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/incorrect-file-permissions-after-java-createnewfile/m-p/4326174#M683386</link>
      <description>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</description>
      <pubDate>Thu, 18 Dec 2008 21:52:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/incorrect-file-permissions-after-java-createnewfile/m-p/4326174#M683386</guid>
      <dc:creator>Michael J Mole</dc:creator>
      <dc:date>2008-12-18T21:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: incorrect file permissions after Java createNewFile</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/incorrect-file-permissions-after-java-createnewfile/m-p/4326175#M683387</link>
      <description>Hi Joyce &amp;amp; Michael:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; 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&lt;BR /&gt;&lt;BR /&gt;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'.  &lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;Hence, the creating code has the "upper limit" of the least restrictive permissions that will apply.&lt;BR /&gt;&lt;BR /&gt;You can evaluate this behavior with this small Perl script:&lt;BR /&gt;&lt;BR /&gt;# cat ./mymodes&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use Fcntl;&lt;BR /&gt;my $file = '/tmp/myfile';&lt;BR /&gt;unlink $file;&lt;BR /&gt;sysopen( FH, $file, O_CREAT, 0777 ) or die "Error: $!\n";&lt;BR /&gt;print "$file created\n";&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 18 Dec 2008 23:15:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/incorrect-file-permissions-after-java-createnewfile/m-p/4326175#M683387</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2008-12-18T23:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: incorrect file permissions after Java createNewFile</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/incorrect-file-permissions-after-java-createnewfile/m-p/4326176#M683388</link>
      <description>Also note that we posted here because the behavior seems to be unique to HP environment; same code sequence yields different/expected results on other platforms.</description>
      <pubDate>Fri, 19 Dec 2008 12:58:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/incorrect-file-permissions-after-java-createnewfile/m-p/4326176#M683388</guid>
      <dc:creator>Joyce Esker_1</dc:creator>
      <dc:date>2008-12-19T12:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: incorrect file permissions after Java createNewFile</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/incorrect-file-permissions-after-java-createnewfile/m-p/4326177#M683389</link>
      <description>&amp;gt;we posted here because the behavior seems to be unique to HP environment; same code sequence yields different/expected results on other platforms.&lt;BR /&gt;&lt;BR /&gt;Then you should be talking to the Response Center and see what they say.</description>
      <pubDate>Fri, 19 Dec 2008 13:44:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/incorrect-file-permissions-after-java-createnewfile/m-p/4326177#M683389</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-12-19T13:44:11Z</dc:date>
    </item>
  </channel>
</rss>

