#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.
#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__)
}
/**
+ * @ingroup DBusMisc
+ *
* Wrapper for setenv(). If the value is #NULL, unsets
* the environment variable.
*
* 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);
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);
}
_dbus_verbose ("Falling back to pseudorandom for %d bytes\n",
n_bytes);
- _dbus_get_current_time (NULL, &tv_usec);
+ _dbus_get_real_time (NULL, &tv_usec);
srand (tv_usec);
i = 0;