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 2138102

Summary: [RFE] Allow containers to write to "container_log_t" - for log processing apps
Product: Red Hat Enterprise Linux 9 Reporter: Kashyap Chamarthy <kchamart>
Component: container-selinuxAssignee: Jindrich Novy <jnovy>
Status: CLOSED ERRATA QA Contact: Edward Shen <weshen>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 9.0CC: bdobreli, jnovy, lsm5, mboddu, tsweeney, weshen, ypu
Target Milestone: rcKeywords: FutureFeature, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: container-selinux-2.193.0-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-09 07:33:44 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:    
Bug Blocks: 1782128, 2093956    

Description Kashyap Chamarthy 2022-10-27 09:08:41 UTC
[This is a bug based on a suggestion by Dan Walsh in an email thread. For detailed context, please see this bug: https://bugzilla.redhat.com/show_bug.cgi?id=2093956 — 'swtpm' binary is denied write/"append" permissions to log files under /var/log/swtpm/]

Description
-----------

In short, from an  RHEL-9 container, '/usr/bin/swtpm' is currently unable to write to log files under /var/log/swtpm/ directory.                                                                                                                                                                  

Currently files under /var/log/swtpm/ get the label 'container_ro_file_t' — i.e. they're unable to write.

Dan Walsh suggested an addition to allow containers to read/write to "container_log_t", and "define it as a log file, so that log processing apps can use it."

Comment 2 Daniel Walsh 2022-10-27 11:02:16 UTC
I think we should just leave content on the host labeled as a logfile, and not make it specific to a container.

matchpathcon  /var/log/swtpm/
/var/log/swtpm	system_u:object_r:var_log_t:s0

Then either disable the SELinux separation for the container with 
podman run --security-opt label=disable ...

Or if running in Kubernetes use
type: spc_t.

If we really need to confine this container, then I could add a new type container_logwriter_t and then we could run this container with that type.

We currently have container_logreader_t.  Container_logwriter_t would be allowed to write to any file under /var/log (Types with attribute logfile)

Comment 3 Bogdan Dobrelya 2022-10-28 12:55:58 UTC
> Then either disable the SELinux separation for the container with 
podman run --security-opt label=disable ...

Just to not that for Tripleo/OSP that would require containerized logrotate, libvirt and may be more containers to run with --security-opt label=disable.
I'm not sure if that'd be a nice move, so my vote goes for the 2nd option.

Comment 4 Daniel Walsh 2022-10-28 14:15:12 UTC
https://github.com/containers/container-selinux/releases/tag/v2.191.0 adds container_logwriter_t.

Comment 9 errata-xmlrpc 2023-05-09 07:33:44 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 (container-selinux 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-2023:2206

Comment 11 Red Hat Bugzilla 2024-09-07 04:25:02 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 120 days