Files
lincodex/deploy/labs/lincodex-labd.service

56 lines
1.7 KiB
Desktop File

# systemd unit of the lab provisioner labd on the app host.
#
# labd is the only process that talks to the LXD API. The lxd group is
# equivalent to root on the host, so the unit gives the process nothing else:
# no capabilities, a read-only file system except its state directory and the
# LXD socket, and no other secrets than its own TLS pair and API token in
# /etc/lincodex-labd/ (owner lincodex-labd, mode 0600). The settings come from
# /etc/lincodex-labd/labd.env; see deploy/labs/labd.env.example.
[Unit]
Description=Lincodex lab provisioner (labd)
Wants=network-online.target
After=network-online.target snap.lxd.daemon.service docker.service
[Service]
Type=simple
User=lincodex-labd
Group=lincodex-labd
SupplementaryGroups=lxd
EnvironmentFile=/etc/lincodex-labd/labd.env
ExecStart=/usr/local/bin/lincodex-labd
Restart=on-failure
RestartSec=5s
# Longer than LABD_SHUTDOWN_TIMEOUT, so a drain finishes before SIGKILL. A
# kill is still safe: the next start finishes every lab from the state file.
TimeoutStopSec=45s
StateDirectory=lincodex-labd
StateDirectoryMode=0700
UMask=0077
ReadWritePaths=/var/snap/lxd/common/lxd/unix.socket
NoNewPrivileges=yes
CapabilityBoundingSet=
AmbientCapabilities=
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
PrivateDevices=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectKernelLogs=yes
ProtectControlGroups=yes
ProtectClock=yes
ProtectHostname=yes
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
RestrictNamespaces=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
LockPersonality=yes
MemoryDenyWriteExecute=yes
SystemCallArchitectures=native
SystemCallFilter=@system-service
# A refused system call fails with EPERM instead of killing the process.
SystemCallErrorNumber=EPERM
[Install]
WantedBy=multi-user.target