| 1 |
# Author: Simon Deziel |
| 2 |
# vim:syntax=apparmor |
| 3 |
#include <tunables/global> |
| 4 |
|
| 5 |
profile unbound /usr/sbin/unbound flags=(attach_disconnected) { |
| 6 |
#include <abstractions/base> |
| 7 |
#include <abstractions/nameservice> |
| 8 |
#include <abstractions/openssl> |
| 9 |
|
| 10 |
# chown (chgrp) the Unix control socket |
| 11 |
capability chown, |
| 12 |
# chmod the Unix control socket |
| 13 |
capability fowner, |
| 14 |
capability fsetid, |
| 15 |
|
| 16 |
capability net_bind_service, |
| 17 |
capability setgid, |
| 18 |
capability setuid, |
| 19 |
capability sys_chroot, |
| 20 |
capability sys_resource, |
| 21 |
|
| 22 |
# root hints from dns-data-root |
| 23 |
/usr/share/dns/root.* r, |
| 24 |
|
| 25 |
# non-chrooted paths |
| 26 |
/etc/unbound/** r, |
| 27 |
owner /etc/unbound/*.key* rw, |
| 28 |
# explicitly deny (and audit) attempts to write to the key files |
| 29 |
# this should be unnecessary after switch to /run/unbound.ctl control socket |
| 30 |
# (here and below) |
| 31 |
audit deny /etc/unbound/unbound_control.{key,pem} rw, |
| 32 |
audit deny /etc/unbound/unbound_server.key w, |
| 33 |
|
| 34 |
# chrooted paths |
| 35 |
# unbound can be chrooted into /etc/unbound (upstream default) with |
| 36 |
# /var/lib/unbound/ bind-mounted to /etc/unbound/var/lib/unbound/, |
| 37 |
# or it can be chrooted into /var/lib/unbound/ with /etc/unbound/ copied |
| 38 |
# into there (previous debian package default). |
| 39 |
/{,etc/unbound/}var/lib/unbound/** r, |
| 40 |
owner /{,etc/unbound/}var/lib/unbound/** rw, |
| 41 |
audit deny /{,etc/unbound/}var/lib/unbound/**/unbound_control.{key,pem} rw, |
| 42 |
audit deny /{,etc/unbound/}var/lib/unbound/**/unbound_server.key w, |
| 43 |
|
| 44 |
/usr/sbin/unbound mr, |
| 45 |
|
| 46 |
/run/systemd/notify w, |
| 47 |
/run/unbound.pid rw, |
| 48 |
|
| 49 |
# Unix control socket |
| 50 |
/run/unbound.ctl rw, |
| 51 |
|
| 52 |
#include <local/usr.sbin.unbound> |
| 53 |
} |