Bug 1881810 - vnstatd cannot start due to selinux policy
Summary: vnstatd cannot start due to selinux policy
Keywords:
Status: NEW
Alias: None
Product: Fedora EPEL
Classification: Fedora
Component: vnstat
Version: epel8
Hardware: x86_64
OS: Unspecified
unspecified
medium
Target Milestone: ---
Assignee: Adrian Reber
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-09-23 06:25 UTC by Drew Woodard
Modified: 2020-10-28 14:48 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: ---
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1648539 0 medium CLOSED SELinux is preventing vnstatd from 'read' accesses on the directory /var/lib/vnstat. 2021-02-22 00:41:40 UTC

Description Drew Woodard 2020-09-23 06:25:09 UTC
=====(DESCRIPTION OF PROBLEM)=====
the vnstat service won't run unless selinux is disabled


=====(VERSION NUMBERS)=====
centos linux 8.2.2004
vnstat-2.6-2.el8


=====(HOW REPRODUCIBLE)=====
always


=====(STEPS TO REPRODUCE)=====
download and install CentOS-8.2.2004-x86_64-dvd1.iso
reboot
dnf upgrade
reboot
dnf install epel-release
dnf install vnstat
systemctl enable vnstat
systemctl start vnstat


=====(EXPECTED RESULTS)=====
"systemctl status vnstat" would return:
active (running)


=====(ACTUAL RESULTS)=====
"systemctl status vnstat" returns:
(code=exited, status=238/STATE_DIRECTORY)


=====(ADDITIONAL INFO)=====
disabling selinux temporarily with "setenforce 0" allows vnstat to start and functional normally

errors like these are logged:
Failed to set up special execution directory in /var/lib: Permission denied
Failed at step STATE_DIRECTORY spawning /usr/sbin/vnstatd: Permission denied
Error: Failed to open database "/var/lib/vnstat/vnstat.db" in read/write mode.

"tail /var/log/audit/audit.log | audit2allow" shows:
allow init_t vnstatd_var_lib_t:dir setattr;

possibly related bug: 1648539

while this is a bug occurring on centos I assume(?) it's also occurring on rhel, and the package is from epel
if it turns out this bug is unrelated to rhel feel free to close/ignore

Comment 1 Ladar Levison 2020-10-28 14:33:00 UTC
The following SELinux policy module seems to fix the problem. These permissions need to be added to the vnstat module provided by the "selinux-policy-targeted" package.


#!bin/bash
cat <<-EOF > my-vnstatd.te
module my-vnstatd 1.0;

require {
	type vnstatd_var_lib_t;
	type init_t;
	class dir { mounton read setattr };
}

#============= init_t ==============
allow init_t vnstatd_var_lib_t:dir mounton;
allow init_t vnstatd_var_lib_t:dir { read setattr };
EOF

checkmodule -M -m -o my-vnstatd.mod my-vnstatd.te
semodule_package -o my-vnstatd.pp -m my-vnstatd.mod
semodule -X 300 -i my-vnstatd.pp

Comment 2 Ladar Levison 2020-10-28 14:48:47 UTC
Request for policy fix ... see:
https://bugzilla.redhat.com/show_bug.cgi?id=1892365


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