From: Andreas Beckmann Date: Thu, 23 Jul 2020 21:15:02 +0000 (+0100) Subject: do not set environment variables in bash processes X-Git-Tag: archive/raspbian/0_20150328-12+rpi1^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=54b24dbd9c0a06a9ee0189dcc4daabe783677e2c;p=primus.git do not set environment variables in bash processes Gbp-Pq: Name workaround-bash-setenv.patch --- diff --git a/libglfork.cpp b/libglfork.cpp index 213779a..7827c41 100644 --- a/libglfork.cpp +++ b/libglfork.cpp @@ -165,9 +165,17 @@ struct ContextsInfo: public std::map { 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);