pulse-server: support absolute unix socket paths

If a unix socket address starts with '/', use it
directly as an absolute path, do not prepend
the runtime directory.
This commit is contained in:
Barnabás Pőcze 2021-05-31 17:22:57 +02:00
parent 70c6e6ccc8
commit ebed44db79
2 changed files with 15 additions and 7 deletions

View file

@ -33,6 +33,7 @@ context.modules = [
# the addresses this server listens on
server.address = [
"unix:native"
# "unix:/tmp/something" # absolute paths may be used
# "tcp:4713" # IPv4 and IPv6 on all addresses
# "tcp:[::]:9999" # IPv6 on all addresses
# "tcp:127.0.0.1:8888" # IPv4 on a single address

View file

@ -5871,21 +5871,28 @@ get_server_name(struct pw_context *context)
static int parse_unix_address(const char *address, struct pw_array *addrs)
{
struct sockaddr_un addr = {0}, *s;
char runtime_dir[PATH_MAX];
int res;
if ((res = get_runtime_dir(runtime_dir, sizeof(runtime_dir), "pulse")) < 0)
return res;
if (address[0] != '/') {
char runtime_dir[PATH_MAX];
res = snprintf(addr.sun_path, sizeof(addr.sun_path),
"%s/%s", runtime_dir, address);
if ((res = get_runtime_dir(runtime_dir, sizeof(runtime_dir), "pulse")) < 0)
return res;
res = snprintf(addr.sun_path, sizeof(addr.sun_path),
"%s/%s", runtime_dir, address);
}
else {
res = snprintf(addr.sun_path, sizeof(addr.sun_path),
"%s", address);
}
if (res < 0)
return -EINVAL;
if ((size_t) res >= sizeof(addr.sun_path)) {
pw_log_error(NAME": '%s/%s' too long",
runtime_dir, address);
pw_log_warn(NAME": '%s...' too long",
addr.sun_path);
return -ENAMETOOLONG;
}