Bug 2058426

Summary: Cannot extract rpms from RHEL9 on RHEL7.8
Product: Red Hat Enterprise Linux 7 Reporter: kartthik.raghunathan
Component: rpmAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED NOTABUG QA Contact: swm-qe
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.8CC: pmatilai
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-02-25 07:40:17 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:

Description kartthik.raghunathan 2022-02-24 22:04:04 UTC
Description of problem: 
rpm2cpio produces garbage when extracting a rhel-9 rpm on RHEL7.8. 

rpm2cpio kmod-elx-lpfc-14.2.171.0-1.rhel9u0.x86_64.rpm  | cpio -idv
cpio: Malformed number E▒▒▒
cpio: Malformed number ▒▒▒4
cpio: Malformed number ▒▒4<
cpio: Malformed number ▒4<U
cpio: warning: skipped 26720 bytes of junk
cpio: warning: archive header has reverse byte-order
cpio: ▒▒▒i▒▒X▒*▒▒▒8qN!▒▒\       ▒+▒▒`)/%6�}˩b
(▒▒0▒R▒(▒▒>ǰ▒▒ܮTC▒▒#▒▒▒▒gNRbVw▒▒=?o▒▒_}~▒▒
▒w▒hkc▒▒|▒▒޾5▒:▒4▒▒▒▒▒5"Ӏ▒▒"▒S▒▒8▒▒!▒▒▒Ux▒▒▒▒R
'▒▒N&SG▒TL▒▒R#▒ט▒S▒b▒=R▒▒x▒QMX▒i▒▒~▒,G▒▒J&▒;▒Z▒▒▒jG▒V▒▒~▒jNQD/h▒Ot▒▒▒▒▒▒M▒▒▒
                                                                            gW)▒=<▒o\ڋ~▒▒N▒?▒L▒▒C▒▒+▒
▒▒▒▒)$▒▒VLČօ▒▒־Q▒,M▒▒~▒'▒Y1▒D▒V▒r->w▒▒▒[▒S▒▒F▒▒0E▒▒D▒▒▒▒▒Tp: unknown file type
cpio: premature end of file

Version-Release number of selected component (if applicable):
rpm-4.11.3-43.el7.x86_64

How reproducible:
always


Steps to Reproduce:
1. rpm2cpio <rpmname.rpm> | cpio -imdv
2. Note that your console output is full of garbage.
3.

Actual results:
can't open rpm


Expected results:
rpm extracts, or error is reported.

Additional info:

Comment 3 Panu Matilainen 2022-02-25 07:40:17 UTC
This is to be expected, RHEL 9 uses a payload compression (zstd) which is not be available on RHEL 7.
Rpm tracks these incompatibility via rpmlib() dependencies so an attempt to 'rpm -U' the package on RHEL 7 will fail cleanly but rpm2cpio does not use these mechanisms.

Arguably rpm2cpio should detect an unsupported payload format though and error out instead of spitting the compressed data out as-is, OTOH that flaw can be utilized by piping to an external extractor if available. For this case, if 'zstd' is available, you should be able to extract the contents by piping through that, ie

    rpm2cpio foo.rpm | zstd -d | cpio

There should probably be an explicit switch to enable this behavior though, but this is not something that will get addressed in RHEL 7 at this point.