diff -urN a/configure.in b/configure.in
--- a/configure.in	2012-10-10 16:53:23.042888925 +0200
+++ b/configure.in	2012-10-10 17:00:21.943232932 +0200
@@ -590,7 +590,7 @@
 AC_CHECK_LIB(socket,socket)
 AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)])
 
-AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll)
+AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll __secure_getenv)
 
 #### Check for broken poll; taken from Glib's configure
 
diff -urN a/dbus/dbus-keyring.c b/dbus/dbus-keyring.c
--- a/dbus/dbus-keyring.c	2012-10-10 16:53:23.033889154 +0200
+++ b/dbus/dbus-keyring.c	2012-10-10 17:00:21.944232895 +0200
@@ -718,6 +718,13 @@
   DBusCredentials *our_credentials;
   
   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+  if (_dbus_check_setuid ())
+    {
+      dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED,
+                            "Unable to create DBus keyring when setuid");
+      return NULL;
+    }
   
   keyring = NULL;
   error_set = FALSE;
diff -urN a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c
--- a/dbus/dbus-sysdeps.c	2012-10-10 16:53:23.038889009 +0200
+++ b/dbus/dbus-sysdeps.c	2012-10-10 17:00:21.944232895 +0200
@@ -174,6 +174,11 @@
 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);
 }
 
diff -urN a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h
--- a/dbus/dbus-sysdeps.h	2012-10-10 16:53:23.033889154 +0200
+++ b/dbus/dbus-sysdeps.h	2012-10-10 17:00:21.945232857 +0200
@@ -97,6 +97,7 @@
 
 void _dbus_abort (void) _DBUS_GNUC_NORETURN;
 
+dbus_bool_t _dbus_check_setuid (void);
 const char* _dbus_getenv (const char *varname);
 dbus_bool_t _dbus_setenv (const char *varname,
 			  const char *value);
diff -urN a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
--- a/dbus/dbus-sysdeps-unix.c	2012-10-10 16:53:23.042888925 +0200
+++ b/dbus/dbus-sysdeps-unix.c	2012-10-10 17:00:21.945232857 +0200
@@ -2743,6 +2743,13 @@
 #ifdef HAVE_SOCKETPAIR
   int fds[2];
 
+  if (_dbus_check_setuid ())
+    {
+      dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED,
+                            "Unable to autolaunch when setuid");
+      return FALSE;
+    }
+
   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
   
   if (socketpair (AF_UNIX, SOCK_STREAM, 0, fds) < 0)
@@ -3353,4 +3360,57 @@
   return errno == EAGAIN || errno == EWOULDBLOCK;
 }
 
+/**
+ * **NOTE**: If you modify this function, please also consider making
+ * the corresponding change in GLib.  See
+ * glib/gutils.c:g_check_setuid().
+ *
+ * Returns TRUE if the current process was executed as setuid (or an
+ * equivalent __libc_enable_secure is available).  See:
+ * http://osdir.com/ml/linux.lfs.hardened/2007-04/msg00032.html
+ */
+dbus_bool_t
+_dbus_check_setuid (void)
+{
+  /* TODO: get __libc_enable_secure exported from glibc.
+   * See http://www.openwall.com/lists/owl-dev/2012/08/14/1
+   */
+#if 0 && defined(HAVE_LIBC_ENABLE_SECURE)
+  {
+    /* See glibc/include/unistd.h */
+    extern int __libc_enable_secure;
+    return __libc_enable_secure;
+  }
+#elif defined(HAVE_ISSETUGID)
+  /* BSD: http://www.freebsd.org/cgi/man.cgi?query=issetugid&sektion=2 */
+  return issetugid ();
+#else
+  uid_t ruid, euid, suid; /* Real, effective and saved user ID's */
+  gid_t rgid, egid, sgid; /* Real, effective and saved group ID's */
+
+  static dbus_bool_t check_setuid_initialised;
+  static dbus_bool_t is_setuid;
+
+  if (_DBUS_UNLIKELY (!check_setuid_initialised))
+    {
+#ifdef HAVE_GETRESUID
+      if (getresuid (&ruid, &euid, &suid) != 0 ||
+          getresgid (&rgid, &egid, &sgid) != 0)
+#endif /* HAVE_GETRESUID */
+        {
+          suid = ruid = getuid ();
+          sgid = rgid = getgid ();
+          euid = geteuid ();
+          egid = getegid ();
+        }
+
+      check_setuid_initialised = TRUE;
+      is_setuid = (ruid != euid || ruid != suid ||
+                   rgid != egid || rgid != sgid);
+
+    }
+  return is_setuid;
+#endif
+}
+
 /* tests in dbus-sysdeps-util.c */
