RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1207129 - 'jar uf' changes file permissions unexpectedly
Summary: 'jar uf' changes file permissions unexpectedly
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: java-1.7.0-openjdk
Version: 7.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Andrew John Hughes
QA Contact: Lukáš Zachar
URL:
Whiteboard:
Depends On:
Blocks: 1203710 1297579 1313485
TreeView+ depends on / blocked
 
Reported: 2015-03-30 09:59 UTC by Piyush Bhoot
Modified: 2019-12-16 04:42 UTC (History)
2 users (show)

Fixed In Version: java-1.7.0-openjdk-1.7.0.101-2.6.6.6.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-03 22:58:23 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Icedtea Bugzilla 1437 0 None None None 2016-06-29 14:34:19 UTC
Red Hat Product Errata RHBA-2016:2140 0 normal SHIPPED_LIVE java-1.7.0-openjdk bug fix and enhancement update 2016-11-03 13:12:14 UTC

Description Piyush Bhoot 2015-03-30 09:59:03 UTC
Description of problem:	
'jar uf' changes file permissions unexpectedly


Version-Release number of selected component (if applicable):
java-1.7.0-openjdk-1.7.0.71-2.5.3.1.el7_0.x86_64
to  java version "1.7.0_75"


How reproducible:
Always

Steps to Reproduce:
1] On RHEL 7 install latest openjdk

$ jar -cvf /tmp/aa.jar /tmp/aa1
added manifest
adding: tmp/aa1(in = 7) (out= 6)(deflated 14%)
 
-bash-4.2$ ls -l /tmp/aa.jar
-rw-rw-r-- 1 alfbiwer users 453 Mar 27 14:24 /tmp/aa.jar
 $ jar -uvf /tmp/aa.jar /tmp/aa2
adding: tmp/aa2(in = 8) (out= 6)(deflated 25%)

$ ls -l /tmp/aa.jar
-rw------- 1 alfbiwer users 565 Mar 27 14:25 /tmp/aa.jar

Actual results:
File permissions change

Expected results:
File Permission should not change

Additional info:
Seems regression
https://bugs.openjdk.java.net/browse/JDK-7175845

Comment 3 Andrew John Hughes 2016-01-06 13:39:29 UTC
7.2 has shipped, so switching this to 7.3.

Comment 5 Andrew John Hughes 2016-06-29 14:36:51 UTC
It looks like 7175845 may have been regressed during a merge:

7175845: "jar uf" changes file permissions unexpectedly
Reviewed-by: sherman, alanb

diff -r cb2985085ab4 -r c735836c2355 src/share/classes/sun/tools/jar/Main.java
--- a/src/share/classes/sun/tools/jar/Main.java	Mon Jun 18 15:51:37 2012 -0700
+++ b/src/share/classes/sun/tools/jar/Main.java	Wed Jun 20 15:49:12 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -137,7 +137,7 @@
         File dir = file.getParentFile();
         if (dir == null)
             dir = new File(".");
-        return Files.createTempFile(dir.toPath(), "jartmp", null).toFile();
+        return File.createTempFile("jartmp", null, dir);
     }
 
     private boolean ok;

diff -u {icedtea7/jdk,jdk7/jdk}/src/share/classes/sun/tools/jar/Main.java
--- src/share/classes/sun/tools/jar/Main.java	2015-06-12 16:19:50.081013982 +0100
+++ ../../jdk7/jdk/src/share/classes/sun/tools/jar/Main.java	2016-04-11 15:39:35.505188051 +0100
@@ -138,7 +138,7 @@
         File dir = file.getParentFile();
         if (dir == null)
             dir = new File(".");
-        return Files.createTempFile(dir.toPath(), "jartmp", null).toFile();
+        return File.createTempFile("jartmp", null, dir);
     }
 
     private boolean ok;

Comment 6 Andrew John Hughes 2016-06-29 15:03:03 UTC
Confirmed:

Latest release:

$ /usr/lib/jvm/icedtea-7/bin/java UpdateJar
[OWNER_WRITE, OWNER_READ, OTHERS_READ, GROUP_READ] not equal to [OWNER_WRITE, OWNER_READ]
java.lang.Exception: Stack trace
	at java.lang.Thread.dumpStack(Thread.java:1365)
	at UpdateJar.fail(UpdateJar.java:75)
	at UpdateJar.fail(UpdateJar.java:76)
	at UpdateJar.equal(UpdateJar.java:81)
	at UpdateJar.realMain(UpdateJar.java:65)
	at UpdateJar.main(UpdateJar.java:83)

Passed = 0 failed = 1

Patched build:

$ /mnt/builder/icedtea7/j2sdk-image/bin/java UpdateJar

Passed = 1 failed = 0

Comment 7 Andrew John Hughes 2016-06-29 15:05:20 UTC
$ touch /tmp/aa1
$ /mnt/builder/icedtea7/j2sdk-image/bin/jar -cvf /tmp/aa.jar /tmp/aa1
added manifest
adding: tmp/aa1(in = 0) (out= 0)(stored 0%)
$ touch /tmp/aa2
$ /mnt/builder/icedtea7/j2sdk-image/bin/jar -uvf /tmp/aa.jar /tmp/aa2
adding: tmp/aa2(in = 0) (out= 0)(stored 0%)
$ ls -l /tmp/aa.jar
-rw-r--r-- 1 andrew users 527 Jun 29 16:04 /tmp/aa.jar

Comment 12 errata-xmlrpc 2016-11-03 22:58:23 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2140.html


Note You need to log in before you can comment on or make changes to this bug.