Bug 1450277 - `rpm -qp README.rpm` hangs when the 'README.rpm' is text file
Summary: `rpm -qp README.rpm` hangs when the 'README.rpm' is text file
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: 25
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Packaging Maintenance Team
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 1449517 1449790
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-05-12 06:56 UTC by Pavel Raiskup
Modified: 2017-05-12 10:33 UTC (History)
17 users (show)

Fixed In Version:
Clone Of: 1449790
Environment:
Last Closed: 2017-05-12 08:54:21 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Example file (2.60 KB, text/plain)
2017-05-12 06:56 UTC, Pavel Raiskup
no flags Details

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.


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