X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnames.c;h=688e96d35b31f216b534af7f8eb72d3da9dae779;hb=a8b52becbbd86a52dc50a6a1b725a80737f2c760;hp=5a5270a9d7761d16aedd73219f1cd073c8253c13;hpb=f5bb64b36ae0807cdd3f241f81a8e933065437f6;p=tinc diff --git a/src/names.c b/src/names.c index 5a5270a9..688e96d3 100644 --- a/src/names.c +++ b/src/names.c @@ -27,6 +27,7 @@ char *netname = NULL; char *confdir = NULL; /* base configuration directory */ char *confbase = NULL; /* base configuration directory for this instance of tinc */ char *identname = NULL; /* program name for syslog */ +char *unixsocketname = NULL; /* UNIX socket location */ char *logfilename = NULL; /* log file location */ char *pidfilename = NULL; char *program_name = NULL; @@ -65,7 +66,7 @@ void make_names(void) { } #endif if(!confdir) - confdir = xstrdup(CONFDIR); + confdir = xstrdup(CONFDIR SLASH "tinc"); if(!logfilename) xasprintf(&logfilename, LOCALSTATEDIR SLASH "log" SLASH "%s.log", identname); @@ -73,6 +74,16 @@ void make_names(void) { if(!pidfilename) xasprintf(&pidfilename, LOCALSTATEDIR SLASH "run" SLASH "%s.pid", 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) xasprintf(&confbase, CONFDIR SLASH "tinc" SLASH "%s", netname); @@ -87,6 +98,7 @@ void make_names(void) { void free_names(void) { free(identname); free(netname); + free(unixsocketname); free(pidfilename); free(logfilename); free(confbase);