Selinux policy blocks cache after restorecon
Concerned version
Version: %2.0.9
Platform: Apache / CentOS
Summary
Since #2254 (closed), the cache is stored in /var/cache/lemonldap-ng to avoid systemd private directory issues.
However, after running restorecon
on /var/cache/lemonldap-ng
, the files become tagged var_t instead of httpd_cache_t (upon initial creation). From this point on, /var/cache/lemonldap-ng
becomes polluted with temporary files
Logs
system_u:object_r:var_t:s0 .
system_u:object_r:var_t:s0 ./2
system_u:object_r:var_t:s0 ./2/d
system_u:object_r:var_t:s0 ./2/d/4
system_u:object_r:var_t:s0 ./2/d/4/2d4de2ba4d00f51dd7031724d2fbe7ff899ea508
system_u:object_r:httpd_cache_t:s0 ./2/d/4/_lj1q4t1OB
system_u:object_r:httpd_cache_t:s0 ./2/d/4/Gh6lS8HaWp
system_u:object_r:httpd_cache_t:s0 ./2/d/4/UIrWvLjhsY
audit.log:
type=AVC msg=audit(1606731077.821:963): avc: denied { getattr } for pid=11712 comm="index.fcgi" path="/var/cache/lemonldap-ng/lemonldap-ng-config/2/d/4/2d4de2ba4d00f51dd7031724d2fbe7ff899ea508" dev="dm-0" ino=4656864 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:var_t:s0 tclass=file permissive=0
Possible fixes
A temporary fix:
semanage fcontext --add -t httpd_cache_t -f a '/var/cache/lemonldap-ng(/.*)?'
However we need to integrate this modification in our RPMS
@xavierb can you give me some pointers on the proper way to do this? I found this doc https://fedoraproject.org/wiki/PackagingDrafts/SELinux#File_contexts but it seems pretty old, and adding semanage
as a LemonLDAP dependancy doesn't seem like a great idea.