summaryrefslogtreecommitdiff
path: root/src/pulse/client-conf.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-05-15 23:59:33 +0200
committerLennart Poettering <lennart@poettering.net>2012-05-15 23:59:33 +0200
commit87ae8307057944662bb8a4b638f56fa980eef48a (patch)
tree06da8c75979700e9941c301b2c6b4bd6bcd126f5 /src/pulse/client-conf.c
parent9ab510a69216b468c80acad92a0e2360ffccfea2 (diff)
downloadpulseaudio-87ae8307057944662bb8a4b638f56fa980eef48a.tar.gz
auth: move cookie file to ~/.config/pulse/cookie
In order to follow XDG basedir, read the cookie file from ~/.config/pulse/cookie if possible, but fall back to the old file. if it doesn't exist.
Diffstat (limited to 'src/pulse/client-conf.c')
-rw-r--r--src/pulse/client-conf.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/pulse/client-conf.c b/src/pulse/client-conf.c
index e2c2aae17..781fdf919 100644
--- a/src/pulse/client-conf.c
+++ b/src/pulse/client-conf.c
@@ -71,7 +71,7 @@ pa_client_conf *pa_client_conf_new(void) {
c->daemon_binary = pa_xstrdup(PA_BINARY);
c->extra_arguments = pa_xstrdup("--log-target=syslog");
- c->cookie_file = pa_xstrdup(PA_NATIVE_COOKIE_FILE);
+ c->cookie_file = NULL;
return c;
}
@@ -178,15 +178,27 @@ int pa_client_conf_env(pa_client_conf *c) {
}
int pa_client_conf_load_cookie(pa_client_conf* c) {
- pa_assert(c);
+ int k;
- if (!c->cookie_file)
- return -1;
+ pa_assert(c);
c->cookie_valid = FALSE;
- if (pa_authkey_load_auto(c->cookie_file, c->cookie, sizeof(c->cookie)) < 0)
- return -1;
+ if (c->cookie_file)
+ k = pa_authkey_load_auto(c->cookie_file, TRUE, c->cookie, sizeof(c->cookie));
+ else {
+ k = pa_authkey_load_auto(PA_NATIVE_COOKIE_FILE, FALSE, c->cookie, sizeof(c->cookie));
+
+ if (k < 0) {
+ k = pa_authkey_load_auto(PA_NATIVE_COOKIE_FILE_FALLBACK, FALSE, c->cookie, sizeof(c->cookie));
+
+ if (k < 0)
+ k = pa_authkey_load_auto(PA_NATIVE_COOKIE_FILE, TRUE, c->cookie, sizeof(c->cookie));
+ }
+ }
+
+ if (k < 0)
+ return k;
c->cookie_valid = TRUE;
return 0;