summaryrefslogtreecommitdiffstats
path: root/src/egl/main
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2010-02-02 16:47:53 +0800
committerChia-I Wu <[email protected]>2010-02-03 14:16:15 +0800
commit6fd8b6a9e22f474117281b00d15c548c29b8197f (patch)
tree87fe60361a6b5289b9a2fdf7f91f3a4250a1d4af /src/egl/main
parent5d8646c41ff3022692fa9d7f5f1644a2a60641e4 (diff)
egl: Ignore certain environment variables when setuid/setgid.
Specifically, ignore EGL_DRIVERS_PATH when an application is setuid/setgid. And ignore EGL_DRIVER when there is a slash in it.
Diffstat (limited to 'src/egl/main')
-rw-r--r--src/egl/main/egldriver.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index 139f8396853..0ccdea76c9b 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -415,6 +415,14 @@ _eglGetSearchPath(void)
int ret;
p = getenv("EGL_DRIVERS_PATH");
+#if defined(_EGL_PLATFORM_POSIX)
+ if (p && (geteuid() != getuid() || getegid() != getgid())) {
+ _eglLog(_EGL_DEBUG,
+ "ignore EGL_DRIVERS_PATH for setuid/setgid binaries");
+ p = NULL;
+ }
+#endif /* _EGL_PLATFORM_POSIX */
+
if (p) {
ret = snprintf(buffer, sizeof(buffer),
"%s:%s", p, _EGL_DRIVER_SEARCH_DIR);
@@ -446,9 +454,15 @@ _eglPreloadUserDriver(void)
env = getenv("EGL_DRIVER");
#if defined(_EGL_PLATFORM_POSIX)
- if (env && strchr(env, '/'))
+ if (env && strchr(env, '/')) {
search_path = "";
-#endif
+ if ((geteuid() != getuid() || getegid() != getgid())) {
+ _eglLog(_EGL_DEBUG,
+ "ignore EGL_DRIVER for setuid/setgid binaries");
+ env = NULL;
+ }
+ }
+#endif /* _EGL_PLATFORM_POSIX */
if (!env)
return EGL_FALSE;