X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fnames.c;h=8218216ece0aacd1a504f02932380140bd8c92ff;hb=176ee015267d87ff4fd4d2615e9f5ac978116171;hp=a631ad97e7fcde60c0216e66d7324bf55952db72;hpb=918067f117d5b9983a8f2273fd81983362a2ff88;p=tinc diff --git a/src/names.c b/src/names.c index a631ad97..8218216e 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,7 @@ 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..."); @@ -62,8 +64,6 @@ void make_names(void) { else xasprintf(&confbase, "%s", installdir); } - if(!pidfilename) - xasprintf(&pidfilename, "%s" SLASH "pid", confbase); } RegCloseKey(key); } @@ -71,11 +71,26 @@ void make_names(void) { if(!confdir) confdir = xstrdup(CONFDIR SLASH "tinc"); + if(!confbase) { + if(netname) + xasprintf(&confbase, CONFDIR SLASH "tinc" SLASH "%s", netname); + else + xasprintf(&confbase, CONFDIR SLASH "tinc"); + } + +#ifdef HAVE_MINGW + if(!logfilename) + xasprintf(&logfilename, "%s" SLASH "log", confbase); + + if(!pidfilename) + xasprintf(&pidfilename, "%s" SLASH "pid", confbase); +#else if(!logfilename) xasprintf(&logfilename, LOCALSTATEDIR SLASH "log" SLASH "%s.log", identname); if(!pidfilename) xasprintf(&pidfilename, LOCALSTATEDIR SLASH "run" SLASH "%s.pid", identname); +#endif if(!unixsocketname) { int len = strlen(pidfilename); @@ -86,13 +101,6 @@ void make_names(void) { else strcpy(unixsocketname + len, ".socket"); } - - if(!confbase) { - if(netname) - xasprintf(&confbase, CONFDIR SLASH "tinc" SLASH "%s", netname); - else - xasprintf(&confbase, CONFDIR SLASH "tinc"); - } } void free_names(void) {