summaryrefslogtreecommitdiffstats
path: root/dbus
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2006-10-01 20:05:39 +0000
committerHavoc Pennington <hp@redhat.com>2006-10-01 20:05:39 +0000
commit10fe37f58213d3895229208453c3e691e554ed72 (patch)
tree45b26b235471d398ef9d7d1331a00b02690d62b1 /dbus
parent7020b573764bb86551d329e867c2e87172424c9b (diff)
2006-10-01 Havoc Pennington <hp@redhat.com>
* tools/dbus-launch.c (print_variables): if no syntax is given, don't print something that's sort-of-half-sh-syntax, just print a plain key-value pairs thing. * tools/dbus-launch-x11.c: use machine ID rather than hostname for the local machine representation (but still have the hostname in the display). Remove the hostname from the display if it is localhost. Change session files to be named ~/.dbus/session-bus/machine-display. Change X atoms to be underscore-prefixed so nobody whines about ICCCM compliance. Otherwise name them the same as the env variables. Change session file format to include key-value pairs and an explanatory comment. Keys are the same as the env variables. (set_address_in_x11): X property format can't depend on sizeof(pid_t) on a particular machine, fix to always be 32 bits * tools/dbus-launch.c: make --autolaunch take a machine id argument. If --autolaunch is used with a program to run, complain for now (but add a FIXME). Also, don't look for existing bus if there's a program to run (but add a FIXME). * dbus/dbus-sysdeps-unix.c (_dbus_get_autolaunch_address): pass machine uuid to dbus-launch (avoids linking dbus-launch to libdbus just to get this, and avoids duplicating uuid-reading code). * tools/dbus-launch.1: clarify various things
Diffstat (limited to 'dbus')
-rw-r--r--dbus/dbus-sysdeps-unix.c52
1 files changed, 44 insertions, 8 deletions
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index 55b61a39..22ef9969 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -2293,18 +2293,44 @@ _dbus_get_tmpdir(void)
* @returns #TRUE on success, #FALSE if an error happened
*/
dbus_bool_t
-_dbus_get_autolaunch_address (DBusString *address, DBusError *error)
+_dbus_get_autolaunch_address (DBusString *address,
+ DBusError *error)
{
- static char *argv[] = { DBUS_BINDIR "/dbus-launch", "--autolaunch",
- "--binary-syntax", NULL };
+ static char *argv[5];
int address_pipe[2];
pid_t pid;
int ret;
int status;
int orig_len;
-
+ int i;
+ DBusString uuid;
+ dbus_bool_t retval;
+
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
+ retval = FALSE;
+ _dbus_string_init (&uuid);
+
+ if (!_dbus_get_local_machine_uuid_encoded (&uuid))
+ {
+ _DBUS_SET_OOM (error);
+ goto out;
+ }
+
+ i = 0;
+ argv[i] = DBUS_BINDIR "/dbus-launch";
+ ++i;
+ argv[i] = "--autolaunch";
+ ++i;
+ argv[i] = _dbus_string_get_const_data (&uuid);
+ ++i;
+ argv[i] = "--binary-syntax";
+ ++i;
+ argv[i] = NULL;
+ ++i;
+
+ _dbus_assert (i == _DBUS_N_ELEMENTS (argv));
+
orig_len = _dbus_string_get_length (address);
#define READ_END 0
@@ -2316,7 +2342,7 @@ _dbus_get_autolaunch_address (DBusString *address, DBusError *error)
_dbus_strerror (errno));
_dbus_verbose ("Failed to create a pipe to call dbus-launch: %s\n",
_dbus_strerror (errno));
- return FALSE;
+ goto out;
}
pid = fork ();
@@ -2327,7 +2353,7 @@ _dbus_get_autolaunch_address (DBusString *address, DBusError *error)
_dbus_strerror (errno));
_dbus_verbose ("Failed to fork() to call dbus-launch: %s\n",
_dbus_strerror (errno));
- return FALSE;
+ goto out;
}
if (pid == 0)
@@ -2389,9 +2415,19 @@ _dbus_get_autolaunch_address (DBusString *address, DBusError *error)
_dbus_string_set_length (address, orig_len);
dbus_set_error (error, DBUS_ERROR_SPAWN_EXEC_FAILED,
"Failed to execute dbus-launch to autolaunch D-Bus session");
- return FALSE;
+ goto out;
}
- return TRUE;
+
+ retval = TRUE;
+
+ out:
+ if (retval)
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+ else
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+
+ _dbus_string_free (&uuid);
+ return retval;
}
/**