Skip to content

Commit 3155258

Browse files
committed
undo NIX_LD fallback
The issue is that we need to insert a new environment variable into envp... and also than shift the whole stack a bit. While this is feasible implementing this will take a little bit more time.
1 parent 5e696c9 commit 3155258

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

nixos-test.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ in {
1515
machine.succeed("$(< ${nix-ld}/nix-support/ldpath) --version")
1616
1717
# test fallback if NIX_LD is not set
18-
machine.succeed("unset NIX_LD; unset NIX_LD_LIBRARY_PATH; $(< ${nix-ld}/nix-support/ldpath) $(which hello)")
18+
#machine.succeed("unset NIX_LD; unset NIX_LD_LIBRARY_PATH; $(< ${nix-ld}/nix-support/ldpath) $(which hello)")
1919
'';
2020
} {
2121
inherit pkgs;

src/nix-ld.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -399,15 +399,18 @@ int main(int argc, char** argv, char** envp) {
399399
struct ld_ctx ctx = init_ld_ctx(argc, argv, envp, auxv);
400400

401401
if (!ctx.nix_ld) {
402-
// fallback to default ld.so
403-
if (access(DEFAULT_NIX_LD, R_OK) == 0) {
404-
ctx.nix_ld = DEFAULT_NIX_LD;
405-
// if no NIX_LD is set we also don't trust NIX_LD_LIBRARY_PATH since it may point to a different libc
406-
ctx.nix_lib_path_prefix = DEFAULT_NIX_LD_LIBRARY_PATH;
407-
} else {
408-
log_error(&ctx, "You are trying to run an unpatched binary on nixos, but you have not configured NIX_LD or NIX_LD_" NIX_SYSTEM ". See https://github.com/Mic92/nix-ld for more details");
409-
return 1;
410-
}
402+
// FIXME: fallback to default ld.so
403+
// This requires however to also increase envp to have space for the new environment variable
404+
//if (access(DEFAULT_NIX_LD, R_OK) == 0) {
405+
// ctx.nix_ld = DEFAULT_NIX_LD;
406+
// // if no NIX_LD is set we also don't trust NIX_LD_LIBRARY_PATH since it may point to a different libc
407+
// ctx.nix_lib_path_prefix = DEFAULT_NIX_LD_LIBRARY_PATH;
408+
//} else {
409+
// log_error(&ctx, "You are trying to run an unpatched binary on nixos, but you have not configured NIX_LD or NIX_LD_" NIX_SYSTEM ". See https://github.com/Mic92/nix-ld for more details");
410+
// return 1;
411+
//}
412+
log_error(&ctx, "You are trying to run an unpatched binary on nixos, but you have not configured NIX_LD or NIX_LD_" NIX_SYSTEM ". See https://github.com/Mic92/nix-ld for more details");
413+
return 1;
411414
}
412415

413416
if (!ctx.page_size) {

0 commit comments

Comments
 (0)