Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/proc/self/exec points to a wrong path #2

Open
Mic92 opened this issue Jun 26, 2024 · 3 comments
Open

/proc/self/exec points to a wrong path #2

Mic92 opened this issue Jun 26, 2024 · 3 comments

Comments

@Mic92
Copy link

Mic92 commented Jun 26, 2024

Some programs i.e. the rust stdlib will use /proc/self/exe to get their own executable path i.e. to re-execute themself. In earlier versions of nix-ld, I was also using exec ld-linux.so having the same issue.

@wwilson
Copy link
Contributor

wwilson commented Jul 3, 2024

This is totally a problem! We work around it in our own code that needs to read /proc/self/exe, but it's done in a pretty annoying way. Has nix-ld solved this issue? If so we would love to learn from you!

@Mic92
Copy link
Author

Mic92 commented Jul 3, 2024

The solution was to jump to the entry point of glibc. https://github.com/Mic92/nix-ld/blob/bf5aa84a713c31d95b4307e442e966d6c7fd7ae7/src/nix-ld.c#L445

An ld still needs to be executable as a program, which however is not hard to implement: https://github.com/Mic92/nix-ld/blob/bf5aa84a713c31d95b4307e442e966d6c7fd7ae7/src/nix-ld.c#L439

@Mic92
Copy link
Author

Mic92 commented Jul 3, 2024

However over all I would recommend what nix-ld-rs is doing: https://github.com/nix-community/nix-ld-rs
It also leaves no LD_LIBRARY_PATH pollution set in child processes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants