Running screen in bash wipes the variable LD_LIBRARY_PATH. I've done some reading and it seems that this is expected behaviour, but I need to get around it.

The workaround is adding the LD_LIBRARY_PATH declaration to ~/.bashrc. In my case, LD_LIBRARY_PATH gets changed a lot between the launch of the shell and when I invoke screen, so I need to get the current value of LD_LIBRARY_PATH into the screen session.

link|improve this question

you have export LD_KLIBRARY_PATH before run screen? – kinnou02 Jan 20 '11 at 14:56
Superuser question. – karlphillip Jan 20 '11 at 14:57
Sorry, can I somehow move it over, or should I delete and repost? – ajwood Jan 20 '11 at 15:07
If you get five close votes, it will be bumped there automatically. One more to go! – Thomas Jan 20 '11 at 17:29
feedback

migrated from stackoverflow.com Jan 20 '11 at 18:23

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 2 down vote accepted

screen doesn't unset the environment variable; it is removed by Linux itself.

On most systems, the /usr/bin/screen executable is installed with the setgid bit for utmp group, in order to be able to modify the utmp database. It also uses setgid to control access to the socket directory (/var/run/screen/).

On Linux, when a setuid (or setgid) program is ran, it does not receive certain environment variables (including LD_LIBRARY_PATH, several other LD_* variables, and HOSTALIASES), in order to reduce the possible attack points: Otherwise you could write a small library and trick su or sudo into calling your "improved" functions that way.


You can remove the setgid bit from screen, but you will have to make the socket directory fully accessible by everyone (mode 0777). It shouldn't be a security risk, though, as screen also checks the attacher's UID itself.

However, you should not make the utmp database world-writable.

link|improve this answer
feedback

Try exporting the environment variable you are interested in.

export LD_LIBRARY_PATH
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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