47 lines
2.1 KiB
SYSTEMD
47 lines
2.1 KiB
SYSTEMD
|
|
# SPDX-License-Identifier: LGPL-3.0-only
|
||
|
|
# SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
||
|
|
#
|
||
|
|
# nostrod: every local user's bank connections, one worker process per user, behind net.catcrafts.Nostro1 and
|
||
|
|
# net.catcrafts.Nostro1.Checkout on the system bus. The first call starts it (D-Bus activation), and it ends by itself
|
||
|
|
# once idle, so an updated Flatpak takes over at the next call. It runs from the net.catcrafts.Nostro Flatpak as the
|
||
|
|
# system user nostro, whose home, the state directory, holds the connections: no other user can read it.
|
||
|
|
#
|
||
|
|
# The hardening is what bubblewrap, which flatpak runs the daemon in, works under. Not here, because it breaks it:
|
||
|
|
# RestrictSUIDSGID= (systemd answers openat2() with ENOSYS for it, and bubblewrap 0.13 has no fallback; NoNewPrivileges=
|
||
|
|
# voids setuid bits anyway), RestrictNamespaces=, and ProtectKernelTunables=, ProtectKernelLogs=, ProtectProc= and
|
||
|
|
# ProcSubset=, which overmount the /proc bubblewrap mounts its own over.
|
||
|
|
#
|
||
|
|
# Install: /etc/systemd/system/nostrod.service (install.sh) or /usr/lib/systemd/system/nostrod.service (a package).
|
||
|
|
[Unit]
|
||
|
|
Description=nostro banking daemon
|
||
|
|
|
||
|
|
[Service]
|
||
|
|
Type=dbus
|
||
|
|
BusName=net.catcrafts.Nostro1
|
||
|
|
User=nostro
|
||
|
|
Group=nostro
|
||
|
|
ExecStart=/usr/bin/flatpak run --system --no-session-bus --die-with-parent --command=nostrod net.catcrafts.Nostro//stable
|
||
|
|
StateDirectory=nostro
|
||
|
|
StateDirectoryMode=0700
|
||
|
|
# flatpak run needs a runtime directory, which a system user does not have.
|
||
|
|
RuntimeDirectory=nostro
|
||
|
|
RuntimeDirectoryMode=0700
|
||
|
|
Environment=XDG_RUNTIME_DIR=/run/nostro
|
||
|
|
UMask=0077
|
||
|
|
# A core dump would hold every key the daemon had in memory; nostrod's workers also make themselves undumpable.
|
||
|
|
LimitCORE=0
|
||
|
|
NoNewPrivileges=yes
|
||
|
|
PrivateTmp=yes
|
||
|
|
PrivateDevices=yes
|
||
|
|
ProtectSystem=strict
|
||
|
|
ProtectHome=yes
|
||
|
|
ProtectClock=yes
|
||
|
|
ProtectControlGroups=yes
|
||
|
|
CapabilityBoundingSet=
|
||
|
|
MemoryDenyWriteExecute=yes
|
||
|
|
LockPersonality=yes
|
||
|
|
RestrictRealtime=yes
|
||
|
|
# AF_NETLINK: bubblewrap brings up loopback in the network namespace of the sandbox flatpak runs ldconfig in.
|
||
|
|
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
|
||
|
|
# @mount, unshare and setns: bubblewrap builds the sandbox with them.
|
||
|
|
SystemCallFilter=@system-service @mount unshare setns
|