Don't try to mkdir(CONFDIR) if --config is used.
[tinc] / src / names.c
index cc72a11..37708f8 100644 (file)
@@ -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);
@@ -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");
        }
 }