Bug 1450277

Summary: `rpm -qp README.rpm` hangs when the 'README.rpm' is text file
Product: [Fedora] Fedora Reporter: Pavel Raiskup <praiskup>
Component: rpmAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 25CC: extras-qa, fedora, ffesti, gwync, hhorak, ignatenko, jmlich83, kardos.lubos, kevin, mhlavink, mjw, packaging-team-maint, pokorra.mailinglists, praiskup, tis, viktor.vix.jancik, vmukhame
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1449790 Environment:
Last Closed: 2017-05-12 08:54:21 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: 1449517, 1449790    
Bug Blocks:    
Attachments:
Description Flags
Example file none

Description Pavel Raiskup 2017-05-12 06:56:36 UTC
Created attachment 1278076 [details]
Example file

The /usr/share/doc/roundcubemail/README.rpm text file is attached.

This is what I get:

    $ rpm -qp  /tmp/README.rpm 
    error: open of Additional failed: No such file or directory
    error: open of installation failed: No such file or directory
    error: open of and failed: No such file or directory
    error: open of update failed: No such file or directory
    error: open of information: failed: No such file or directory
    error: open of Upstream failed: No such file or directory
    error: open of documentation: failed: No such file or directory
    ^Cerror: open of http://trac.roundcube.net/wiki failed: Interrupted
    system call
    error: open of Notice failed: No such file or directory
    ^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^Z
    [2]+  Stopped                 rpm -qp /tmp/README.rpm
    $ killall -9 rpm
    [2]+  Killed                  rpm -qp /tmp/README.rpm

Seems like rpm is also trying to reach internet?


+++ This bug was initially created as a clone of Bug #1449790 +++
+++ This bug was initially created as a clone of Bug #1449517 +++

Comment 1 Florian Festi 2017-05-12 08:54:21 UTC
Well, works as intended ... ehm ... may be ...

RPM allows passing manifest files at the command line. These files are supposed to contain file names of packages or other manifest files.

So rpm tries to open all these "file names".

As far as I can see it does not try to access the internet but tries to open the URL as a file name (and fails).

There seems to be an issue with rpm treating the "-" from the file as stdin. This results in rpm waiting for the user to type in more package names. Removing all the standalone "-" signs makes rpm go through the file without stopping.

Upstream has a few more checks in place now rejecting the file right away. There also is some code to not open stdin on encountering "-".

Comment 2 Pavel Raiskup 2017-05-12 09:48:52 UTC
> As far as I can see it does not try to access the internet but tries to open
> the URL as a file name (and fails).

$ strace -e execve -f rpm -qp /tmp/README.rpm
....
strace: Process 31757 attached
[pid 31757] execve("/usr/bin/curl", ["/usr/bin/curl", "--silent", "--show-error", "--fail", "--globoff", "--location", "-o", "/var/tmp/rpm-tmp.lQSoq1", "http://trac.roundcube.net/wiki"], [/* 90 vars */]) = 0
....
strace: Process 31760 attached
[pid 31760] execve("/usr/bin/curl", ["/usr/bin/curl", "--silent", "--show-error", "--fail", "--globoff", "--location", "-o", "/var/tmp/rpm-tmp.rhKYfQ", "http://trac.roundcube.net/wiki"], [/* 90 vars */]) = 0
....

> Upstream has a few more checks in place now rejecting the file right
> away. There also is some code to not open stdin on encountering "-".

Ok, good to know.  What is your suggestion for the 'less' (bug 1449790)
issue?  Can I detect (without file) that "README.rpm" is manifest file,
and open the file as text file (without using file)?  Thanks!

Comment 3 Florian Festi 2017-05-12 10:08:46 UTC
I think this is the wrong question. The manifest files are not supposed to end with .rpm. So the issue here is not detecting manifest files names *.rpm but detecting any improper files named *.rpm. There has been a lot of work improving file checks upstream (by Panu mostly).

Proper manifest files can and should end with .txt or something like that. So they already should be listed correctly.

So the right answer here is rpm becoming more robust when being passed garbage. This is something happening right now.

Wrt less: Using file instead of the ending alone would make things more robust. There is no real way around that other that reimplementing the check used by file: looking for the magic bytes at the beginning of an rpm package.

Comment 4 Pavel Raiskup 2017-05-12 10:32:11 UTC
> Proper manifest files can and should end with .txt or something like that. So
> they already should be listed correctly.

Ah, OK.  Then it should be safe to do 'rpm -qp --nomanifest', do I get it right?

Comment 5 Florian Festi 2017-05-12 10:33:31 UTC
yes.