From aa8c9f5d9a1cbefcb9886df41d4502048866ea27 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Sun, 14 Jun 2026 13:06:41 +0200 Subject: [PATCH] nixos/pretalx: remove elevation from the pretalx-manage wrapper This reduces execution of pretalx-manage to root, so there is no dependency on sudo, a setuid root binary, any more. --- nixos/modules/services/web-apps/pretalx.nix | 35 ++++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/nixos/modules/services/web-apps/pretalx.nix b/nixos/modules/services/web-apps/pretalx.nix index 37527a4e1688..c67910f03fb6 100644 --- a/nixos/modules/services/web-apps/pretalx.nix +++ b/nixos/modules/services/web-apps/pretalx.nix @@ -27,6 +27,28 @@ let cfg.settings.database.backend == "postgresql" ) finalPackage.optional-dependencies.postgres; }; + + pretalxManageWrapper = pkgs.writeShellApplication { + name = "pretalx-manage"; + runtimeInputs = with pkgs; [ + util-linux + ]; + text = '' + cd ${cfg.settings.filesystem.data} + set -a + ${lib.concatMapStringsSep "\n" (file: '' + . ${lib.escapeShellArg file} + '') cfg.environmentFiles} + set +a + export PRETALX_CONFIG_FILE=${configFile} + exec runuser ${ + lib.cli.toCommandLineShellGNU { } { + inherit (cfg) user; + preserve-environment = true; + } + } -- ${lib.getExe' pythonEnv "pretalx-manage"} "$@" + ''; + }; in { @@ -325,18 +347,7 @@ in # https://docs.pretalx.org/administrator/installation/ environment.systemPackages = [ - (pkgs.writeScriptBin "pretalx-manage" '' - cd ${cfg.settings.filesystem.data} - sudo=exec - if [[ "$USER" != ${cfg.user} ]]; then - sudo='exec /run/wrappers/bin/sudo -u ${cfg.user} --preserve-env=PRETALX_CONFIG_FILE' - fi - set -a - ${lib.concatMapStringsSep "\n" (file: ". ${lib.escapeShellArg file}") cfg.environmentFiles} - set +a - export PRETALX_CONFIG_FILE=${configFile} - $sudo ${lib.getExe' pythonEnv "pretalx-manage"} "$@" - '') + pretalxManageWrapper ]; services.logrotate.settings.pretalx = {