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.
Description of problem:
When setting the SELinux to enforcing, "mail" command in the following mrtg script won't be executed as expected.
mrtg_alert.sh:
~~~
RCPT=mrtg-alert
echo "$YEAR/$MONTH/$DAY $HOUR:$MINUTE $PROG: $MESG" | mail -s "mrtg report" $RCPT
~~~
The root cause for this is multiple:
1. First mrtg_t executes "mail" (bin_t), running in caller context (mrtg_t), which then tries to create a temporary file
With current policy, mrtg_t domain cannot create temporary files in /tmp directory:
1.1 It cannot create nodes in the directory
# sesearch -A -s mrtg_t -t tmp_t -c dir -p add_name
--> nothing
1.2 It cannot writes to files
# sesearch -A -s mrtg_t -t tmp_t -c file -p write
--> nothing
2. Then later, assuming "mail" could create the temporary file, it will execute "sendmail" binary, which requires setting a special context (to execute as sendmail_t)
With current policy, mrtg_t cannot execute sendmail binary
# sesearch -A -s mrtg_t -t sendmail_exec_t -c file -p execute
--> nothing
I'm not sure allowing writing to "tmp_t" is wise, I think we need some alternate domain for files in "tmp_t" generated by the mail command, e.g. mrtg_tmp_t.
Version-Release number of selected component (if applicable):
RHEL7 and RHEL8
How reproducible:
Always
Steps to Reproduce:
1. Create a fake "mrtg" executable that will execute "mail" internally
# cat > /usr/local/bin/fake_mrtg << EOF
#!/bin/sh
echo "Foo" | mail -s "fake_mrtg" root@localhost
EOF
# chmod +x /usr/local/bin/fake_mrtg
# chcon -t mrtg_exec_t /usr/local/bin/fake_mrtg
2. Start it as a transient service
# systemd-run --unit=fake_mrgt /usr/local/bin/fake_mrtg
Actual results:
type=PROCTITLE msg=audit(07/04/2022 15:15:00.406:95) : proctitle=mail -s /usr/local/bin/fake_mrtg root@localhost
type=SYSCALL msg=audit(07/04/2022 15:15:00.406:95) : arch=x86_64 syscall=open success=no exit=EACCES(Permission denied) a0=0x1643820 a1=O_RDWR|O_CREAT|O_EXCL a2=0600 a3=0x62c2e7d4 items=0 ppid=1311 pid=1314 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=mail exe=/usr/bin/mailx subj=system_u:system_r:mrtg_t:s0 key=(null)
type=AVC msg=audit(07/04/2022 15:15:00.406:95) : avc: denied { write } for pid=1314 comm=mail name=tmp dev="dm-0" ino=16777287 scontext=system_u:system_r:mrtg_t:s0 tcontext=system_u:object_r:tmp_t:s0 tclass=dir permissive=0
Other AVCs are hidden because there is a dontaudit on "tmp_t" files
Expected results:
Works fine
Additional info:
Following rules are needed, *assuming it's wise to allow writing to /tmp"*:
~~~
sendmail_domtrans(mrtg_t)
allow mrtg_t tmp_t:dir { add_name remove_name write };
allow mrtg_t tmp_t:file { create setattr unlink write };
~~~
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-2023:2965
Description of problem: When setting the SELinux to enforcing, "mail" command in the following mrtg script won't be executed as expected. mrtg_alert.sh: ~~~ RCPT=mrtg-alert echo "$YEAR/$MONTH/$DAY $HOUR:$MINUTE $PROG: $MESG" | mail -s "mrtg report" $RCPT ~~~ The root cause for this is multiple: 1. First mrtg_t executes "mail" (bin_t), running in caller context (mrtg_t), which then tries to create a temporary file With current policy, mrtg_t domain cannot create temporary files in /tmp directory: 1.1 It cannot create nodes in the directory # sesearch -A -s mrtg_t -t tmp_t -c dir -p add_name --> nothing 1.2 It cannot writes to files # sesearch -A -s mrtg_t -t tmp_t -c file -p write --> nothing 2. Then later, assuming "mail" could create the temporary file, it will execute "sendmail" binary, which requires setting a special context (to execute as sendmail_t) With current policy, mrtg_t cannot execute sendmail binary # sesearch -A -s mrtg_t -t sendmail_exec_t -c file -p execute --> nothing I'm not sure allowing writing to "tmp_t" is wise, I think we need some alternate domain for files in "tmp_t" generated by the mail command, e.g. mrtg_tmp_t. Version-Release number of selected component (if applicable): RHEL7 and RHEL8 How reproducible: Always Steps to Reproduce: 1. Create a fake "mrtg" executable that will execute "mail" internally # cat > /usr/local/bin/fake_mrtg << EOF #!/bin/sh echo "Foo" | mail -s "fake_mrtg" root@localhost EOF # chmod +x /usr/local/bin/fake_mrtg # chcon -t mrtg_exec_t /usr/local/bin/fake_mrtg 2. Start it as a transient service # systemd-run --unit=fake_mrgt /usr/local/bin/fake_mrtg Actual results: type=PROCTITLE msg=audit(07/04/2022 15:15:00.406:95) : proctitle=mail -s /usr/local/bin/fake_mrtg root@localhost type=SYSCALL msg=audit(07/04/2022 15:15:00.406:95) : arch=x86_64 syscall=open success=no exit=EACCES(Permission denied) a0=0x1643820 a1=O_RDWR|O_CREAT|O_EXCL a2=0600 a3=0x62c2e7d4 items=0 ppid=1311 pid=1314 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=mail exe=/usr/bin/mailx subj=system_u:system_r:mrtg_t:s0 key=(null) type=AVC msg=audit(07/04/2022 15:15:00.406:95) : avc: denied { write } for pid=1314 comm=mail name=tmp dev="dm-0" ino=16777287 scontext=system_u:system_r:mrtg_t:s0 tcontext=system_u:object_r:tmp_t:s0 tclass=dir permissive=0 Other AVCs are hidden because there is a dontaudit on "tmp_t" files Expected results: Works fine Additional info: Following rules are needed, *assuming it's wise to allow writing to /tmp"*: ~~~ sendmail_domtrans(mrtg_t) allow mrtg_t tmp_t:dir { add_name remove_name write }; allow mrtg_t tmp_t:file { create setattr unlink write }; ~~~