From f3c2e8f33f87e1854c31aba342806551a13a7984 Mon Sep 17 00:00:00 2001 From: Jeremy Fleischman Date: Fri, 9 May 2025 18:33:08 -0700 Subject: [PATCH] Add `/bin/sh` to bubblewrap sandbox I ran into this error when trying to run `opendkim-genkey` in a vars generator: ```console =========================================================================== Command =========================================================================== nix \ --extra-experimental-features 'nix-command flakes' \ shell \ --inputs-from /nix/store/9r3ddw80dz4qzci9pj57ppbh6gy2pgv9-clan-cli/lib/python3.12/site-packages/clan_cli/nixpkgs \ 'nixpkgs#bash' \ 'nixpkgs#bubblewrap' \ -c bwrap \ --unshare-all --tmpfs \ / \ --ro-bind /nix/store \ /nix/store \ --dev /dev \ --bind /tmp/nix-shell.ClOjgJ/vars-kh4qrnas \ /tmp/nix-shell.ClOjgJ/vars-kh4qrnas \ --chdir / \ --bind /proc \ /proc \ --uid 1000 \ --gid 1000 \ -- bash \ -c /nix/store/p0089w4y1w3h535g7ipv4jl4r6mb2hs2-generator-dkim-playground.jflei.com.mail =========================================================================== Stderr ============================================================================ perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_CTYPE = (unset), LC_NUMERIC = (unset), LC_COLLATE = (unset), LC_TIME = (unset), LC_MESSAGES = (unset), LC_MONETARY = (unset), LC_ADDRESS = (unset), LC_IDENTIFICATION = (unset), LC_MEASUREMENT = (unset), LC_PAPER = (unset), LC_TELEPHONE = (unset), LC_NAME = (unset), LANG = "en_US.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). Can't exec "/bin/sh": No such file or directory at /nix/store/nfawbww80p1hgpymfgq1vq8wqlak75yh-opendkim-2.11.0-Beta2/sbin/.opendkim-genkey-wrapped line 139. .opendkim-genkey-wrapped: openssl died with signal %d 127 Return Code: 1 1 hosts failed with an error. Check the logs above ``` As we allow `/bin/sh` in the nix build sandbox, I assume we're OK allowing it here as well? --- pkgs/clan-cli/clan_cli/facts/generate.py | 1 + pkgs/clan-cli/clan_cli/vars/generate.py | 1 + 2 files changed, 2 insertions(+) diff --git a/pkgs/clan-cli/clan_cli/facts/generate.py b/pkgs/clan-cli/clan_cli/facts/generate.py index 3d0dabb1d..45542b2bc 100644 --- a/pkgs/clan-cli/clan_cli/facts/generate.py +++ b/pkgs/clan-cli/clan_cli/facts/generate.py @@ -48,6 +48,7 @@ def bubblewrap_cmd(generator: str, facts_dir: Path, secrets_dir: Path) -> list[s "--unshare-all", "--tmpfs", "/", "--ro-bind", "/nix/store", "/nix/store", + "--ro-bind", "/bin/sh", "/bin/sh", "--dev", "/dev", # not allowed to bind procfs in some sandboxes "--bind", str(facts_dir), str(facts_dir), diff --git a/pkgs/clan-cli/clan_cli/vars/generate.py b/pkgs/clan-cli/clan_cli/vars/generate.py index c515f7967..d071b6bdc 100644 --- a/pkgs/clan-cli/clan_cli/vars/generate.py +++ b/pkgs/clan-cli/clan_cli/vars/generate.py @@ -103,6 +103,7 @@ def bubblewrap_cmd(generator: str, tmpdir: Path) -> list[str]: "--unshare-all", "--tmpfs", "/", "--ro-bind", "/nix/store", "/nix/store", + "--ro-bind", "/bin/sh", "/bin/sh", *(["--ro-bind", str(test_store), str(test_store)] if test_store else []), "--dev", "/dev", # not allowed to bind procfs in some sandboxes