yggdrasil-go/contrib/systemd/yggdrasil.service
TomZ 2fbfa4dcb4 Update to make systemd create the user
Also use some stricter security features systemd provides.

This change from github user John Goerzen @jgoerzen as provided
in his comment:
https://github.com/yggdrasil-network/yggdrasil-go/pull/816#issuecomment-1006679721

ProtectSystem=strict prevents it from modifying basically anything on
the filesystem, so therefore we have to specify the possible locations
for the runtime directory under ReadWritePaths.
2022-01-09 15:37:31 +01:00

30 lines
803 B
Desktop File

[Unit]
Description=yggdrasil
Wants=network-online.target
Wants=yggdrasil-default-config.service
After=network-online.target
After=yggdrasil-default-config.service
[Service]
ProtectHome=true
ProtectSystem=true
SyslogIdentifier=yggdrasil
ExecStartPre=+-/sbin/modprobe tun
ExecStart=/usr/bin/yggdrasil -useconffile /etc/yggdrasil.conf
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
TimeoutStopSec=5
Group=yggdrasil
User=yggdrasil-dyn
DynamicUser=true
ProtectSystem=strict
NoNewPrivileges=true
ReadWritePaths=/var/run/yggdrasil /run/yggdrasil
# make sure /var/run/yggdrasil/ is created writable for the user.
RuntimeDirectory=yggdrasil
# the small list of admin capabilities we need to do our job
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target