mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-01-03 19:40:14 +01:00
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=39196 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Colin Walters <walters@verbum.org>
This commit is contained in:
parent
412538b3b9
commit
5ee72fe2e1
3 changed files with 19 additions and 22 deletions
|
|
@ -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 ();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue