void-linux / void-linux/void-packages

nix: do not disable sandbox by default

Open
#35,666 6 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Shell
Stars
3.4k
Forks
2.8k
Avg merge
2d 5h
Merged PRs (30d)
299

Description

System
  • xuname: Void 5.12.14_1 x86_64-musl AuthenticAMD uptodate rFFFF
  • package: nix-2.3.12_1
Expected behavior

/etc/nix.conf should have sandbox on, and should build packages as expected in such isolated environment.

Actual behavior

/etc/nix.conf has sandbox turned off by default, and it fails unexpectedly when turned on due to a misconfiguration with sandbox-paths. Nix mounts /bin/sh into the sandboxed namespace, but this binary is linked against musl libc and thus fails to work in such a sandboxed environment.

The workaround is to install busybox-static and edit sandbox-paths in /etc/nix.conf so that /bin/sh points to busybox.static instead.

Steps to reproduce the behavior
  1. Install nix and make sure sandboxing is turned on (restart daemon)
  2. Use the following default.nix
{ pkgs ? import <nixpkgs> {} }:

pkgs.buildPackages.rustPlatform.buildRustPackage rec {
  pname = "diesel-cli-ext";
  version = "0.3.6";
  cargoSha256 = "1npmr1sy7d6gv7j3r8c03c7k7c9fv0kvipl96cm6g1c90qqba2hx";
  src = pkgs.fetchCrate {
    inherit version;
    crateName = "diesel_cli_ext";
    sha256 = "0zf98kydxgb9mc77x7r4d0vmkfzgi5h4h6n1dhpgq2if9ybyci0b";
  };
}
  1. build will fail with misleading error:
tar (child): gzip: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
  1. strace reveals the tar actually does /bin/sh -c gzip

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting how /etc/nix.conf is generated and how its sandbox-paths setting handles /bin/sh. Reproduce the failure with the provided default.nix and the rustPlatform.buildRustPackage build, then verify that sandboxing remains enabled and the build no longer reports the misleading gzip execution error.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, shell
Domain
build-system, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.