Bug#593746: pulseaudio doesn't support that $XAUTHORITY may have changed after logout/login

Alexander Kurtz kurtz.alex at googlemail.com
Fri Aug 20 17:34:32 UTC 2010


Package: pulseaudio
Version: 0.9.21-3
Severity: normal

Hi,

=== Problem ===

I am running Debian squeeze with GNOME, GDM3 and Pulseaudio installed.

After booting and logging into GNOME, right-clicking on the volume
control applet (alternative: run `gnome-volume-control') will bring up
the PA-specific GNOME volume control program (see g-v-c-pulse.png).

However, if I logout and login again, I won't get the PA-specific
volume control program, instead the generic one for gstreamer pops
up (see g-v-c-gstreamer.png).

=== Reasons 1/3 ===

Looking at /usr/bin/gnome-volume-control

	$ cat /usr/bin/gnome-volume-control
	#! /bin/sh

	if xprop -root | grep -q ^PULSE_SERVER ; then
	     exec gnome-volume-control.pulse "$@"
	fi
	exec gnome-volume-control.gstreamer "$@"

reveals that gnome-volume-control uses the properties stored by PA in
the X root window to determine which program to launch. But these are
not there:

	$ xprop -root | grep -q ^PULSE_SERVER
	$ echo $?
	1

However if I restart PA they are back:

	$ killall pulseaudio; sleep 1; start-pulseaudio-x11
	$ xprop -root | grep -q ^PULSE_SERVER
	$ echo $?
	0

= Reasons 2/3 =

After logging out and in again, looking a the PA process

	$ ps -F -C pulseaudio -C x-session-manager
	UID        PID  PPID  C    SZ   RSS PSR STIME TTY          TIME CMD
	1000     18979     1  0 52023  5104   2 17:25 ?        00:00:00 /usr/bin/pulseaudio --start
	1000     19128 19095  0 66014  8344   2 17:29 ?        00:00:00 x-session-manager
	                                        ^^^^^

shows that the PA instance from the previous session is still running.
AFAIK that's because GNOME starts its session daemons and then orphans
them, so they'll get adopted by init (PID 1) and therefore not signaled
when their parent process (a.k.a. the login shell) exits. IMHO that's
a bug too, but that's another issue which we can discuss separately.

But PA actually supports hopping from one X-session to another:
/etc/xdg/autostart/pulseaudio.desktop executes `start-pulseaudio-x11'
during each login which starts PA if necessary and publishes its
properties to the X root window by loading module-x11-publish:

	$ egrep -v '(^#|^$)' /usr/bin/start-pulseaudio-x11 
	set -e
	[ -z "$PULSE_SERVER" ]
	/usr/bin/pulseaudio --start "$@"
	if [ x"$DISPLAY" != x ] ; then
	    /usr/bin/pactl load-module module-x11-publish "display=$DISPLAY" > /dev/null
	    /usr/bin/pactl load-module module-x11-cork-request "display=$DISPLAY" > /dev/null
	    if [ x"$SESSION_MANAGER" != x ] ; then
		/usr/bin/pactl load-module module-x11-xsmp "display=$DISPLAY session_manager=$SESSION_MANAGER" > /dev/null
	    fi
	fi

As you can see this script even supports that $DISPLAY may change during
logins. So why does publishing PA's properties to X11 still fail?

=== Reasons 3/3 ===

Looking at the syslog

	$ sudo tail /var/log/syslog
	[...]
	Aug 20 17:29:31 localhost pulseaudio[19234]: pid.c: Daemon already running.
	Aug 20 17:29:31 localhost pulseaudio[18979]: x11wrap.c: XOpenDisplay() failed
	Aug 20 17:29:31 localhost pulseaudio[18979]: module.c: Failed to load  module "module-x11-publish" (argument: "display=:0.0"): initialization failed.
	[...]

shows us that the display can't be opened. After looking around for a
while I found the reason for this: With GDM3 the MIT-MAGIC-COOKIE-1 for
X isn't stored in ~/.Xauthority anymore (in fact there is even no such
file on my machine) but somewhere under /var:

	$ echo $XAUTHORITY
	/var/run/gdm3/auth-for-alexander-cIsL3O/database

As you can see the last part is randomised and changes for every login.

=== Conclusion ===

PA does support being started in X-session A and (still) being used in a
later X-session B (see /usr/bin/start-pulseaudio-x11). It does even
support that $DISPLAY may change during sessions.

But the developers seem to have forgotten that $XAUTHORITY may also
change (probably because with most display managers it's always
~/.Xauthority).

So when GDM3 is used and PA is already running, it will try to publish
its properties to the correct $DISPLAY but fails because it uses the
wrong $XAUTHORITY (the one from the session where PA was started).

Best regards

Alexander Kurtz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: g-v-c-pulse.png
Type: image/png
Size: 31843 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-pulseaudio-devel/attachments/20100820/4ba216a5/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: g-v-c-gstreamer.png
Type: image/png
Size: 30819 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-pulseaudio-devel/attachments/20100820/4ba216a5/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.alioth.debian.org/pipermail/pkg-pulseaudio-devel/attachments/20100820/4ba216a5/attachment-0001.pgp>


More information about the pkg-pulseaudio-devel mailing list