summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorColin Guthrie <cguthrie@mandriva.org>2011-03-25 23:03:31 +0000
committerColin Guthrie <cguthrie@mandriva.org>2011-03-25 23:14:28 +0000
commit7aa8a3fa8015d17240e5fc27bf44eb7d22e7e13a (patch)
treececc44a855e85b870c8124e5396372d567424d95 /src
parent34ddc5b9c533ed83d53238fff0777663f9c50336 (diff)
daemon: Fix regression introduced in f1d1447e.
With Tanu's patch, the server no longer starts when a server is configured. While this is sensible in most circumstances there is a corner case where we still want to start. In a typical X11 login, module-x11-publish will be loaded and will thus set the PULSE_SERVER X11 property on the root window. This then hits the check introduced in f1d1447e and exits. If PA had previously crashed (thus leaving behind it's X11 properties) then this means that we will not autospawn nor even allow ourselves to be started manually until pax11publish -r is run to clear out the X11 properties. This is obviously not desirable. This patch introduces a more in-depth check of the server. If it looks like a local unix domain socket, then we do not exit straight away and instead probe further. This should not pose any problems with e.g. remote SSH usage as the DBus Machine ID is used in the server string.
Diffstat (limited to 'src')
-rw-r--r--src/daemon/main.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/daemon/main.c b/src/daemon/main.c
index f939313c..53166560 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -90,6 +90,7 @@
#include <pulsecore/once.h>
#include <pulsecore/shm.h>
#include <pulsecore/memtrap.h>
+#include <pulsecore/strlist.h>
#ifdef HAVE_DBUS
#include <pulsecore/dbus-shared.h>
#endif
@@ -673,10 +674,49 @@ int main(int argc, char *argv[]) {
}
if (conf->cmd == PA_CMD_START && (configured_address = check_configured_address())) {
- pa_log_notice(_("User-configured server at %s, not autospawning."), configured_address);
+ /* There is an server address in our config, but where did it come from?
+ * By default a standard X11 login will load module-x11-publish which will
+ * inject PULSE_SERVER X11 property. If the PA daemon crashes, we will end
+ * up hitting this code path. So we have to check to see if our configured_address
+ * is the same as the value that would go into this property so that we can
+ * recover (i.e. autospawn) from a crash.
+ */
+ char *ufn;
+ pa_bool_t start_anyway = FALSE;
+
+ if ((ufn = pa_runtime_path(PA_NATIVE_DEFAULT_UNIX_SOCKET))) {
+ char *id;
+
+ if ((id = pa_machine_id())) {
+ pa_strlist *server_list;
+ char formatted_ufn[256];
+
+ pa_snprintf(formatted_ufn, sizeof(formatted_ufn), "{%s}unix:%s", id, ufn);
+ pa_xfree(id);
+
+ if ((server_list = pa_strlist_parse(configured_address))) {
+ char *u = NULL;
+
+ /* We only need to check the first server */
+ server_list = pa_strlist_pop(server_list, &u);
+ pa_strlist_free(server_list);
+
+ start_anyway = (u && pa_streq(formatted_ufn, u));
+ pa_xfree(u);
+ }
+ }
+ pa_xfree(ufn);
+ }
+
+ if (!start_anyway) {
+ pa_log_notice(_("User-configured server at %s, refusing to start/autospawn."), configured_address);
+ pa_xfree(configured_address);
+ retval = 0;
+ goto finish;
+ }
+
+ pa_log_notice(_("User-configured server at %s, which appears to be local. Probing deeper."), configured_address);
pa_xfree(configured_address);
- retval = 0;
- goto finish;
}
if (conf->system_instance && !conf->disallow_exit)