diff options
Diffstat (limited to 'dbus/dbus-sysdeps.c')
-rw-r--r-- | dbus/dbus-sysdeps.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 861bfec9..de3a18cb 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -29,6 +29,7 @@ #include "dbus-protocol.h" #include "dbus-string.h" #include "dbus-list.h" +#include "dbus-misc.h" /* NOTE: If you include any unix/windows-specific headers here, you are probably doing something * wrong and should be putting some code in dbus-sysdeps-unix.c or dbus-sysdeps-win.c. @@ -46,10 +47,6 @@ #include <errno.h> #endif -_DBUS_DEFINE_GLOBAL_LOCK (win_fds); -_DBUS_DEFINE_GLOBAL_LOCK (sid_atom_cache); -_DBUS_DEFINE_GLOBAL_LOCK (system_users); - #ifdef DBUS_WIN #include <stdlib.h> #elif (defined __APPLE__) @@ -96,6 +93,8 @@ _dbus_abort (void) } /** + * @ingroup DBusMisc + * * Wrapper for setenv(). If the value is #NULL, unsets * the environment variable. * @@ -104,13 +103,16 @@ _dbus_abort (void) * we can not rely on internal implementation details of * the underlying libc library. * + * This function is not thread-safe, because altering the environment + * in Unix is not thread-safe in general. + * * @param varname name of environment variable - * @param value value of environment variable - * @returns #TRUE on success. + * @param value value of environment variable, or #NULL to unset + * @returns #TRUE on success, #FALSE if not enough memory. */ dbus_bool_t -_dbus_setenv (const char *varname, - const char *value) +dbus_setenv (const char *varname, + const char *value) { _dbus_assert (varname != NULL); @@ -182,6 +184,11 @@ _dbus_setenv (const char *varname, const char* _dbus_getenv (const char *varname) { + /* 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); } |