struct EarlyInitializer {
EarlyInitializer(const char **adpy_strp, const char **libgla_strp)
{
+ // Setting environment variables in a bash process from an LD_PRELOAD
+ // library during initialization may be harmful. It can temporarily wipe
+ // the environment making subsequent getenv() return NULL (see #962566).
+ // Not setting this variable will allow primus to continue its
+ // initialization while possibly breaking OpenGL usage in bash processes
+ // (but not in subsequent processes started from bash scripts).
+ if (!dlsym(RTLD_DEFAULT, "bash_copyright")) {
// Allow multiple glvnd libGL.so.1 instances to be loaded into a process
// and OpenGL calls dispatched to them depending on context.
setenv("__GLVND_DISALLOW_PATCHING", "1", 0);
+ }
#ifdef BUMBLEBEE_SOCKET
// Signal the Bumblebee daemon to bring up secondary X
int sock = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);