Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1826047

Summary: Missing SELlinux rule prevents pmlogger from establishing secure communication with a remote pmcd
Product: Red Hat Enterprise Linux 8 Reporter: Carlos Santos <casantos>
Component: pcpAssignee: Andreas Gerstmayr <agerstmayr>
Status: CLOSED ERRATA QA Contact: Jan Kurik <jkurik>
Severity: high Docs Contact:
Priority: unspecified    
Version: 8.3CC: agerstmayr, b.prins, jkurik, mgoodwin, nathans, patrickm
Target Milestone: rcKeywords: Bugfix, Triaged
Target Release: 8.0Flags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: pcp-5.1.1-3 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 03:00:37 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: 1792971    
Bug Blocks:    
Attachments:
Description Flags
Output of "grep '^type=AVC.*pcp' /var/log/audit/audit.log | audit2allow -w" none

Description Carlos Santos 2020-04-20 18:37:36 UTC
Created attachment 1680350 [details]
Output of "grep '^type=AVC.*pcp' /var/log/audit/audit.log | audit2allow -w"

Description of problem:

Customer configured pmdc to accept secure connections as described in

    https://pcp.io/docs/lab.secureclient.html

After that it was possible to fetch data interactively, e.g. with

    $ pminfo -h remote.host -f kernel.uname.nodename

but it was not possible to establish a secure connection between pmlogger and
the remote pmdc due to AVC denials (see attached audit2allow.txt).

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

    # cat /etc/redhat-release 
    Red Hat Enterprise Linux Server release 7.8 (Maipo)

    # rpm -q pcp
    pcp-4.3.2-6.el7.x86_64

How reproducible:

Always

Steps to Reproduce:

1. Generate the CA, server and client certificates, as shown in the CA Setup
   session of 

   https://pcp.io/docs/lab.secureclient.html

2. Copy the CA and server certificates to the server machine and configure
   pmcd as described in the Collector Setup session of the same document.
   Enable and start the pmcd service with

     # systemctl enable --now pmcd
   
2. Copy the CA and server certificates to the server machine and create the
   pcp-specific certficate database path:

     # echo > /tmp/empty
     # certutil -d sql:/etc/pcp/nssdb -N -f /tmp/empty 
     # certutil -d sql:/etc/pcp/nssdb -A -t "CT,," -n "Root CA" \
        -i ./rootCA.crt
     # certutil -d sql:/etc/pcp/nssdb -A -t "P,," -n "pmclient_cert" \
       -i pmclient.crt
     # pk12util -i pmclient_pkcs12.key -d sql:/etc/pcp/nssdb

   Ensure that /etc/pcp/nssdb has the same SELinux context as /etc/pki/nssdb

     # semanage fcontext -a -e /etc/pki/nssdb '/etc/pcp/nssdb(/.*)?'
     # restorecon -R -F -vv /etc/pcp/nssdb
     # ls -lZ /etc/pcp/nssdb
    -rw-------. pcp pcp unconfined_u:object_r:cert_t:s0  cert9.db
    -rw-------. pcp pcp unconfined_u:object_r:cert_t:s0  key4.db
    -rw-------. pcp pcp unconfined_u:object_r:cert_t:s0  pkcs11.txt

3. Test if the secure communication works

     # export PCP_SECURE_SOCKETS=enforce
     # export PCP_ALLOW_BAD_CERT_DOMAIN=1
     # export PCP_ALLOW_SERVER_SELF_CERT=1
     # export PCP_SECURE_DB_PATH=/etc/pcp/nssdb
     # pminfo -h rhel-7-2 -f kernel.uname.nodename

     kernel.uname.nodename
         value "rhel-7-2.example.com"

4. Configure pmlogger to fetch data from the remote pmcd

     # pmlogconf -c -r -h rhel-7-2.example.com \
       /var/lib/pcp/config/pmlogger/config.rhel-7-2

     Create /etc/pcp/pmlogger/control.d/rhel-7-2.example.com containing

     #--------------------------------------------------------------------------------------------------------------------
     $PCP_SECURE_SOCKETS=enforce;        export PCP_SECURE_SOCKETS
     $PCP_ALLOW_BAD_CERT_DOMAIN=1;       export PCP_ALLOW_BAD_CERT_DOMAIN
     $PCP_ALLOW_SERVER_SELF_CERT=1;      export PCP_ALLOW_SERVER_SELF_CERT
     $PCP_SECURE_DB_PATH=/etc/pcp/nssdb; export PCP_SECURE_DB_PATH

     rhel-7-2.example.com   n   n   PCP_LOG_DIR/pmlogger/rhel-7-2.example.com      -r -T24h10m -c config.rhel-7-2 -v 100Mb
     #--------------------------------------------------------------------------------------------------------------------

   Start pmlogger with

     # systemctl enable --now pmlogger
     # cat /var/log/pcp/pmlogger/rhel-7-2.example.com/pmlogger.log

Actual results:

The /var/log/pcp/pmlogger/rhel-7-2.example.com/pmlogger.log file contains

    pmlogger: Cannot connect to PMCD on host "rhel-7-2.example.com": No cipher suites are present and enabled in this program.

The /var/log/audit/audit.log file contains lots of AVC...denied messages (see
attached output of the command

    # grep '^type=AVC.*pcp' /var/log/audit/audit.log | audit2allow -w

Expected results:

pmlogger should be able to establish a secure connection.

Additional info:

Customer was instructed to temporarily flip SELinux to permissive.

Comment 2 Carlos Santos 2020-04-20 19:10:40 UTC
In step 2, the first one :-), it is also necessary to set the firewall

    # firewall-cmd --permanent --zone=public --add-service=pmcd
    # firewall-cmd --reload

Comment 5 Andreas Gerstmayr 2020-05-28 14:25:28 UTC
fixed in

commit 8b62d5f12b91c69612c1b9c155a8cbca63a4dd78
Author: Andreas Gerstmayr <agerstmayr>
Date:   Tue May 19 16:05:27 2020 +0200

    libpcp: open NSSDB readonly for clients
    
    Resolves: RedHat BZ #1826047

will be included in the next build

Comment 8 Jan Kurik 2020-07-15 19:26:50 UTC
The issue described in this bug is fixed in the pcp-5.1.1-3.el8 build. However a similar issue appears when pmcd is opening NSS database. The pmcd selinux issue is now tracked in bz1857396.

Comment 11 errata-xmlrpc 2020-11-04 03:00:37 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 (pcp bug fix and enhancement update), 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://access.redhat.com/errata/RHBA-2020:4684