mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-05 13:29:57 -05:00
client-conf: Don't create multiple cookie files
The old code loaded cookies at the time of loading the client configuration, which could lead to creation of multiple cookie files. For example, when pa_client_conf_load() was called, the default cookie file was created, and then if PULSE_COOKIE was set, pa_client_conf_env() would create another cookie file. This patch moves the loading of the cookie to a separate function, which pa_context calls just before needing the cookie, so the cookie won't be loaded from the default file if PULSE_COOKIE is set. This patch also splits the single cookie and cookie_file fields in pa_client_conf into multiple fields, one for each possible cookie source. That change allows falling back to another cookie source if the primary source doesn't work. BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=75006
This commit is contained in:
parent
0a583fe0c3
commit
1116daa5eb
4 changed files with 104 additions and 88 deletions
|
|
@ -506,6 +506,7 @@ finish:
|
|||
}
|
||||
|
||||
static void setup_context(pa_context *c, pa_iochannel *io) {
|
||||
uint8_t cookie[PA_NATIVE_COOKIE_LENGTH];
|
||||
pa_tagstruct *t;
|
||||
uint32_t tag;
|
||||
|
||||
|
|
@ -524,7 +525,7 @@ static void setup_context(pa_context *c, pa_iochannel *io) {
|
|||
pa_assert(!c->pdispatch);
|
||||
c->pdispatch = pa_pdispatch_new(c->mainloop, c->use_rtclock, command_table, PA_COMMAND_MAX);
|
||||
|
||||
if (!c->conf->cookie_valid)
|
||||
if (pa_client_conf_load_cookie(c->conf, cookie, sizeof(cookie)) < 0)
|
||||
pa_log_info(_("No cookie loaded. Attempting to connect without."));
|
||||
|
||||
t = pa_tagstruct_command(c, PA_COMMAND_AUTH, &tag);
|
||||
|
|
@ -538,7 +539,7 @@ static void setup_context(pa_context *c, pa_iochannel *io) {
|
|||
/* Starting with protocol version 13 we use the MSB of the version
|
||||
* tag for informing the other side if we could do SHM or not */
|
||||
pa_tagstruct_putu32(t, PA_PROTOCOL_VERSION | (c->do_shm ? 0x80000000U : 0));
|
||||
pa_tagstruct_put_arbitrary(t, c->conf->cookie, sizeof(c->conf->cookie));
|
||||
pa_tagstruct_put_arbitrary(t, cookie, sizeof(cookie));
|
||||
|
||||
#ifdef HAVE_CREDS
|
||||
{
|
||||
|
|
@ -1451,11 +1452,13 @@ size_t pa_context_get_tile_size(pa_context *c, const pa_sample_spec *ss) {
|
|||
|
||||
int pa_context_load_cookie_from_file(pa_context *c, const char *cookie_file_path) {
|
||||
pa_assert(c);
|
||||
pa_assert(cookie_file_path);
|
||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||
|
||||
PA_CHECK_VALIDITY(c, !pa_detect_fork(), PA_ERR_FORKED);
|
||||
PA_CHECK_VALIDITY(c, c->state == PA_CONTEXT_UNCONNECTED, PA_ERR_BADSTATE);
|
||||
PA_CHECK_VALIDITY(c, !cookie_file_path || *cookie_file_path, PA_ERR_INVALID);
|
||||
|
||||
return pa_client_conf_load_cookie_from_file(c->conf, cookie_file_path);
|
||||
pa_client_conf_set_cookie_file_from_application(c->conf, cookie_file_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue