Commit 5ee72fe2 authored by Simon McVittie's avatar Simon McVittie

dbus-run-session: remove various extra variables from the environment

DBUS_SESSION_BUS_PID is not mandatory to set, but we should unset it
if present, since it points to a different session's bus. Likewise for
DBUS_SESSION_BUS_WINDOWID.

Similarly, if DBUS_STARTER_BUS_TYPE and DBUS_STARTER_ADDRESS
are set (as they would be under GNOME Terminal 3.8, see
<https://bugs.freedesktop.org/show_bug.cgi?id=63119>) then they
are likely to point to a different session's bus.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39196Signed-off-by: default avatarSimon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Colin Walters's avatarColin Walters <walters@verbum.org>
parent 412538b3
......@@ -130,6 +130,13 @@ contain a
<emphasis remap='I'>PROGRAM</emphasis>
in the environment variable
<emphasis remap='B'>DBUS_SESSION_BUS_ADDRESS</emphasis>.</para>
<para>The variables
<emphasis remap='B'>DBUS_SESSION_BUS_PID</emphasis>,
<emphasis remap='B'>DBUS_SESSION_BUS_WINDOWID</emphasis>,
<emphasis remap='B'>DBUS_STARTER_BUS_TYPE</emphasis> and
<emphasis remap='B'>DBUS_STARTER_ADDRESS</emphasis>
are removed from the environment, if present.</para>
</refsect1>
<refsect1 id='bugs'><title>BUGS</title>
......
......@@ -47,6 +47,10 @@ dbus_launch_SOURCES= \
dbus_run_session_SOURCES = \
dbus-run-session.c
dbus_run_session_LDADD = \
$(top_builddir)/dbus/libdbus-1.la \
$(NULL)
endif
dbus_cleanup_sockets_SOURCES= \
......
......@@ -36,6 +36,8 @@
#include <sys/wait.h>
#include <signal.h>
#include "dbus/dbus.h"
#define MAX_ADDR_LEN 512
#define PIPE_READ_END 0
#define PIPE_WRITE_END 1
......@@ -100,22 +102,6 @@ oom (void)
exit (1);
}
static void *
xmalloc (size_t bytes)
{
void *ret;
if (bytes == 0)
bytes = 1;
ret = malloc (bytes);
if (ret == NULL)
oom ();
return ret;
}
typedef enum
{
READ_STATUS_OK, /**< Read succeeded */
......@@ -228,7 +214,6 @@ main (int argc, char **argv)
int requires_arg = 0;
pid_t bus_pid;
pid_t app_pid;
char *envvar;
while (i < argc)
{
......@@ -397,11 +382,12 @@ main (int argc, char **argv)
close (bus_address_pipe[PIPE_READ_END]);
envvar = xmalloc (strlen ("DBUS_SESSION_BUS_ADDRESS=") +
strlen (bus_address) + 1);
strcpy (envvar, "DBUS_SESSION_BUS_ADDRESS=");
strcat (envvar, bus_address);
putenv (envvar);
if (!dbus_setenv ("DBUS_SESSION_BUS_ADDRESS", bus_address) ||
!dbus_setenv ("DBUS_SESSION_BUS_PID", NULL) ||
!dbus_setenv ("DBUS_SESSION_BUS_WINDOWID", NULL) ||
!dbus_setenv ("DBUS_STARTER_ADDRESS", NULL) ||
!dbus_setenv ("DBUS_STARTER_BUS_TYPE", NULL))
oom ();
app_pid = fork ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment