From a8b52becbbd86a52dc50a6a1b725a80737f2c760 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Thu, 7 Feb 2013 15:26:56 +0100 Subject: [PATCH] Derive UNIX socket filename from PID filename. --- src/names.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/names.c b/src/names.c index c42b9534..688e96d3 100644 --- a/src/names.c +++ b/src/names.c @@ -74,8 +74,15 @@ void make_names(void) { if(!pidfilename) xasprintf(&pidfilename, LOCALSTATEDIR SLASH "run" SLASH "%s.pid", identname); - if(!unixsocketname) - xasprintf(&unixsocketname, LOCALSTATEDIR SLASH "run" SLASH "%s.socket", identname); + if(!unixsocketname) { + int len = strlen(pidfilename); + unixsocketname = xmalloc(len + 8); + strcpy(unixsocketname, pidfilename); + if(len > 4 && !strcmp(pidfilename + len - 4, ".pid")) + strcpy(unixsocketname + len - 4, ".socket"); + else + strcpy(unixsocketname + len, ".socket"); + } if(netname) { if(!confbase) -- 2.39.5