JDK-4097578 : Enhance jar tool to preserve file permissions/modes
  • Type: Enhancement
  • Component: tools
  • Sub-Component: jar
  • Affected Version: 1.1.1,1.2.0,1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5.1,solaris_2.6
  • CPU: sparc
  • Submitted: 1997-12-05
  • Updated: 2006-12-14
  • Resolved: 2006-12-14
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
We have jars that goes pretty deep into the package hierarchy. For example,
com.sun.em.api.alarm.jar contains classes from the package com.sun.em.api.alarm.
When this jar is exploded on a user's machine, the permissions of the 
directories com, com/sun, com/sun/em, com/sun/em/api and com/sun/em/api/alarm 
are 754. Since it is root that is doing the jar explosion (during postinstall),
the classes are inaccessible to less privileged users. The permissions of these
directories should be 755. See workaround.

-Akhil Arora


I'm going to update the description of this bug a bit because it's become a huge problem.  The synopsis of the bug refers to directories, but jar doesn't have the ability to retain permission information on any files at all.

This is keeping a major new features of Java 1.3 from working.  Using Java 1.3, if I go to a web site that requires a Java Optional Package like Java 3D, if I don't have it, the package is automatically downloaded and installed, and then the application is executed as normal.  I call this feature "Extension-Installation" after the name of the associated manifest file attribute.

Supporting Extension-Installation involves wrapping the installer for your extension in a jar file, signing it, and putting it on the web.  When the user goes to the web site with the Java application requiring a Java Optional Package, the Java Plug-In (JPI) checks to see if it's installed, and if it isn't, automatically downloads and installs the extension.

To do this, it downloads the signed jar file, asks for permission, unjars the file, and runs the installer contained inside.  And there's the problem.  The installer, since it was in a jar file, is no longer executable, and therefore won't run (Permission denied).

What this means is that Extension-Installation works on Windows, and fails on Solaris.

The jar utility *must* have a way to preserve execute permission on the files it contains.  In the 'tar' unix utility, this is achieved through the -p parameter.  Jar needs something similar.

Note that the workaround mentioned above will not work here.  The JPI downloads the jar, unjars it, and runs the installer.  There's no place to insert any scripting to change the permission on the file before it gets executed.  The feature simply won't work and there's no workaround.  

All of the Java Optional Packages are adding support for Extension-Installation.  We are the first to run into this bug, but I'm sure you'll hear from all of them as well, plus the JPI team.  Please help!

Comments
EVALUATION Closing as dup of more general bug.
14-12-2006

WORK AROUND cd $EM_HOME/classes for ajar in `ls *.jar`; do info extracting $ajar... jar xf $ajar >/dev/null 2>&1 if [ $? != 0 ]; then # try again if the first attempt failed, see jar bug 4067481 jar xf $ajar >/dev/null 2>&1 if [ $? != 0 ]; then info failed to extract $ajar exit 1 fi fi done # jar xf leaves permissions of directories as 754, fix this /bin/find $EM_HOME/classes -type d -exec /bin/chmod 755 {} \;
11-06-2004

PUBLIC COMMENTS extracted directories have the wrong permission (754 should be 755)
10-06-2004

EVALUATION A better workaround for the first problem is to set the umask appropriately before invoking the jar tool. If you set the umask to 022 then you'll get directories with mode 755. The second problem, that of setting the execute bit on binary executables, has been worked around in the Java Plug-In (4364782). Enhancing the jar tool to preserve file permissions will, as previously stated, require an improved core filesystem API. Since this is not going to happen in Merlin, and there are effective workarounds for both of the problems described, I'm lowering the priority of this bug back to 4 and changing it into an RFE. -- mr@eng 2001/2/2
02-09-0168