I am observing a curious behavior when running a program with setuid bit enabled.

Program foo is owned by user bar with setuid bit set.

User execbar runs foo

foo reports that one of the dynamic libraries is inaccessible.

The dynamic library in question is located in a directory outside the normal ld.so.conf search paths so it's set via LD_LIBRARY_PATH for user execbar

The question is: Is running a program with setuid clears the environment set by user execbar?

1 Answer 1


No, but the dynamic linker will ignore some environment variables when run with setuid as otherwise you could make it load and run any code as the target user. That goes for LD_LIBRARY_PATH, LD_PRELOAD and more. See ld.so(8).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.