Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 8 down vote accepted

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).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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