RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1332025 - Inspection does not parse /etc/redhat-release containing "Derived from Red Hat Enterprise Linux 7.1 (Source)"
Summary: Inspection does not parse /etc/redhat-release containing "Derived from Red Ha...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libguestfs
Version: 7.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 7.3
Assignee: Richard W.M. Jones
QA Contact:
URL:
Whiteboard:
Depends On: 1218766
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-05-01 10:02 UTC by Richard W.M. Jones
Modified: 2016-11-03 18:00 UTC (History)
3 users (show)

Fixed In Version: libguestfs-1.32.4-1.el7.x86_64
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-03 18:00:05 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:2576 0 normal SHIPPED_LIVE Moderate: libguestfs and virt-p2v security, bug fix, and enhancement update 2016-11-03 12:06:51 UTC

Description Richard W.M. Jones 2016-05-01 10:02:05 UTC
Description of problem:

(Reported by novegin @ IRC)

novegin found a CentOS cloud image that contains the file
/etc/redhat-release containing:

  Derived from Red Hat Enterprise Linux 7.1 (Source)

Our inspection code cannot parse that, thinking that the
version is 0.0, resulting in several negative consequences,
not least that we then infer that the package manager is
up2date.

Easy reproducer is:

virt-builder centos-7.1 \
  --write '/etc/redhat-release:Derived from Red Hat Enterprise Linux 7.1 (Source)'
virt-inspector -a centos-7.1.img

As well as fixing the parsing problem, we should also make
sure that we don't try to infer the package manager / format
when the major version is obviously bogus.

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

libguestfs-1.33.23-1.fc25.x86_64 and earlier versions.

How reproducible:

100%

Steps to Reproduce:
1. See reproducer above.

Comment 1 Richard W.M. Jones 2016-05-01 10:05:56 UTC
The cloud image is the standard CentOS image from
http://cloud.centos.org/centos/7/images/

They have split the release information out to
/etc/centos-release so we should parse that file in
preference to /etc/redhat-release.

This also caused issues for facter:
https://tickets.puppetlabs.com/browse/FACT-893
and the facter bug links to more info here:
https://lists.centos.org/pipermail/centos-devel/2015-February/012876.html

Comment 2 Richard W.M. Jones 2016-05-01 10:06:35 UTC
/etc/centos-release contains:
CentOS Linux release 7.2.1511 (Core)

Comment 3 Pino Toscano 2016-05-02 14:44:06 UTC
The cloud images are detected properly:
$ wget http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2
$ virt-inspector -a CentOS-7-x86_64-GenericCloud.qcow2
<?xml version="1.0"?>
<operatingsystems>
  <operatingsystem>
    <root>/dev/sda1</root>
    <name>linux</name>
    <arch>x86_64</arch>
    <distro>centos</distro>
    <product_name>CentOS Linux release 7.2.1511 (Core) </product_name>
    <major_version>7</major_version>
    <minor_version>2</minor_version>
    <package_format>rpm</package_format>
    <package_management>yum</package_management>
[...]

Also, this has been fixed one year ago in CentOS, see:
https://lists.centos.org/pipermail/centos-announce/2015-April/021010.html

