mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
esound, native: Pass an absolute path to pa_authkey_load() when using a file in the home directory
If a relative path is passed to pa_authkey_load(), it will interpret the path as relative to the home directory. This is wrong, because relative paths should be interpreted to be relative to the config home directory. Before fixing pa_authkey_load(), this patch prepares for the change by using absolute paths when the file actually needs to be in the home directory (i.e. the fallback cookie path for the native protocol and the default cookie path for the esound protocol).
This commit is contained in:
parent
50042da434
commit
14845b2c8e
4 changed files with 35 additions and 10 deletions
|
|
@ -527,6 +527,8 @@ int pa__init(pa_module*m) {
|
||||||
const char *espeaker;
|
const char *espeaker;
|
||||||
uint32_t key;
|
uint32_t key;
|
||||||
pa_sink_new_data data;
|
pa_sink_new_data data;
|
||||||
|
char *cookie_path;
|
||||||
|
int r;
|
||||||
|
|
||||||
pa_assert(m);
|
pa_assert(m);
|
||||||
|
|
||||||
|
|
@ -620,9 +622,18 @@ int pa__init(pa_module*m) {
|
||||||
|
|
||||||
pa_socket_client_set_callback(u->client, on_connection, u);
|
pa_socket_client_set_callback(u->client, on_connection, u);
|
||||||
|
|
||||||
|
cookie_path = pa_xstrdup(pa_modargs_get_value(ma, "cookie", NULL));
|
||||||
|
if (!cookie_path) {
|
||||||
|
if (pa_append_to_home_dir(".esd_auth", &cookie_path) < 0)
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
/* Prepare the initial request */
|
/* Prepare the initial request */
|
||||||
u->write_data = pa_xmalloc(u->write_length = ESD_KEY_LEN + sizeof(int32_t));
|
u->write_data = pa_xmalloc(u->write_length = ESD_KEY_LEN + sizeof(int32_t));
|
||||||
if (pa_authkey_load(pa_modargs_get_value(ma, "cookie", ".esd_auth"), true, u->write_data, ESD_KEY_LEN) < 0) {
|
|
||||||
|
r = pa_authkey_load(cookie_path, true, u->write_data, ESD_KEY_LEN);
|
||||||
|
pa_xfree(cookie_path);
|
||||||
|
if (r < 0) {
|
||||||
pa_log("Failed to load cookie");
|
pa_log("Failed to load cookie");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,7 @@ void pa_client_conf_load(pa_client_conf *c, bool load_from_x11, bool load_from_e
|
||||||
|
|
||||||
int pa_client_conf_load_cookie(pa_client_conf *c, uint8_t *cookie, size_t cookie_length) {
|
int pa_client_conf_load_cookie(pa_client_conf *c, uint8_t *cookie, size_t cookie_length) {
|
||||||
int r;
|
int r;
|
||||||
|
char *fallback_path;
|
||||||
|
|
||||||
pa_assert(c);
|
pa_assert(c);
|
||||||
pa_assert(cookie);
|
pa_assert(cookie);
|
||||||
|
|
@ -213,9 +214,12 @@ int pa_client_conf_load_cookie(pa_client_conf *c, uint8_t *cookie, size_t cookie
|
||||||
if (r >= 0)
|
if (r >= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = pa_authkey_load(PA_NATIVE_COOKIE_FILE_FALLBACK, false, cookie, cookie_length);
|
if (pa_append_to_home_dir(PA_NATIVE_COOKIE_FILE_FALLBACK, &fallback_path) > 0) {
|
||||||
if (r >= 0)
|
r = pa_authkey_load(fallback_path, false, cookie, cookie_length);
|
||||||
return 0;
|
pa_xfree(fallback_path);
|
||||||
|
if (r >= 0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
r = pa_authkey_load(PA_NATIVE_COOKIE_FILE, true, cookie, cookie_length);
|
r = pa_authkey_load(PA_NATIVE_COOKIE_FILE, true, cookie, cookie_length);
|
||||||
if (r >= 0)
|
if (r >= 0)
|
||||||
|
|
|
||||||
|
|
@ -1707,15 +1707,20 @@ int pa_esound_options_parse(pa_esound_options *o, pa_core *c, pa_modargs *ma) {
|
||||||
pa_auth_cookie_unref(o->auth_cookie);
|
pa_auth_cookie_unref(o->auth_cookie);
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
const char *cn;
|
char *cn;
|
||||||
|
|
||||||
/* The new name for this is 'auth-cookie', for compat reasons
|
/* The new name for this is 'auth-cookie', for compat reasons
|
||||||
* we check the old name too */
|
* we check the old name too */
|
||||||
if (!(cn = pa_modargs_get_value(ma, "auth-cookie", NULL)))
|
if (!(cn = pa_xstrdup(pa_modargs_get_value(ma, "auth-cookie", NULL)))) {
|
||||||
if (!(cn = pa_modargs_get_value(ma, "cookie", NULL)))
|
if (!(cn = pa_xstrdup(pa_modargs_get_value(ma, "cookie", NULL)))) {
|
||||||
cn = DEFAULT_COOKIE_FILE;
|
if (pa_append_to_home_dir(DEFAULT_COOKIE_FILE, &cn) < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!(o->auth_cookie = pa_auth_cookie_get(c, cn, true, ESD_KEY_LEN)))
|
o->auth_cookie = pa_auth_cookie_get(c, cn, true, ESD_KEY_LEN);
|
||||||
|
pa_xfree(cn);
|
||||||
|
if (!o->auth_cookie)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
} else
|
} else
|
||||||
|
|
|
||||||
|
|
@ -5303,7 +5303,12 @@ int pa_native_options_parse(pa_native_options *o, pa_core *c, pa_modargs *ma) {
|
||||||
else {
|
else {
|
||||||
o->auth_cookie = pa_auth_cookie_get(c, PA_NATIVE_COOKIE_FILE, false, PA_NATIVE_COOKIE_LENGTH);
|
o->auth_cookie = pa_auth_cookie_get(c, PA_NATIVE_COOKIE_FILE, false, PA_NATIVE_COOKIE_LENGTH);
|
||||||
if (!o->auth_cookie) {
|
if (!o->auth_cookie) {
|
||||||
o->auth_cookie = pa_auth_cookie_get(c, PA_NATIVE_COOKIE_FILE_FALLBACK, false, PA_NATIVE_COOKIE_LENGTH);
|
char *fallback_path;
|
||||||
|
|
||||||
|
if (pa_append_to_home_dir(PA_NATIVE_COOKIE_FILE_FALLBACK, &fallback_path) >= 0) {
|
||||||
|
o->auth_cookie = pa_auth_cookie_get(c, fallback_path, false, PA_NATIVE_COOKIE_LENGTH);
|
||||||
|
pa_xfree(fallback_path);
|
||||||
|
}
|
||||||
|
|
||||||
if (!o->auth_cookie)
|
if (!o->auth_cookie)
|
||||||
o->auth_cookie = pa_auth_cookie_get(c, PA_NATIVE_COOKIE_FILE, true, PA_NATIVE_COOKIE_LENGTH);
|
o->auth_cookie = pa_auth_cookie_get(c, PA_NATIVE_COOKIE_FILE, true, PA_NATIVE_COOKIE_LENGTH);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue