From 40ff5fa06f4c9749e4bee9a8c2b18fe50e1210ab Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 7 Aug 2008 02:39:58 +0200 Subject: [PATCH] add compatibility with older PA socket paths --- src/pulse/context.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/pulse/context.c b/src/pulse/context.c index 5be4078..bdd519a 100644 --- a/src/pulse/context.c +++ b/src/pulse/context.c @@ -776,7 +776,7 @@ finish: } -static char *get_legacy_runtime_dir(void) { +static char *get_old_legacy_runtime_dir(void) { char *p, u[128]; struct stat st; @@ -798,6 +798,28 @@ static char *get_legacy_runtime_dir(void) { return p; } +static char *get_very_old_legacy_runtime_dir(void) { + char *p, h[128]; + struct stat st; + + if (!pa_get_home_dir(h, sizeof(h))) + return NULL; + + p = pa_sprintf_malloc("%s/.pulse", h); + + if (stat(p, &st) < 0) { + pa_xfree(p); + return NULL; + } + + if (st.st_uid != getuid()) { + pa_xfree(p); + return NULL; + } + + return p; +} + int pa_context_connect( pa_context *c, const char *server, @@ -849,8 +871,16 @@ int pa_context_connect( /* The system wide instance */ c->server_list = pa_strlist_prepend(c->server_list, PA_SYSTEM_RUNTIME_PATH PA_PATH_SEP PA_NATIVE_DEFAULT_UNIX_SOCKET); - /* The old per-user instance path. This is supported only to ease upgrades */ - if ((legacy_dir = get_legacy_runtime_dir())) { + /* The very old per-user instance path (< 0.9.11). This is supported only to ease upgrades */ + if ((legacy_dir = get_very_old_legacy_runtime_dir())) { + char *p = pa_sprintf_malloc("%s" PA_PATH_SEP PA_NATIVE_DEFAULT_UNIX_SOCKET, legacy_dir); + c->server_list = pa_strlist_prepend(c->server_list, p); + pa_xfree(p); + pa_xfree(legacy_dir); + } + + /* The old per-user instance path (< 0.9.12). This is supported only to ease upgrades */ + if ((legacy_dir = get_old_legacy_runtime_dir())) { char *p = pa_sprintf_malloc("%s" PA_PATH_SEP PA_NATIVE_DEFAULT_UNIX_SOCKET, legacy_dir); c->server_list = pa_strlist_prepend(c->server_list, p); pa_xfree(p); -- 2.7.4