Bug 1270052

Summary: brp-java-repack-jars doesn't preserve UID / GID on jar files
Product: Red Hat Enterprise Linux 6 Reporter: Ryan Sawhill <rsawhill>
Component: redhat-rpm-configAssignee: Florian Festi <ffesti>
Status: CLOSED ERRATA QA Contact: Karel Srot <ksrot>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.7CC: lkardos, mrichter, rsawhill
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1270053 (view as bug list) Environment:
Last Closed: 2016-05-11 01:03:46 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1172231, 1270053    
Attachments:
Description Flags
patch for file /usr/lib/rpm/redhat/brp-java-repack-jars none

Description Ryan Sawhill 2015-10-08 22:25:20 UTC
Description of problem:

  The UID and GID of any jar files gets reset by brp-java-repack-jars.

  I think few people notice this because it's extremely common to manually set those attributes in the %files section.

  If however you configure the ownership & perms in the %install section (e.g., with chown, chgrp, chmod) and use "%defattr(-,-,-,-)"  in the %files section ... well, then this hurts bad.


Version-Release number of selected component (if applicable):

  All. Tried the version of redhat-rpm-config shipped in every RHEL 6 and RHEL 7 release DVD. I didn't try RHEL 5 but I suspect it would be the same.


How reproducible:

  100%


Steps to Reproduce:

~~~~~~~~
yum -y install zip rpm-build rpmdevtools
user=mockbuild      # or whatever
group=OTHERGRP      # or whatever

cat >/tmp/jartest.spec <<EOF
%define __jar_repack %{nil}
Name:           jartest
Version:        1.0
Release:        1
Summary:        Demonstrate how brp-java-repack-jars messes w/GID
License:        GPLv3
Source0:        %{name}-%{version}.tar
%description
%{summary}
%prep
%setup -q
%install
rm -vrf %{buildroot}
mkdir -vp %{buildroot}
chgrp -v ${group} number1.jar
mv -v * %{buildroot}
%files
%defattr(-,-,-,-)
/*
EOF

groupadd ${group}
useradd -G ${group} ${user}
su - ${user}
rpmdev-setuptree
cd rpmbuild
mkdir SOURCES/jartest-1.0
zip SOURCES/jartest-1.0/number1.jar /etc/issue
zip SOURCES/jartest-1.0/number2.jar /etc/yum.conf
tar -C SOURCES -cf SOURCES/jartest-1.0.tar jartest-1.0
cp /tmp/jartest.spec SPECS/

rpmbuild -bb SPECS/jartest.spec
rpm -qplv RPMS/x86_64/jartest-1.0-1.x86_64.rpm

   # The two jar files are owned by different groups
   # Now remove the line disabling java_repack and try again

sed -i.bak 1d SPECS/jartest.spec
rpmbuild -bb SPECS/jartest.spec
rpm -qplv RPMS/x86_64/jartest-1.0-1.x86_64.rpm

   # Notice that the jar files are both owned by user's primary group
~~~~~~~~


Additional info:

  The latest version of rpm-build added redhat-rpm-config as a dependency which means that some folks are only now running into this.

Comment 6 Ľuboš Kardoš 2016-01-14 14:26:06 UTC
Created attachment 1114819 [details]
patch for file /usr/lib/rpm/redhat/brp-java-repack-jars

Comment 22 errata-xmlrpc 2016-05-11 01:03:46 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-0948.html