United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7175845 "jar uf" changes file permissions unexpectedly
JDK-7175845 : "jar uf" changes file permissions unexpectedly

Details
Type:
Bug
Submit Date:
2012-06-11
Status:
Closed
Updated Date:
2012-08-15
Project Name:
JDK
Resolved Date:
2012-06-21
Component:
tools
OS:
solaris,linux,generic,linux_redhat_5.0
Sub-Component:
jar
CPU:
x86,generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
1.4.2_38-rev,5.0u36-rev,6u33,6u34,8
Fixed Versions:
6u33 (b32)

Related Reports
Backport:
Backport:
Backport:
Backport:
Backport:
Backport:
Backport:
Backport:
Duplicate:
Duplicate:
Relates:
Relates:

Sub Tasks

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

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.
                                     
2012-06-11
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.
                                     
2012-06-12
EVALUATION

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



Hardware and Software, Engineered to Work Together