summaryrefslogtreecommitdiffstats
path: root/tv/2configs/test.nix
blob: fa556ec78fb0b3096c403861dc57d48d312ad580 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{ config, lib, pkgs, ... }:

with import ../4lib { inherit lib pkgs; };

let
  tvpkgs = import ../5pkgs { inherit lib pkgs; };

  out = {
    environment.systemPackages = [
      su-test
    ];
    security.sudo.extraConfig = ''
      tv ALL=(test) NOPASSWD: ALL
    '';
    users.extraUsers.test = {
      shell = "${test-shell}";
    };
  };

  su-test = tvpkgs.execveBin "su-test" rec {
    filename = "/var/setuid-wrappers/sudo";
    argv = ["sudo" "-u" "test" "-i"];
  };

  test-shell = tvpkgs.execve "test-shell" rec {
    filename = "${pkgs.bash}/bin/bash";
    argv = ["sh" "--noprofile" "-l"];
    envp.ENV = pkgs.writeText "test-env" ''
      ${shell.cat "Hello, `$(j0w\nd0g!)`!\\o/\n"} >&2
    '';
  };

in out