JDK-6778921 : Regression: rpm install may corrupt /etc/mailcap file
  • Type: Bug
  • Component: install
  • Sub-Component: install
  • Affected Version: 6u10
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2008-12-02
  • Updated: 2011-02-16
  • Resolved: 2010-01-13
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.
JDK 6 JDK 7
6u18 b05Fixed 7Fixed
Description
FULL PRODUCT VERSION :
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Linux localhost 2.4.29-0 #86 SMP Wed Oct 31 11:07:33 MSK 2007 i686 unknown

A DESCRIPTION OF THE PROBLEM :
The postin, postun and verify scriptlets of the rpm file declare function UpdateMailcap that contains the following line of code:

 printf "${mc_text}" > "${mailcap_file}"

where ${mc_text} contains the updated text of /etc/mailcap file.

If the text of the file contains any symbols that have special meaning or are not allowed in the format argument of the printf command, the file becomes corrupted or truncated.

It is regression since 1.6.0_07. In 6u7 the line was
 echo -e "${mc_text}" > "${mailcap_file}"

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The following snippet that is present in our /etc/mailcap file triggers the issue:

application/pgp; gpg < %s | metamail; needsterminal;        test=test %{encapsulation}=entity ; copiousoutput

  To reproduce:
1. Add the above snippet to an existing /etc/mailcap file
2. Login as root
3. Install  jre-6u10-linux-i586.rpm
4. During installation an error message is printed and the file becomes corrupted


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
1. Installation completes without any error messages.
2. The following line is added to /etc/mailcap file:
application/x-java-jnlp-file; /usr/bin/javaws %s
ACTUAL -
1. An error message is printed:
 printf: `{': invalid format character
2. The /etc/mailcap file is truncated after the following words:
 "test=test %"

Additional note:
If I replace /etc/mailcap with an empty file and run the installation, it completes without errors, but the file contains the following text:
 application/x-java-jnlp-file; /usr/bin/javaws
Note, that "%s" is missing from the line.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
/var/tmp/rpm-tmp.14051: printf: `{': invalid format character

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
1. Before installing or uninstalling JRE 6u10 rename your /etc/mailcap file (create a backup) and create an empty file instead of it.

2. Run the installation. It should complete without errors.

3. Restore the backup'ed copy of /etc/mailcap

4. If you were installing, add the following line to /etc/mailcap file, if it is not already there:
application/x-java-jnlp-file; /usr/bin/javaws %s

5. If you were uninstalling, remove the above mentioned line from the file.

Release Regression From : 6u7
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
EVALUATION (from Kelly) we need to replace that line in install/make/installer/bundles/linux/legacy_mime_support with: printf "%s" "${mc_text}" > "${mailcap_file}"
23-10-2009