(In reply to Richard W.M. Jones from comment #0)
> virt-builder centos-7.1 \
>   --write '/etc/redhat-release:Derived from Red Hat Enterprise Linux 7.1
> (Source)'
> virt-inspector -a centos-7.1.img

This is not a valid reproducer though, since /etc/redhat-release is a symlink to /etc/centos-release, which means the old content of centos-release is lost and there's no way to parse its version information again.
Neither using the plain centos-7.0 template we provide triggers the bug.

If the disk image is a real one (i.e. not forged manually, like above), I'd like to inspect it manually.

Comment 4 Pino Toscano 2016-05-02 14:44:24 UTC
(In reply to Richard W.M. Jones from comment #0)
> As well as fixing the parsing problem, we should also make
> sure that we don't try to infer the package manager / format
> when the major version is obviously bogus.

This is what happens in src/inspect.c:

  void
  guestfs_int_check_package_management (guestfs_h *g, struct inspect_fs *fs)
  {
    switch (fs->distro) {
  [...]
    case OS_DISTRO_REDHAT_BASED:
    case OS_DISTRO_RHEL:
    case OS_DISTRO_CENTOS:
    case OS_DISTRO_SCIENTIFIC_LINUX:
    case OS_DISTRO_ORACLE_LINUX:
      if (fs->major_version >= 5)
        fs->package_management = OS_PACKAGE_MANAGEMENT_YUM;
      else
        fs->package_management = OS_PACKAGE_MANAGEMENT_UP2DATE;
      break;

Maybe a different logic can be setting UP2DATE when version_major is > 0 && < 5, although I'm not sure it would that much better.

Comment 5 Richard W.M. Jones 2016-05-04 11:58:09 UTC
Yes Pino is completely correct here.  This is fixed by:

commit 1ff463e8692aae4313bd5b42bb6f09932bb63392
Author: Pino Toscano <ptoscano>
Date:   Fri May 29 16:01:26 2015 +0200

    inspection: fix CentOS 7 detection
    
    In newer CentOS 7 versions /etc/redhat-release says that the distro is
    derived from RHEL, so we need to look at /etc/centos-release for
    actually identifying it as CentOS.
    
    The old code is needed as sub-case of /etc/redhat-release, as on
    CentOS < 7 that file is a symlink to /etc/centos-release.

This is a RHEL 7.2-only bug which will be fixed by the rebase.

Comment 6 Richard W.M. Jones 2016-05-04 12:30:49 UTC
(In reply to Pino Toscano from comment #3)
> If the disk image is a real one (i.e. not forged manually, like above), I'd
> like to inspect it manually.

The disk image is:
http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1503.qcow2
which was released before the fix announced in comment 3.

This is not reproducible with upstream libguestfs, which correctly
displays the version of the guest as 7.1 and gives the right
package management tool (yum).

However it is also reproducible with RHEL 7.2:

$ virt-inspector CentOS-7-x86_64-GenericCloud-1503.qcow2
...
    <major_version>0</major_version>
    <minor_version>0</minor_version>
    <package_format>rpm</package_format>
    <package_management>up2date</package_management>
...

It is fixed in our current RHEL 7.3 package (libguestfs-1.32.4-1.el7.x86_64).

Comment 7 Richard W.M. Jones 2016-05-04 13:24:21 UTC
Couple of additional patches we might consider backporting:

https://www.redhat.com/archives/libguestfs/2016-May/msg00016.html
https://www.redhat.com/archives/libguestfs/2016-May/msg00017.html

Comment 8 Richard W.M. Jones 2016-05-04 21:54:07 UTC
Those two patches are now upstream:
https://github.com/libguestfs/libguestfs/commit/5470f059c2e45342638a598ac3515013e05aba12
https://github.com/libguestfs/libguestfs/commit/547662d9f6cea869d5edefd7e4612f070fa73143

They are optional in terms of fixing this bug (which is
already fixed), but improve the error messages if this
situation happens again in future.

Comment 10 Xianghua Chen 2016-06-01 05:23:31 UTC
Verified with the packages:
libguestfs-1.32.4-3.el7.x86_64

Verify steps:
1. Download the image:
# wget http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1503.qcow2
2. There are two release file :
# virt-cat -a CentOS-7-x86_64-GenericCloud-1503.qcow2 /etc/centos-release 
CentOS Linux release 7.1.1503 (Core)
# virt-cat -a CentOS-7-x86_64-GenericCloud-1503.qcow2 /etc/redhat-release
Derived from Red Hat Enterprise Linux 7.1 (Source)
3. # virt-inspector -a CentOS-7-x86_64-GenericCloud-1503.qcow2
<?xml version="1.0"?>
<operatingsystems>
  <operatingsystem>
    <root>/dev/sda1</root>
    <name>linux</name>
    <arch>x86_64</arch>
    <distro>centos</distro>
    <product_name>CentOS Linux release 7.1.1503 (Core) </product_name>
    <major_version>7</major_version>
    <minor_version>1</minor_version>
... ...


So Verified.

Comment 12 errata-xmlrpc 2016-11-03 18:00:05 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/RHSA-2016-2576.html


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