aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-25 23:06:46 +0000
committertv <tv@krebsco.de>2026-11-26 00:03:17 +0000
commitb5edf2b27f18f6576d3bcc00f65f95754aec1317 (patch)
tree3fc8423b412a97ce3ee54aeb3cca9ca9cf1277a0 /pkgs
parent23df3da867ec9297f1050dcca14103fddca2153d (diff)
rigs: the host's names, rig-egress, rigbr0, rigtapN, ...
The host side loses the fc and firecracker, too: rig-egress (the command, also in the guests, and in log lines; /var/lib/rig-egress for the lists, /run/rig-egress for the VMs' choices of list), rig-proxy (the proxy, its user, /run/rig-proxy, and /var/lib/rig-proxy with the CA), rig-firewall, rig-dnsmasq, /run/rig-hosts, /run/rig-addr, the bridge rigbr0 and taps rigtapN, /etc/rig-taps and /etc/rig-vms, config.rig.vms, the nftables tables rigs and rigs-bridge, and egress.lua's RIG_EGRESS_*. The host's own configuration needs the new names, too: its firewall's trusted interface rigbr0, and config.rig.vms.
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/run-rig/default.nix64
1 files changed, 32 insertions, 32 deletions
diff --git a/pkgs/run-rig/default.nix b/pkgs/run-rig/default.nix
index 16af39d..cc16879 100644
--- a/pkgs/run-rig/default.nix
+++ b/pkgs/run-rig/default.nix
@@ -44,18 +44,18 @@ let
exec ${pkgs.socat}/bin/socat VSOCK-CONNECT:2:"$1" EXEC:"${pkgs.util-linux}/bin/mount -t 9p -o trans=fd -o rfdno=0 -o wfdno=1 -o version=9p2000.L -o msize=1048576$opts vsock9p $2",nofork
'';
- # The guest's side of fc-egress (see modules/host): asks the host
+ # The guest's side of rig-egress (see modules/host): asks the host
# whether the guest's egress allows URIs, over bash's /dev/tcp, as the
# guest may have no HTTP client.
- fc-egress = pkgs.writeShellScriptBin "fc-egress" ''
- # usage: fc-egress check URI...
+ rig-egress = pkgs.writeShellScriptBin "rig-egress" ''
+ # usage: rig-egress check URI...
# Whether this guest's egress allows each URI (https://HOST[/PATH],
# tcp://HOST:PORT, udp://HOST:PORT): true or false, and the URI, a line
# each. Exit status 0 if all of them are allowed, 1 if not, 2 on
- # errors. The whitelist itself is the host's, see fc-egress there.
+ # errors. The whitelist itself is the host's, see rig-egress there.
set -eu
usage() {
- echo "usage: fc-egress check URI..." >&2
+ echo "usage: rig-egress check URI..." >&2
exit 2
}
test "''${1-}" = check || usage
@@ -65,21 +65,21 @@ let
body=
for uri; do
case $uri in *$'\n'* | *$'\r'*)
- echo "fc-egress: bad URI" >&2
+ echo "rig-egress: bad URI" >&2
exit 2
esac
body+=$uri$'\n'
done
export LC_ALL=C # for the length in bytes
if ! exec 3<>/dev/tcp/172.16.0.1/80; then
- echo "fc-egress: can't reach the host" >&2
+ echo "rig-egress: can't reach the host" >&2
exit 2
fi
printf 'POST /check HTTP/1.0\r\nHost: 172.16.0.1\r\nContent-Type: text/plain\r\nContent-Length: %d\r\n\r\n%s' "''${#body}" "$body" >&3
read -r _ status _ <&3 || status=
while IFS= read -r line <&3 && test -n "''${line%$'\r'}"; do :; done
if test "$status" != 200; then
- echo "fc-egress: the host answered ''${status:-nothing}" >&2
+ echo "rig-egress: the host answered ''${status:-nothing}" >&2
cat <&3 >&2
exit 2
fi
@@ -92,7 +92,7 @@ let
i=$((i + 1))
done
if test $i != $#; then
- echo "fc-egress: $i answers for $# URIs" >&2
+ echo "rig-egress: $i answers for $# URIs" >&2
exit 2
fi
exit $all
@@ -264,8 +264,8 @@ let
(pkgs.runCommand "mount.vsock9p" { } "install -D ${mountVsock9p} $out/bin/mount.vsock9p")
];
- # fc-egress check URI..., see fc-egress above.
- environment.systemPackages = [ fc-egress ];
+ # rig-egress check URI..., see rig-egress above.
+ environment.systemPackages = [ rig-egress ];
# sshd, started on demand (a layer may turn that off), with the host
# key a secret (--secret ssh_host_ed25519_key=FILE; see rig-secrets),
@@ -326,7 +326,7 @@ let
# (if it's there; another one: security.pki.certificateFiles).
environment.etc."resolv.conf".text = "nameserver 172.16.0.1\n";
security.pki.certificateFiles =
- lib.optional (builtins.pathExists /var/lib/fcbr0-egress/ca.pem) /var/lib/fcbr0-egress/ca.pem;
+ lib.optional (builtins.pathExists /var/lib/rig-proxy/ca.pem) /var/lib/rig-proxy/ca.pem;
systemd.network.enable = true;
systemd.network.wait-online.enable = false;
systemd.network.networks.eth = {
@@ -584,8 +584,8 @@ pkgs.writeShellScriptBin "run-rig" /* sh */ ''
# layer) doesn't start without --home.
# --mem-size sets the guest's memory, in MiB (default 1024).
# The guest's egress goes by the user's whitelist LIST (default: the
- # VM's name, or without one, default), see modules/host and fc-egress.
- # --name names the VM, for fc-egress and as the guest's host name; only
+ # VM's name, or without one, default), see modules/host and rig-egress.
+ # --name names the VM, for rig-egress and as the guest's host name; only
# one running VM of the user's can have a given name. --vcpus: the
# guest's number of CPUs (default 2; Firecracker takes 1 to 32).
# --secret NAME=FILE: a secret for the guest, NAME letters, digits, '.',
@@ -776,12 +776,12 @@ pkgs.writeShellScriptBin "run-rig" /* sh */ ''
fi
# Take the first tap device of the user's that no other VM holds, from
- # the ones modules/host lists in /etc/fc-taps (TAP USER IP MAC, with the
+ # the ones modules/host lists in /etc/rig-taps (TAP USER IP MAC, with the
# tap's own address). The lock is held until the script exits. The
# guest's address, and the MAC address that DHCP hands it out by, is
- # its VM's, if it has a name in /etc/fc-vms (VM USER IP MAC), else the
+ # its VM's, if it has a name in /etc/rig-vms (VM USER IP MAC), else the
# tap's own; modules/host gives the tap that address once the VM's name
- # is in /run/fc-egress/TAP.name (see below).
+ # is in /run/rig-egress/TAP.name (see below).
# Lock files in a directory of the user's own: in /tmp, another user
# could take them first.
lockdir=''${XDG_RUNTIME_DIR:-/run/user/$(id -u)}
@@ -789,8 +789,8 @@ pkgs.writeShellScriptBin "run-rig" /* sh */ ''
echo "$0: $lockdir isn't a directory of $(id -un)'s; set XDG_RUNTIME_DIR" >&2
exit 1
fi
- if ! test -r /etc/fc-taps; then
- echo "$0: no /etc/fc-taps, see modules/host" >&2
+ if ! test -r /etc/rig-taps; then
+ echo "$0: no /etc/rig-taps, see modules/host" >&2
exit 1
fi
me=$(id -un)
@@ -807,25 +807,25 @@ pkgs.writeShellScriptBin "run-rig" /* sh */ ''
break
fi
exec {lock}>&-
- done < /etc/fc-taps
+ done < /etc/rig-taps
if test -z "$tap"; then
- echo "$0: no free tap device fctap* of $me's, see modules/host" >&2
+ echo "$0: no free tap device rigtap* of $me's, see modules/host" >&2
exit 1
fi
- if test -n "$name" && test -r /etc/fc-vms; then
+ if test -n "$name" && test -r /etc/rig-vms; then
while read -r v u a m; do
if test "$v $u" = "$name $me"; then
addr=$a
mac=$m
fi
- done < /etc/fc-vms
+ done < /etc/rig-vms
fi
# The VM's name: held by a lock, like the tap, so it's unique among the
- # user's running VMs. Not like a tap's, so fc-egress can tell them
+ # user's running VMs. Not like a tap's, so rig-egress can tell them
# apart.
if test -n "$name"; then
if ! printf %s "$name" | grep -qxE '[A-Za-z0-9][A-Za-z0-9-]{0,62}' ||
- printf %s "$name" | grep -qxE 'fctap[0-9]+'; then
+ printf %s "$name" | grep -qxE 'rigtap[0-9]+'; then
echo "$0: bad name: $name (letters, digits and -, not like a tap)" >&2
exit 1
fi
@@ -838,26 +838,26 @@ pkgs.writeShellScriptBin "run-rig" /* sh */ ''
args="$args systemd.hostname=$name"
fi
# The guest's whitelist: modules/host goes by the name in the tap's file
- # in /run/fc-egress (emptied again when the guest exits, below).
- vm=/run/fc-egress/$tap
+ # in /run/rig-egress (emptied again when the guest exits, below).
+ vm=/run/rig-egress/$tap
if test -w "$vm"; then
if ! printf %s "$egress" | grep -qxE '[A-Za-z0-9_-]+'; then
echo "$0: bad list name: $egress" >&2
exit 1
fi
- if ! test -f "/var/lib/fc-egress/$(id -un)/$egress"; then
- echo "$0: no list $egress (see fc-egress), no egress" >&2
+ if ! test -f "/var/lib/rig-egress/$(id -un)/$egress"; then
+ echo "$0: no list $egress (see rig-egress), no egress" >&2
fi
printf '%s\n' "$egress" > "$vm"
printf '%s\n' "$name" > "$vm.name"
# The tap's address, by the VM's name (see above): wait for it, up to
# 10s, writing the name again every second, in case modules/host
- # missed it (fcbr0-firewall@TAP was busy).
+ # missed it (rig-firewall@TAP was busy).
n=0
- while test "$(head -n 1 /run/fcbr0-addr/$tap 2>/dev/null)" != "$addr"; do
+ while test "$(head -n 1 /run/rig-addr/$tap 2>/dev/null)" != "$addr"; do
n=$((n + 1))
if test $n -gt 100; then
- echo "$0: $tap didn't get $addr, see fcbr0-firewall@$tap on the host" >&2
+ echo "$0: $tap didn't get $addr, see rig-firewall@$tap on the host" >&2
exit 1
fi
if test $((n % 10)) = 0; then