From d14ae62671fd4eaec57427da1e50f91d6a5f9605 Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Sun, 5 Sep 2021 14:35:40 +0200 Subject: nixos/terminfo: inherit TERMINFO* env vars also for doas This should mirror the behavior we implement for sudo: The TERMINFO and TERMINFO_DIRS variables are inherited from the normal user's environment, so terminfo files installed in the user's profile can be found by ncurses applications running as root. --- nixos/modules/security/doas.nix | 2 +- nixos/tests/doas.nix | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/nixos/modules/security/doas.nix b/nixos/modules/security/doas.nix index 9a3daf4f504..2a814f17e45 100644 --- a/nixos/modules/security/doas.nix +++ b/nixos/modules/security/doas.nix @@ -15,7 +15,7 @@ let (optionalString rule.noLog "nolog") (optionalString rule.persist "persist") (optionalString rule.keepEnv "keepenv") - "setenv { SSH_AUTH_SOCK ${concatStringsSep " " rule.setEnv} }" + "setenv { SSH_AUTH_SOCK TERMINFO TERMINFO_DIRS ${concatStringsSep " " rule.setEnv} }" ]; mkArgs = rule: diff --git a/nixos/tests/doas.nix b/nixos/tests/doas.nix index 5e9ce4b2c79..7f038b2bee2 100644 --- a/nixos/tests/doas.nix +++ b/nixos/tests/doas.nix @@ -85,6 +85,14 @@ import ./make-test-python.nix ( # ../../pkgs/tools/security/doas/0001-add-NixOS-specific-dirs-to-safe-PATH.patch with subtest("recursive calls to doas from subprocesses should succeed"): machine.succeed('doas -u test0 sh -c "doas -u test0 true"') + + with subtest("test0 should inherit TERMINFO_DIRS from the user environment"): + dirs = machine.succeed( + "su - test0 -c 'doas -u root $SHELL -c \"echo \$TERMINFO_DIRS\"'" + ) + + if not "test0" in dirs: + raise Exception(f"user profile TERMINFO_DIRS is not preserved: {dirs}") ''; } ) -- cgit 1.4.1