Bug 2152418

Summary: SELinux denied { map } on /var/lib/pdns/*
Product: [Fedora] Fedora EPEL Reporter: Carlos Mogas da Silva <r3pek>
Component: pdnsAssignee: Morten Stevens <mstevens>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: epel9CC: mstevens, ruben, sander
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-06-06 08:56:29 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:

Description Carlos Mogas da Silva 2022-12-11 18:27:26 UTC
Description of problem:

Setting up PowerDNS with an SQLite database currently fails to start do to a SELinux permission fail when PDNS tries to `map` the sqlite -shm file.


Version-Release number of selected component (if applicable):
4.6.2-1.el9


How reproducible:
Everytime


Steps to Reproduce:
1. dnf install pdns pdns-backend-sqlite
2. edit /etc/pdns/pdns.conf to use the sqlite backend
3. setup an sqlite database on /var/lib/pdns/
4. try to start the pdns

Actual results:
after setting all the correct selinux permissions, audit.log shows this:

type=AVC msg=audit(1670783172.019:9025): avc:  denied  { map } for  pid=21704 comm="pdns_server" path="/var/lib/pdns/r3pek.org.sqlite-shm" dev="dm-0" ino=50763508 scontext=system_u:system_r:pdns_t:s0 tcontext=system_u:object_r:pdns_var_lib_t:s0 tclass=file permissive=0


Expected results:
pdns should start normally

Additional info:
[root@dns01 pdns]# pwd
/var/lib/pdns
[root@dns01 pdns]# ls -lhZa
total 108K
drwx------.  2 pdns pdns system_u:object_r:pdns_var_lib_t:s0   86 Dec 11 18:15 .
drwxr-xr-x. 25 root root system_u:object_r:var_lib_t:s0      4.0K Dec 11 18:03 ..
-rw-------.  1 pdns pdns system_u:object_r:pdns_var_lib_t:s0  72K Dec 11 18:15 r3pek.org.sqlite
-rw-------.  1 pdns pdns system_u:object_r:pdns_var_lib_t:s0  32K Dec 11 18:27 r3pek.org.sqlite-shm
-rw-------.  1 pdns pdns system_u:object_r:pdns_var_lib_t:s0    0 Dec 11 18:15 r3pek.org.sqlite-wal

Comment 1 Carlos Mogas da Silva 2022-12-11 18:34:42 UTC
OK, after using audit2why I've found out that we can use `setsebool -P domain_can_mmap_files 1` to allow for this behaviour.

Please close if NOTABUG.