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 1795923 - logrotate cannot operate on CIFS file systems
Summary: logrotate cannot operate on CIFS file systems
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: selinux-policy
Version: 8.1
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: 8.3
Assignee: Zdenek Pytela
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-01-29 08:55 UTC by Renaud Métrich
Modified: 2023-09-07 21:37 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-04 01:56:01 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) 4786811 0 None None None 2020-02-04 09:43:19 UTC
Red Hat Product Errata RHBA-2020:4528 0 None None None 2020-11-04 01:56:25 UTC

Description Renaud Métrich 2020-01-29 08:55:13 UTC
This bug was initially created as a copy of Bug #1795681

I am copying this bug because: 

Also applies to RHEL 8


Description of problem:

Although logrotate can operate on NFS file systems thanks to logrotate_use_nfs boolean, a similar set of rules is missing for CIFS file systems.
Customers hitting this need to create the following custom policy:

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
gen_require(`
	type logrotate_t;
')

gen_tunable(logrotate_use_cifs, false)

tunable_policy(`logrotate_use_cifs',`
	fs_manage_cifs_files(logrotate_t)
	fs_manage_cifs_dirs(logrotate_t)
	fs_manage_cifs_symlinks(logrotate_t)
')
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Please integrate this in the standard policy.


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

selinux-policy-3.14.3-20.el8.noarch

How reproducible:

Always


Steps to Reproduce:
1. Set up a CIFS mount point

On a CIFS server:

# yum -y install samba

/etc/samba/smb.conf:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
[share]
	comment = CIFS SHARE
	path = /mnt
	writeable = yes
	browseable = yes
	public = yes
	create mask = 0644
	directory mask = 0755
	force user = root
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

# systemctl restart smb
# useradd smbuser
# smbpasswd -a smbuser
# systemctl stop firewalld

On the client system:

# yum -y install cifs-utils
# mkdir /my_cifs_mount
# mount -t cifs -o username=smbuser,password=smbuser,rw //192.168.122.201/share /my_cifs_mount


2. Create a logrotate file to copy logs after rotation to the CIFS mount point

e.g. /etc/logrotate.d/cifs:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
/var/log/cifs.log
{
    missingok
    daily
    copytruncate
    rotate 7

    postrotate
        cp /var/log/cifs.log-* /my_cifs_mount
    endscript
}
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

3. Populate the file

  # echo "FOO" >> /var/log/cifs.log

4. Execute logrotate

  # runcon -u system_u -r system_r -t logrotate_t logrotate -v -f /etc/logrotate.d/cifs

Actual results:

AVCs

time->Wed Jan 29 09:53:44 2020
type=PROCTITLE msg=audit(1580288024.306:165): proctitle=6370002F7661722F6C6F672F636966732E6C6F672E31002F7661722F6C6F672F636966732E6C6F672E32002F7661722F6C6F672F636966732E6C6F672E33002F7661722F6C6F672F636966732E6C6F672E34002F7661722F6C6F672F636966732E6C6F672E35002F6D795F636966735F6D6F756E74
type=PATH msg=audit(1580288024.306:165): item=0 name="/my_cifs_mount/cifs.log.1" inode=2772 dev=00:2e mode=0100755 ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:cifs_t:s0 nametype=NORMAL cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0
type=CWD msg=audit(1580288024.306:165): cwd="/root"
type=SYSCALL msg=audit(1580288024.306:165): arch=c000003e syscall=257 success=no exit=-13 a0=ffffff9c a1=55b282e20ee0 a2=201 a3=0 items=1 ppid=18144 pid=18145 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=2 comm="cp" exe="/usr/bin/cp" subj=system_u:system_r:logrotate_t:s0-s0:c0.c1023 key=(null)
type=AVC msg=audit(1580288024.306:165): avc:  denied  { write } for  pid=18145 comm="cp" name="cifs.log.1" dev="cifs" ino=2772 scontext=system_u:system_r:logrotate_t:s0-s0:c0.c1023 tcontext=system_u:object_r:cifs_t:s0 tclass=file permissive=0
...

Comment 3 Zdenek Pytela 2020-05-26 13:58:46 UTC
I've submitted a Fedora PR to address the issue:
https://github.com/fedora-selinux/selinux-policy-contrib/pull/251

Comment 17 errata-xmlrpc 2020-11-04 01:56:01 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-2020:4528


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