Open iwanb opened 3 months ago
Triaged in Nix maintainers meeting:
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/2024-05-29-nix-team-meeting-minutes-148/46195/1
Lix has the same bug — seems to be the nix::logger
global that's nullptr:
Starting program: /home/qyriad/code/lix/build/src/nix/nix --version
Program received signal SIGSEGV, Segmentation fault.
0x0000000000a58aab in nix::warn<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > (fs=...) at src/libutil/logging.hh:231
231 inline void warn(const std::string & fs, const Args & ... args)
(gdb) p nix::logger
$1 = (nix::Logger *) 0x0
Linking nix against libutil with -Wl,--whole-archive
when building statically seems to fix/workaround the issue
Describe the bug
Trying to run the static nix as root with HOME set to a folder owned by a different user results in a crash/segfault.
Stacktrace, on latest master.
EDIT: Leaving this wrong stacktrace, I made a mistake before and mixed up two versions of the binary:
Stacktrace, on version 2.18.1:
Steps To Reproduce
Expected behavior
It should fallback to the user's home directory, and/or ignore the HOME folder, as if it didn't exist. That seems to work for the non-static build:
nix-env --version
outputhttps://hydra.nixos.org/build/261167110 and also version 2.18.1 from nixpkgs.
Additional context
I encountered this when trying to make the static nix binary setuid. Seemed like a simple way to have a kind of static multi-user nix, if you don't care about users getting root access (in a container in my case).
Priorities
Add :+1: to issues you find important.