From 64a28f3193ac8518d43dcb716270fd749d34b2cc Mon Sep 17 00:00:00 2001 From: Umut Tezduyar Lindskog Date: Fri, 10 Oct 2014 13:09:53 +0200 Subject: [PATCH] Use secure_getenv if available --- configure.ac | 2 ++ dbus/dbus-sysdeps.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/configure.ac b/configure.ac index 2d56fff..336d7cd 100644 --- a/configure.ac +++ b/configure.ac @@ -593,6 +593,8 @@ AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)]) AC_CHECK_FUNCS([vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll setlocale localeconv strtoll strtoull issetugid getresuid getrlimit]) +AC_CHECK_FUNCS([__secure_getenv secure_getenv]) + AC_CHECK_HEADERS([syslog.h]) if test "x$ac_cv_header_syslog_h" = "xyes"; then AC_CHECK_DECLS([LOG_PERROR], [], [], [[#include ]]) diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index f4ba0fa..8eeb74f 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -56,6 +56,12 @@ extern char **environ; #endif +#ifndef HAVE_SECURE_GETENV +# ifdef HAVE___SECURE_GETENV +# define secure_getenv __secure_getenv +# endif +#endif + /** * @defgroup DBusSysdeps Internal system-dependent API * @ingroup DBusInternals @@ -184,12 +190,16 @@ dbus_setenv (const char *varname, const char* _dbus_getenv (const char *varname) { +#ifdef secure_getenv + return secure_getenv(varname); +#else /* Don't respect any environment variables if the current process is * setuid. This is the equivalent of glibc's __secure_getenv(). */ if (_dbus_check_setuid ()) return NULL; return getenv (varname); +#endif } /** -- 1.7.10.4