X11: Add xauthority parameter

Add an xauthority parameter and use it in the startup script.

Apparently on some systems the X authentication cookie is not stored in
~/.Xauthority but in some dynamic location pointed to by the XAUTHORITY
environment variable. The environment variable therefore needs to be set
in the PulseAudio daemon environment in order to have access to the X
server from the PulseAudio daemon, but the variable is not necessarily
set when starting PulseAudio. For example, systemd starts PulseAudio
outside the X session. The start-pulseaudio-x11 script is run in the
X session, so it has the environment variable available, and can pass it
to the X modules, which then can set the variable in the daemon
environment.

RedHat bug: https://bugzilla.redhat.com/show_bug.cgi?id=1723065
Debian bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=593746

Based on patch by Alexander Kurtz <kurtz.alex@googlemail.com>
This commit is contained in:
Wim Taymans 2019-09-12 09:49:40 +02:00 committed by Tanu Kaskinen
parent 6f28865950
commit c7a55174dc
5 changed files with 35 additions and 3 deletions

View file

@ -19,8 +19,8 @@ set -e
if [ x"$DISPLAY" != x ] ; then
@PACTL_BINARY@ load-module module-x11-publish "display=$DISPLAY" > /dev/null
@PACTL_BINARY@ load-module module-x11-cork-request "display=$DISPLAY" > /dev/null
@PACTL_BINARY@ load-module module-x11-publish "display=$DISPLAY xauthority=$XAUTHORITY" > /dev/null
@PACTL_BINARY@ load-module module-x11-cork-request "display=$DISPLAY xauthority=$XAUTHORITY" > /dev/null
# KDE plasma versions older than 5.17.0 use module-device-manager's routing API.
# Check for current plasma version and load module if it's necessary.
@ -32,6 +32,6 @@ if [ x"$DISPLAY" != x ] ; then
fi
if [ x"$SESSION_MANAGER" != x ] ; then
@PACTL_BINARY@ load-module module-x11-xsmp "display=$DISPLAY session_manager=$SESSION_MANAGER" > /dev/null
@PACTL_BINARY@ load-module module-x11-xsmp "display=$DISPLAY xauthority=$XAUTHORITY session_manager=$SESSION_MANAGER" > /dev/null
fi
fi

View file

@ -44,6 +44,7 @@ static const char* const valid_modargs[] = {
"sink",
"sample",
"display",
"xauthority",
NULL
};
@ -125,6 +126,13 @@ int pa__init(pa_module*m) {
u->sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink", NULL));
u->x11_client = NULL;
if (pa_modargs_get_value(ma, "xauthority", NULL)) {
if (setenv("XAUTHORITY", pa_modargs_get_value(ma, "xauthority", NULL), 1)) {
pa_log("setenv() for $XAUTHORITY failed");
goto fail;
}
}
if (!(u->x11_wrapper = pa_x11_wrapper_get(m->core, pa_modargs_get_value(ma, "display", NULL))))
goto fail;

View file

@ -46,6 +46,7 @@ PA_MODULE_USAGE("display=<X11 display>");
static const char* const valid_modargs[] = {
"display",
"xauthority",
NULL
};
@ -128,6 +129,13 @@ int pa__init(pa_module *m) {
m->userdata = u = pa_xnew0(struct userdata, 1);
u->module = m;
if (pa_modargs_get_value(ma, "xauthority", NULL)) {
if (setenv("XAUTHORITY", pa_modargs_get_value(ma, "xauthority", NULL), 1)) {
pa_log("setenv() for $XAUTHORITY failed");
goto fail;
}
}
if (!(u->x11_wrapper = pa_x11_wrapper_get(m->core, pa_modargs_get_value(ma, "display", NULL))))
goto fail;

View file

@ -56,6 +56,7 @@ static const char* const valid_modargs[] = {
"sink",
"source",
"cookie",
"xauthority",
NULL
};
@ -156,6 +157,13 @@ int pa__init(pa_module*m) {
if (!(u->auth_cookie = pa_auth_cookie_get(m->core, pa_modargs_get_value(ma, "cookie", PA_NATIVE_COOKIE_FILE), true, PA_NATIVE_COOKIE_LENGTH)))
goto fail;
if (pa_modargs_get_value(ma, "xauthority", NULL)) {
if (setenv("XAUTHORITY", pa_modargs_get_value(ma, "xauthority", NULL), 1)) {
pa_log("setenv() for $XAUTHORITY failed");
goto fail;
}
}
if (!(u->x11_wrapper = pa_x11_wrapper_get(m->core, pa_modargs_get_value(ma, "display", NULL))))
goto fail;

View file

@ -46,6 +46,7 @@ static bool ice_in_use = false;
static const char* const valid_modargs[] = {
"session_manager",
"display",
"xauthority",
NULL
};
@ -139,6 +140,13 @@ int pa__init(pa_module*m) {
goto fail;
}
if (pa_modargs_get_value(ma, "xauthority", NULL)) {
if (setenv("XAUTHORITY", pa_modargs_get_value(ma, "xauthority", NULL), 1)) {
pa_log("setenv() for $XAUTHORITY failed");
goto fail;
}
}
if (!(u->x11 = pa_x11_wrapper_get(m->core, pa_modargs_get_value(ma, "display", NULL))))
goto fail;