diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/support/env_linux.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/core/support/env_linux.c b/src/core/support/env_linux.c index 1ca6fa1aff..5863ad5682 100644 --- a/src/core/support/env_linux.c +++ b/src/core/support/env_linux.c @@ -43,7 +43,9 @@ #include "src/core/support/env.h" #include <dlfcn.h> +#include <features.h> #include <stdlib.h> +#include <string.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> @@ -60,12 +62,19 @@ char *gpr_getenv(const char *name) { const char *names[] = {"secure_getenv", "__secure_getenv", "getenv"}; for (size_t i = 0; getenv_func == NULL && i < GPR_ARRAY_SIZE(names); i++) { getenv_func = (getenv_type)dlsym(RTLD_DEFAULT, names[i]); + if (getenv_func != NULL && strstr(names[i], "secure") == NULL) { + gpr_log(GPR_DEBUG, "Warning: insecure environment read function '%s' used", names[i]); + } } char *result = getenv_func(name); return result == NULL ? result : gpr_strdup(result); -#else +#elif __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 17) char *result = secure_getenv(name); return result == NULL ? result : gpr_strdup(result); +#else + gpr_log(GPR_DEBUG, "Warning: insecure environment read function '%s' used", "getenv"); + char *result = getenv(name); + return result == NULL ? result : gpr_strdup(result); #endif } |