From: Guus Sliepen Date: Thu, 7 Feb 2013 14:26:56 +0000 (+0100) Subject: Derive UNIX socket filename from PID filename. X-Git-Tag: release-1.1pre6~6 X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=a8b52becbbd86a52dc50a6a1b725a80737f2c760;p=tinc Derive UNIX socket filename from PID filename. --- 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)