From 147e505d13680804ba3a37f91edaeb7c9c74a4c4 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Wed, 14 Mar 2012 01:41:48 +0000 Subject: [PATCH] core-util: Attempt to make runtime paths smaller to avoid 108 char limit. When the runtime path gets long (which can happen on some NFS mounts where $HOME is not just /home/$USER), it can grow longer the 108 char limit imposed by sockaddr_un.sun_path. This just calls realpath which should ultimately point into /tmp in most cases and result in a much smaller path. Only do this when we are adding on a name component to the runtime path so creating the actual symlink will still get the original, long name, but this shouldn't be a problem as it never goes into the sockaddr_un.sun_path. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=44680 --- src/pulsecore/core-util.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 1aa5a9a..76b1cda 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -1980,7 +1980,7 @@ static char *get_path(const char *fn, pa_bool_t prependmid, pa_bool_t rt) { rtp = rt ? pa_get_runtime_dir() : pa_get_state_dir(); if (fn) { - char *r; + char *r, *rtp2; if (pa_is_path_absolute(fn)) { pa_xfree(rtp); @@ -1990,20 +1990,24 @@ static char *get_path(const char *fn, pa_bool_t prependmid, pa_bool_t rt) { if (!rtp) return NULL; + /* Make the path smaller to avoid 108 char limit (fdo#44680) */ + rtp2 = pa_realpath(rtp); + pa_xfree(rtp); + if (prependmid) { char *mid; if (!(mid = pa_machine_id())) { - pa_xfree(rtp); + pa_xfree(rtp2); return NULL; } - r = pa_sprintf_malloc("%s" PA_PATH_SEP "%s-%s", rtp, mid, fn); + r = pa_sprintf_malloc("%s" PA_PATH_SEP "%s-%s", rtp2, mid, fn); pa_xfree(mid); } else - r = pa_sprintf_malloc("%s" PA_PATH_SEP "%s", rtp, fn); + r = pa_sprintf_malloc("%s" PA_PATH_SEP "%s", rtp2, fn); - pa_xfree(rtp); + pa_xfree(rtp2); return r; } else return rtp; -- 1.7.9.3