From 92c24191d4ee9379626c5fef9f6c234f64eeeee1 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Mon, 29 Jan 2024 12:42:18 +0000 Subject: [PATCH] tree-wide: use __normal_user() everywhere instead of writing the check manually Cc: mesa-stable Part-of: --- src/gallium/frontends/dri/dri_context.c | 2 +- src/intel/compiler/brw_shader.cpp | 3 ++- src/loader/loader.c | 4 ++-- src/util/disk_cache_os.c | 3 ++- src/util/log.c | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/gallium/frontends/dri/dri_context.c b/src/gallium/frontends/dri/dri_context.c index 1ffaded9174..2bdb83e89e9 100644 --- a/src/gallium/frontends/dri/dri_context.c +++ b/src/gallium/frontends/dri/dri_context.c @@ -169,7 +169,7 @@ dri_create_context(struct dri_screen *screen, if (debug_get_bool_option("MESA_NO_ERROR", false) || driQueryOptionb(&screen->dev->option_cache, "mesa_no_error")) #if !defined(_WIN32) - if (geteuid() == getuid()) + if (__normal_user()) #endif attribs.flags |= ST_CONTEXT_FLAG_NO_ERROR; diff --git a/src/intel/compiler/brw_shader.cpp b/src/intel/compiler/brw_shader.cpp index c53a5e4fa6f..c500f5e2b4f 100644 --- a/src/intel/compiler/brw_shader.cpp +++ b/src/intel/compiler/brw_shader.cpp @@ -29,6 +29,7 @@ #include "brw_vec4_tes.h" #include "dev/intel_debug.h" #include "util/macros.h" +#include "util/u_debug.h" enum brw_reg_type brw_type_for_base_type(const struct glsl_type *type) @@ -1230,7 +1231,7 @@ void backend_shader::dump_instructions(const char *name) const { FILE *file = stderr; - if (name && geteuid() != 0) { + if (name && __normal_user()) { file = fopen(name, "w"); if (!file) file = stderr; diff --git a/src/loader/loader.c b/src/loader/loader.c index 4b8f532fe74..19c456c7020 100644 --- a/src/loader/loader.c +++ b/src/loader/loader.c @@ -675,7 +675,7 @@ loader_get_driver_for_fd(int fd) * user's problem, but this allows vc4 simulator to run on an i965 host, * and may be useful for some touch testing of i915 on an i965 host. */ - if (geteuid() == getuid()) { + if (__normal_user()) { const char *override = os_get_option("MESA_LOADER_DRIVER_OVERRIDE"); if (override) return strdup(override); @@ -780,7 +780,7 @@ loader_open_driver_lib(const char *driver_name, const char *search_paths, *next, *end; search_paths = NULL; - if (geteuid() == getuid() && search_path_vars) { + if (__normal_user() && search_path_vars) { for (int i = 0; search_path_vars[i] != NULL; i++) { search_paths = getenv(search_path_vars[i]); if (search_paths) diff --git a/src/util/disk_cache_os.c b/src/util/disk_cache_os.c index f116a0c8de4..d8bd8a0f532 100644 --- a/src/util/disk_cache_os.c +++ b/src/util/disk_cache_os.c @@ -34,6 +34,7 @@ #include "util/compress.h" #include "util/crc32.h" +#include "util/u_debug.h" #include "util/disk_cache.h" #include "util/disk_cache_os.h" @@ -980,7 +981,7 @@ disk_cache_enabled() return false; /* If running as a users other than the real user disable cache */ - if (geteuid() != getuid()) + if (!__normal_user()) return false; /* At user request, disable shader cache entirely. */ diff --git a/src/util/log.c b/src/util/log.c index 96ee7cf98b7..571c0b74a7e 100644 --- a/src/util/log.c +++ b/src/util/log.c @@ -94,7 +94,7 @@ mesa_log_init_once(void) mesa_log_file = stderr; #if !DETECT_OS_WINDOWS - if (geteuid() == getuid()) { + if (__normal_user()) { const char *log_file = os_get_option("MESA_LOG_FILE"); if (log_file) { FILE *fp = fopen(log_file, "w");