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 1937111 - Add cluster_exec_t default context for /usr/lib/pcs/pcs_snmp_agent
Summary: Add cluster_exec_t default context for /usr/lib/pcs/pcs_snmp_agent
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: selinux-policy
Version: 8.3
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: 8.5
Assignee: Zdenek Pytela
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-03-09 21:03 UTC by Reid Wahl
Modified: 2024-12-20 19:44 UTC (History)
13 users (show)

Fixed In Version: selinux-policy-3.14.3-75.el8
Doc Type: Bug Fix
Doc Text:
Cause: The /usr/lib/pcs/pcs_snmp_agent file has the default lib_t type which is incorrect. Consequence: The pcs_snmp_agent process doesn't have the permission to write to the /var/log/pcsd directory. As a result, the pcs_snmp_agent service fails to start. Fix: The /usr/lib/pcs/pcs_snmp_agent file now has the cluster_exec_t type. Result: The pcs_snmp_agent service starts correctly and is able to write to its logs.
Clone Of:
: 2029316 (view as bug list)
Environment:
Last Closed: 2021-11-09 19:42:58 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 5871071 0 None None None 2021-03-10 00:39:16 UTC
Red Hat Product Errata RHBA-2021:4420 0 None None None 2021-11-09 19:43:20 UTC

Description Reid Wahl 2021-03-09 21:03:06 UTC
Description of problem:

The pcs_snmp_agent service fails to start because /usr/lib/pcs/pcs_snmp_agent has the wrong context. It has lib_t when (AFAICT) it should have cluster_exec_t. Since it lacks cluster_exec_t, the pcs_snmp_agent process starts with context init_t, and it doesn't have permission to write to /var/log/pcsd.


Mar 09 12:30:27 fastvm-rhel-8-0-23 systemd[1]: Started SNMP agent for pacemaker cluster.
-- Subject: Unit pcs_snmp_agent.service has finished start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
-- 
-- Unit pcs_snmp_agent.service has finished starting up.
-- 
-- The start-up result is done.
Mar 09 12:30:28 fastvm-rhel-8-0-23 pcs_snmp_agent[82292]: Traceback (most recent call last):
Mar 09 12:30:28 fastvm-rhel-8-0-23 pcs_snmp_agent[82292]:   File "/usr/lib/pcs/pcs_snmp_agent", line 11, in <module>
Mar 09 12:30:28 fastvm-rhel-8-0-23 pcs_snmp_agent[82292]:     load_entry_point('pcs==0.10.6', 'console_scripts', 'pcs_snmp_agent')()
Mar 09 12:30:28 fastvm-rhel-8-0-23 pcs_snmp_agent[82292]:   File "/usr/lib/python3.6/site-packages/pcs/snmp/pcs_snmp_agent.py", line 79, in main
Mar 09 12:30:28 fastvm-rhel-8-0-23 pcs_snmp_agent[82292]:     setup_logging(is_debug())
Mar 09 12:30:28 fastvm-rhel-8-0-23 pcs_snmp_agent[82292]:   File "/usr/lib/python3.6/site-packages/pcs/snmp/pcs_snmp_agent.py", line 59, in setup_logging
Mar 09 12:30:28 fastvm-rhel-8-0-23 pcs_snmp_agent[82292]:     settings.LOG_FILE, encoding="utf8"
Mar 09 12:30:28 fastvm-rhel-8-0-23 pcs_snmp_agent[82292]:   File "/usr/lib64/python3.6/logging/handlers.py", line 437, in __init__
Mar 09 12:30:28 fastvm-rhel-8-0-23 pcs_snmp_agent[82292]:     logging.FileHandler.__init__(self, filename, mode, encoding, delay)
Mar 09 12:30:28 fastvm-rhel-8-0-23 pcs_snmp_agent[82292]:   File "/usr/lib64/python3.6/logging/__init__.py", line 1032, in __init__
Mar 09 12:30:28 fastvm-rhel-8-0-23 pcs_snmp_agent[82292]:     StreamHandler.__init__(self, self._open())
Mar 09 12:30:28 fastvm-rhel-8-0-23 pcs_snmp_agent[82292]:   File "/usr/lib64/python3.6/logging/__init__.py", line 1061, in _open
Mar 09 12:30:28 fastvm-rhel-8-0-23 pcs_snmp_agent[82292]:     return open(self.baseFilename, self.mode, encoding=self.encoding)
Mar 09 12:30:28 fastvm-rhel-8-0-23 pcs_snmp_agent[82292]: PermissionError: [Errno 13] Permission denied: '/var/log/pcsd/pcs_snmp_agent.log'
Mar 09 12:30:28 fastvm-rhel-8-0-23 systemd[1]: pcs_snmp_agent.service: Main process exited, code=exited, status=1/FAILURE
Mar 09 12:30:28 fastvm-rhel-8-0-23 systemd[1]: pcs_snmp_agent.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
-- 
-- The unit pcs_snmp_agent.service has entered the 'failed' state with result 'exit-code'.


# ll -Zd /usr/lib/pcs/pcs_snmp_agent /usr/sbin/pcsd /var/log/pcsd
-rwxr-xr-x. 1 root root system_u:object_r:lib_t:s0             403 Aug 11  2020 /usr/lib/pcs/pcs_snmp_agent
-rwxr-xr-x. 1 root root system_u:object_r:cluster_exec_t:s0    383 Aug 11  2020 /usr/sbin/pcsd
drwx------. 2 root root system_u:object_r:cluster_var_log_t:s0 159 Mar  7 03:46 /var/log/pcsd


PCS is part of the RHEL High Availability product. I've CC'd the PCS developers for any additions or corrections that they might have for this request.

-----

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

selinux-policy-targeted-3.14.3-54.el8

-----

How reproducible:

Always

-----

Steps to Reproduce:
1. Start pcs_snmp_agent.service with SELinux in Enforcing mode.

-----

Actual results:

The service fails with an error like the following:

Mar 09 12:30:28 fastvm-rhel-8-0-23 pcs_snmp_agent[82292]: PermissionError: [Errno 13] Permission denied: '/var/log/pcsd/pcs_snmp_agent.log'

-----

Expected results:

The service starts and writes to the /var/log/pcsd/pcs_snmp_agent.log file.

Comment 1 Reid Wahl 2021-03-10 00:40:10 UTC
It might make sense to also give cluster_exec_t context to /usr/lib/pcs/pcs_internal, although the current lib_t context hasn't caused any known problems for that file.

Comment 6 Zdenek Pytela 2021-07-28 15:33:52 UTC
I've submitted a Fedora PR to address the issue:
https://github.com/fedora-selinux/selinux-policy/pull/811

Comment 7 Zdenek Pytela 2021-07-28 20:15:36 UTC
Commit to backport:
commit f8bbececbc075ba7a6da112ab9f596bf7cd32ab7 (HEAD -> rawhide, upstream/rawhide)
Author: Zdenek Pytela <zpytela>
Date:   Wed Jul 28 17:32:26 2021 +0200

    Label /usr/lib/pcs/pcs_snmp_agent with cluster_exec_t

Comment 18 errata-xmlrpc 2021-11-09 19:42:58 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 (selinux-policy 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-2021:4420


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