Bug 3656

Summary: rpm2cpio: Segmentation fault
Product: [Runtime] Package Management Issues Reporter: Yi Zhao <yi.zhao>
Component: RPMAssignee: Mark Hatle <mark.hatle>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Low CC: bluelightning, hongxu.jia, jeff.polk, kai.kang, liang.li2, mark.hatle, meta.mr.watcher, meta.watcher, n3npq, Qi.Chen, richard.purdie, ross.burton, sgw
Version: 1.4   
Target Milestone: Future   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Yi Zhao 2012-12-28 09:12:02 UTC
Image location: http://autobuilder.yoctoproject.org/pub/nightly/20121226-1/
Tree/Branch: poky/master
Git commit: 4a36a32567ecfbc7ce7b967803e6e23314953ef5

Download the rpm-common package from autobuilder: http://autobuilder.yoctoproject.org/pub/nightly/20121226-1/rpm/

Install this package to the target and run rpm2cpio to extract cpio archive from a rpm package:
###########
root@qemuarm:~# rpm -ivh rpm-common-5.4.9-r60.armv5te.rpm 
Preparing...                ########################################### [100%]
   1:rpm-common             ########################################### [100%]
root@qemuarm:~# 
root@qemuarm:~# rpm2cpio rpm-5.4.9-r60.armv5te.rpm 
Segmentation fault
##########

This command segfault on all target.
Comment 1 Kai Kang 2013-02-28 07:34:53 UTC
rpm config files are not parsed, so no "_db_path" defined. When query "_db_path", it returns nothing and causes segmentation fault.
Comment 2 Kai Kang 2013-04-17 09:17:52 UTC
Patch v2 has been sent to oe-core, and postpone it to 1.5
Comment 3 Jeff Johnson 2013-04-24 16:51:13 UTC
The simplest fix of all is to use rpm2cpio.sh, an ~38 line
shell script.
Comment 4 Jeff Polk 2014-07-31 15:05:36 UTC
Mark asked me to move this to future. The script works correctly but he'd like to keep the reminder to check whether it's fixed in future versions.
Comment 5 Jeff Johnson 2014-07-31 18:11:15 UTC
Using rpm2cpio.sh is still the best fix for Yocto imho.

The segfault comes from attempting to locate
the pubkey needed to verify the header signature
in the rpmdb Pubkeys index. The path to the
rpmdb is stored in in the %_dbpath macro.

The rpmdb pubkey lookup is now (rpm-5.4.15) skipped if %_dbpath
isn't set (which fixes the segfault).

Implicitly disabling package signature verification
depending on macro (mis-)configuration may not be
supportable when rpmlib needs to always verify signatures.
Comment 6 Ross Burton 2015-02-25 15:48:36 UTC
http://patchwork.openembedded.org/patch/59135/ is the patch that Kai sent, and Mark rejected it.  Mark/Kai - presumably this is still a problem - can someone revisit this and prepare a correct patch?
Comment 7 Mark Hatle 2015-02-25 15:58:10 UTC
This is still a bug, but we moved to using the script version of rpm2cpio on the rpm-native side.  Thus this is very low priority.

It might be fixed at some point in the future, but it's really an issue on how the recent binary versions of rpm2cpio inteface w/ the rpmlib and rpmlib interfaces with external files.  (None of that is actually needed for our usage case, thus the scripted version works fine.)

The bug was left open, because well.. it is a bug.  (very low priority) We're just going to continue to monitor the situation, and we'll fix it if/when the upstream design changes.

Again, this only affects rpm-native, not the target rpm.

--Mark
Comment 8 Jeff Johnson 2015-02-25 16:35:29 UTC
There's a modest improvement to rpm2cpio.sh for Cygwin
available here:

    http://stackoverflow.com/questions/18787375/how-do-i-extract-the-contents-of-an-rpm/25986787#25986787
Comment 9 Richard Purdie 2017-07-20 16:02:23 UTC
rpm2cpio works fine with rpm v4 so closing this a resolved.