chore: security updates

This commit is contained in:
2026-10-22 11:57:03 +02:00
parent 6609dbfdc9
commit e0de8f5ace
2 changed files with 50 additions and 25 deletions
+25
View File
@@ -48,6 +48,29 @@
lib.listToAttrs (map (db:
lib.nameValuePair db "host=127.0.0.1 port=${toString pgPort} dbname=${db}")
dbs);
# Boot-Race (Vorfall 2026-10-18): netavark legt die Bridge-IP des Podman-
# Netzwerks „web" (podman1, 10.89.0.1/24) erst an, wenn der erste Container
# des Netzwerks startet. pgbouncer startet beim Boot aber VOR den
# Container-Diensten → bind() auf 10.89.0.1 schlägt fehl („Cannot assign
# requested address"). pgbouncer läuft danach trotzdem weiter (nur auf
# 127.0.0.1) und systemd zeigt beide Dienste „active" — alle Container-Apps
# erhalten auf der Bridge connection refused und fallen in den
# Wartungsmodus. Erst ein manueller Dienst-Restart (Bridge existiert
# inzwischen) behebt es.
#
# Fix: vor dem Start auf die Bridge-IP warten. Nach Ablauf des Timeouts
# trotzdem starten (Warnung ins Journal) — sonst wären auch localhost-
# Clients (z. B. vaultwarden) ganz ohne Dienst, wie heute auch.
waitForBridge = pkgs.writeShellScript "pgbouncer-wait-for-bridge" ''
for _ in $(seq 1 120); do
if ${pkgs.iproute2}/bin/ip -4 -o addr show | ${pkgs.gnugrep}/bin/grep -q "inet ${hostBridgeIP}/"; then
exit 0
fi
sleep 1
done
echo "WARNING: ${hostBridgeIP} (Podman-Bridge podman1) nach 120s nicht vorhanden — pgbouncer lauscht nur auf 127.0.0.1!" >&2
'';
in {
services.pgbouncer = {
enable = true;
@@ -81,6 +104,7 @@ in {
systemd.services.pgbouncer = {
after = ["postgresql.service"];
requires = ["postgresql.service"];
serviceConfig.ExecStartPre = lib.mkBefore waitForBridge;
};
environment.etc."pgbouncer/pgbouncer-session.ini".text = let
@@ -141,6 +165,7 @@ in {
User = "pgbouncer";
Group = "pgbouncer";
RuntimeDirectory = "pgbouncer-session";
ExecStartPre = waitForBridge;
ExecStart = "${pkgs.pgbouncer}/bin/pgbouncer /etc/pgbouncer/pgbouncer-session.ini";
Restart = "on-failure";
RestartSec = 5;