Watch
0
0
Fork
You've already forked hyperhive
0

hive-matrix: the fallocate probe works inside tuwunel's sandbox

Refs #6885
This commit is contained in:
atlas 2026-11-27 18:39:03 +01:00
commit 05e59c1e8c

View file

@ -960,16 +960,29 @@ let
c = host.containers.hive-matrix;
global = c.config.services.matrix-tuwunel.settings.global;
unit = c.config.systemd.services.tuwunel;
probe = lib.head unit.serviceConfig.ExecStartPre;
probeLib = import ../host-modules/lib/tuwunel-fallocate-probe.nix { inherit pkgs; };
text = probeLib.probe.text;
in
global ? allow_registration
&& global ? unix_socket_perms
&& !(global ? rocksdb_allow_fallocate)
&& lib.length unit.serviceConfig.ExecStartPre == 1
&& unit.serviceConfig.ExecStartPre == [ "${probeLib.probe} /var/lib/tuwunel" ]
&& unit.serviceConfig.EnvironmentFile == [ "-/run/tuwunel/fallocate.env" ]
&& unit.serviceConfig.RuntimeDirectory == "tuwunel"
&& lib.hasInfix "stat -f -c %t /var/lib/tuwunel" probe.text
&& lib.hasInfix "9123683e | 2fc12fc1) echo TUWUNEL_ROCKSDB_ALLOW_FALLOCATE=false > /run/tuwunel/fallocate.env" probe.text
# The sandbox denies the `@ipc` group, which has `pipe`: the probe makes no pipe.
# The VM test of the probe runs it under that sandbox. These are the
# presence arms of the absences below.
&& lib.any (f: lib.hasPrefix "~" f && lib.hasInfix " @ipc" f) unit.serviceConfig.SystemCallFilter
&& lib.hasInfix "stat -f -c %t" text
&& lib.hasInfix "read -r magic < " text
&& lib.hasInfix "stat -f of $1 failed; rocksdb_allow_fallocate stays at tuwunel's default\" >&2" text
&& lib.hasInfix "no filesystem type read back" text
&& lib.hasInfix "9123683e) fs=btrfs" text
&& lib.hasInfix "2fc12fc1) fs=zfs" text
&& lib.hasInfix "TUWUNEL_ROCKSDB_ALLOW_FALLOCATE=false > /run/tuwunel/fallocate.env" text
&& !(lib.hasInfix "$(" text)
&& !(lib.hasInfix "`" text)
&& !(lib.hasInfix "<<" text)
&& c.timeoutStartSec == "1min"
&& startLimitOf "hive-matrix" == 60;
}