| 1 | Author: Andreas Beckmann <[email protected]> |
| 2 | Description: do not set environment variables in bash processes |
| 3 | |
| 4 | --- a/libglfork.cpp |
| 5 | +++ b/libglfork.cpp |
| 6 | @@ -165,9 +165,17 @@ struct ContextsInfo: public std::map<GLX |
| 7 | struct EarlyInitializer { |
| 8 | EarlyInitializer(const char **adpy_strp, const char **libgla_strp) |
| 9 | { |
| 10 | + // Setting environment variables in a bash process from an LD_PRELOAD |
| 11 | + // library during initialization may be harmful. It can temporarily wipe |
| 12 | + // the environment making subsequent getenv() return NULL (see #962566). |
| 13 | + // Not setting this variable will allow primus to continue its |
| 14 | + // initialization while possibly breaking OpenGL usage in bash processes |
| 15 | + // (but not in subsequent processes started from bash scripts). |
| 16 | + if (!dlsym(RTLD_DEFAULT, "bash_copyright")) { |
| 17 | // Allow multiple glvnd libGL.so.1 instances to be loaded into a process |
| 18 | // and OpenGL calls dispatched to them depending on context. |
| 19 | setenv("__GLVND_DISALLOW_PATCHING", "1", 0); |
| 20 | + } |
| 21 | #ifdef BUMBLEBEE_SOCKET |
| 22 | // Signal the Bumblebee daemon to bring up secondary X |
| 23 | int sock = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); |