JDK-7175845 : "jar uf" changes file permissions unexpectedly
  • Type: Bug
  • Component: tools
  • Sub-Component: jar
  • Affected Version: 1.4.2_38-rev,5.0u36-rev,6u33,6u34,8
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS:
    generic,linux,linux_redhat_5.0,solaris generic,linux,linux_redhat_5.0,solaris
  • CPU: generic,x86
  • Submitted: 2012-06-11
  • Updated: 2014-07-09
  • Resolved: 2012-06-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other Other JDK 6 JDK 7 JDK 8 Other
1.4.2_38,OpenJDK6Fixed 1.4.2_40Fixed 5.0u38Fixed 6u33 b32Fixed 7u6Fixed 8Fixed OpenJDK6Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
There seems a regression in jdk6u33 (linux am64)
Jar command changes the permission of file.

REPRODUCE :
1. run "umask 022"
2. run "jar cvf new-file any-file"
3. confirm the permission of new-file in the above step2
  (permission is set to 644)
4. run "jar uvf new-file any-file2"
5. confirm the permission of new-file again.
You can see the permission is changed to 600

FREQUENCY:
This problem occurs every time the command is run.

EXPECTED:
The behavior in jdk6u32 is expected.(permission is not changed by jar command)
---- JDK6u32 ---
jle-esxi-redhat:/home/tbaba 42 % umask 022
jle-esxi-redhat:/home/tbaba 43 % jar cvf test.jar te.csh
added manifest
adding: te.csh(in = 476) (out= 96)(deflated 79%)
jle-esxi-redhat:/home/tbaba 44 % ls -l test.jar
-rw-r--r--+ 1 tbaba javasoft 545 Jun 10 23:25 test.jar
jle-esxi-redhat:/home/tbaba 45 % jar uvf test.jar cmd
adding: cmd(in = 149) (out= 91)(deflated 38%)
jle-esxi-redhat:/home/tbaba 46 % ls -l test.jar
-rw-r--r--+ 1 tbaba javasoft 734 Jun 10 23:25 test.jar
jle-esxi-redhat:/home/tbaba 47 % java -version
java version "1.6.0_32"
Java(TM) SE Runtime Environment (build 1.6.0_32-b05)
Java HotSpot(TM) 64-Bit Server VM (build 20.7-b02, mixed mode)
----------

ACTUAL:
Permission of file is changed by jar command.
--- JDK6u33 ----
jle-esxi-redhat:/home/tbaba 43 % umask 022
jle-esxi-redhat:/home/tbaba 44 % jar cvf test.jar te.csh
added manifest
adding: te.csh(in = 476) (out= 96)(deflated 79%)
jle-esxi-redhat:/home/tbaba 45 % ls -l test.jar
-rw-r--r--+ 1 tbaba javasoft 545 Jun 10 23:28 test.jar
jle-esxi-redhat:/home/tbaba 46 % jar uvf test.jar cmd
adding: cmd(in = 149) (out= 91)(deflated 38%)
jle-esxi-redhat:/home/tbaba 47 % ls -l test.jar
-rw-------+ 1 tbaba javasoft 734 Jun 10 23:29 test.jar  <==== Permission is changed !!
jle-esxi-redhat:/home/tbaba 48 % java -version
java version "1.6.0_33"
Java(TM) SE Runtime Environment (build 1.6.0_33-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03, mixed mode)
---------------

Comments
EVALUATION http://hg.openjdk.java.net/hsx/hotspot-comp/jdk/rev/819258b5002e
14-08-2012

EVALUATION Note that this issue does not affect Windows, only Linux/Solaris/Mac and only when jar files are shared between developers. Bob updates a JAR file with the jar command and Alice, on the same system or accessing via NFS, can no longer access it because the file permissions on the .jar file have changed after the update. The short term solution is to back out the changes made for this specific case. Later it can be fixed properly so that the rename over the original JAR file keeps the original permissions.
12-06-2012

EVALUATION This regression is caused by a change that was made in previous release to improve file permission. The temporary file used in this case was "renamed" to overwrite the original file for the jar update.
11-06-2012