1*561252a2Schristos; For further details about the directives used in this unit file, including
2*561252a2Schristos; the below, please refer to systemd's official documentation, available at
3*561252a2Schristos; https://www.freedesktop.org/software/systemd/man/systemd.exec.html.
4*561252a2Schristos;
5*561252a2Schristos;
6*561252a2Schristos;   - `ProtectSystem=strict` implies we mount the entire file system hierarchy
7*561252a2Schristos;     read-only for the processes invoked by the unit except for the API file
8*561252a2Schristos;     system subtrees /dev, /proc and /sys (which are protected by
9*561252a2Schristos;     PrivateDevices=, ProtectKernelTunables=, ProtectControlGroups=).
10*561252a2Schristos;
11*561252a2Schristos;   - `PrivateTmp=yes` secures access to temporary files of the process, and
12*561252a2Schristos;     makes sharing between processes via /tmp or /var/tmp impossible.
13*561252a2Schristos;
14*561252a2Schristos;   - `ProtectHome=yes` makes the directories /home, /root, and /run/user
15*561252a2Schristos;     inaccessible and empty for processes invoked by the unit.
16*561252a2Schristos;
17*561252a2Schristos;   - `ProtectControlGroups=yes` makes the Linux Control Groups hierarchies
18*561252a2Schristos;     (accessible through /sys/fs/cgroup) read-only to all processes invoked by
19*561252a2Schristos;     the unit. It also implies `MountAPIVFS=yes`.
20*561252a2Schristos;
21*561252a2Schristos;   - `RuntimeDirectory=unbound` creates a /run/unbound directory, owned by the
22*561252a2Schristos;     unit User and Group with read-write permissions (0755) as soon as the
23*561252a2Schristos;     unit starts. This allows unbound to store its pidfile. The directory and
24*561252a2Schristos;     its content are automatically removed by systemd when the unit stops.
25*561252a2Schristos;
26*561252a2Schristos;   - `NoNewPrivileges=yes` ensures that the service process and all its
27*561252a2Schristos;     children can never gain new privileges through execve().
28*561252a2Schristos;
29*561252a2Schristos;   - `RestrictSUIDSGID=yes` ensures that any attempts to set the set-user-ID
30*561252a2Schristos;     (SUID) or set-group-ID (SGID) bits on files or directories will be denied.
31*561252a2Schristos;
32*561252a2Schristos;   - `RestrictRealTime=yes` ensures that any attempts to enable realtime
33*561252a2Schristos;     scheduling in a process invoked by the unit will be denied.
34*561252a2Schristos;
35*561252a2Schristos;   - `RestrictNamespaces=yes` ensures that access to any kind of namespacing
36*561252a2Schristos;     is prohibited.
37*561252a2Schristos;
38*561252a2Schristos;   - `LockPersonality=yes` locks down the personality system call so that the
39*561252a2Schristos;     kernel execution domain may not be changed from the default.
40*561252a2Schristos;
41*561252a2Schristos;
42762909a6Schristos[Unit]
43762909a6SchristosDescription=Validating, recursive, and caching DNS resolver
44762909a6SchristosDocumentation=man:unbound(8)
45*561252a2SchristosAfter=network-online.target
46*561252a2SchristosBefore=nss-lookup.target
47*561252a2SchristosWants=network-online.target nss-lookup.target
48762909a6Schristos
49762909a6Schristos[Install]
50762909a6SchristosWantedBy=multi-user.target
51762909a6Schristos
52762909a6Schristos[Service]
53f337475aSchristosExecReload=+/bin/kill -HUP $MAINPID
54*561252a2SchristosExecStart=@UNBOUND_SBIN_DIR@/unbound -d -p
55762909a6SchristosNotifyAccess=main
56762909a6SchristosType=notify
57*561252a2SchristosCapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_SETGID CAP_SETUID CAP_SYS_CHROOT CAP_SYS_RESOURCE CAP_NET_RAW
58762909a6SchristosMemoryDenyWriteExecute=true
59762909a6SchristosNoNewPrivileges=true
60762909a6SchristosPrivateDevices=true
61762909a6SchristosPrivateTmp=true
62762909a6SchristosProtectHome=true
63762909a6SchristosProtectControlGroups=true
64762909a6SchristosProtectKernelModules=true
65762909a6SchristosProtectSystem=strict
66*561252a2SchristosRuntimeDirectory=unbound
67*561252a2SchristosConfigurationDirectory=unbound
68*561252a2SchristosStateDirectory=unbound
69*561252a2SchristosRestrictAddressFamilies=AF_INET AF_INET6 AF_NETLINK AF_UNIX
70762909a6SchristosRestrictRealtime=true
71762909a6SchristosSystemCallArchitectures=native
72762909a6SchristosSystemCallFilter=~@clock @cpu-emulation @debug @keyring @module mount @obsolete @resources
73f337475aSchristosRestrictNamespaces=yes
74f337475aSchristosLockPersonality=yes
75f337475aSchristosRestrictSUIDSGID=yes
76*561252a2SchristosReadWritePaths=@UNBOUND_RUN_DIR@ @UNBOUND_CHROOT_DIR@
77*561252a2Schristos
78*561252a2Schristos# Below rules are needed when chroot is enabled (usually it's enabled by default).
79*561252a2Schristos# If chroot is disabled like chroot: "" then they may be safely removed.
80*561252a2SchristosTemporaryFileSystem=@UNBOUND_CHROOT_DIR@/dev:ro
81*561252a2SchristosTemporaryFileSystem=@UNBOUND_CHROOT_DIR@/run:ro
82*561252a2SchristosBindReadOnlyPaths=-/run/systemd/notify:@UNBOUND_CHROOT_DIR@/run/systemd/notify
83*561252a2SchristosBindReadOnlyPaths=-/dev/urandom:@UNBOUND_CHROOT_DIR@/dev/urandom
84*561252a2SchristosBindPaths=-/dev/log:@UNBOUND_CHROOT_DIR@/dev/log
85