Better default paths for log and PID files on Windows.
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 27 Dec 2014 08:08:34 +0000 (09:08 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Sat, 27 Dec 2014 08:08:34 +0000 (09:08 +0100)
src/names.c

index 37708f8..8218216 100644 (file)
@@ -64,8 +64,6 @@ void make_names(void) {
                                else
                                        xasprintf(&confbase, "%s", installdir);
                        }
                                else
                                        xasprintf(&confbase, "%s", installdir);
                        }
-                       if(!pidfilename)
-                               xasprintf(&pidfilename, "%s" SLASH "pid", confbase);
                }
                RegCloseKey(key);
        }
                }
                RegCloseKey(key);
        }
@@ -73,11 +71,26 @@ void make_names(void) {
        if(!confdir)
                confdir = xstrdup(CONFDIR SLASH "tinc");
 
        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);
        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);
 
        if(!unixsocketname) {
                int len = strlen(pidfilename);
@@ -88,13 +101,6 @@ void make_names(void) {
                else
                        strcpy(unixsocketname + len, ".socket");
        }
                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) {
 }
 
 void free_names(void) {