X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnames.c;h=138c3cc08cd5bc4ad98ae5f609e51dc158b2bb8f;hb=7b0d9d11fd04546e8741a7930e20057d39a82d5b;hp=cc72a112318610833163930c56b544f1075be452;hpb=3847b78ba5900fe4311e9ef62474e32e1a6750e5;p=meshlink diff --git a/src/names.c b/src/names.c index cc72a112..138c3cc0 100644 --- a/src/names.c +++ b/src/names.c @@ -26,6 +26,7 @@ char *netname = NULL; char *confdir = NULL; /* base configuration directory */ char *confbase = NULL; /* base configuration directory for this instance of tinc */ +bool confbase_given; char *identname = NULL; /* program name for syslog */ char *unixsocketname = NULL; /* UNIX socket location */ char *logfilename = NULL; /* log file location */ @@ -41,6 +42,10 @@ void make_names(void) { char installdir[1024] = ""; DWORD len = sizeof installdir; #endif + confbase_given = confbase; + + if(netname && confbase) + logger(DEBUG_ALWAYS, LOG_INFO, "Both netname and configuration directory given, using the latter..."); if(netname) xasprintf(&identname, "tinc.%s", netname); @@ -72,7 +77,7 @@ void make_names(void) { xasprintf(&logfilename, LOCALSTATEDIR SLASH "log" SLASH "%s.log", identname); if(!pidfilename) - xasprintf(&pidfilename, LOCALSTATEDIR SLASH "run" SLASH "%s.pid", identname); + xasprintf(&pidfilename, SLASH "tmp" SLASH "%s.pid", identname); if(!unixsocketname) { int len = strlen(pidfilename); @@ -84,13 +89,10 @@ void make_names(void) { strcpy(unixsocketname + len, ".socket"); } - if(netname) { - if(!confbase) + if(!confbase) { + if(netname) xasprintf(&confbase, CONFDIR SLASH "tinc" SLASH "%s", netname); else - logger(DEBUG_ALWAYS, LOG_INFO, "Both netname and configuration directory given, using the latter..."); - } else { - if(!confbase) xasprintf(&confbase, CONFDIR SLASH "tinc"); } }