Don't try to mkdir(CONFDIR) if --config is used.
authorGuus Sliepen <guus@tinc-vpn.org>
Sun, 8 Sep 2013 13:03:06 +0000 (15:03 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Sun, 8 Sep 2013 13:03:06 +0000 (15:03 +0200)
src/invitation.c
src/names.c
src/names.h
src/tincctl.c

index 6ccfc1f4cf8e7499bbf2e407174074d698c23aa3..59bcf456ec63075e1f45595af86761cf4a05d7d4 100644 (file)
@@ -823,7 +823,7 @@ int cmd_join(int argc, char *argv[]) {
        }
 
        // Make sure confbase exists and is accessible.
-       if(strcmp(confdir, confbase) && mkdir(confdir, 0755) && errno != EEXIST) {
+       if(!confbase_given && mkdir(confdir, 0755) && errno != EEXIST) {
                fprintf(stderr, "Could not create directory %s: %s\n", confdir, strerror(errno));
                return 1;
        }
index a631ad97e7fcde60c0216e66d7324bf55952db72..37708f81169cc77d4c093cbee10c04c44b8b8d4f 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,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...");
index 6f43a2c885aaa48fce397ede409dfb87b022acab..1163ff6efd22d5a834508efe97e1ef03d1f223e0 100644 (file)
@@ -23,6 +23,7 @@
 
 extern char *confdir;
 extern char *confbase;
+extern bool confbase_given;
 extern char *netname;
 extern char *identname;
 extern char *unixsocketname;
index a6673901c89c1552bc559117faa79b7dec5508e0..a986af7633e69d9e7cf28b3d6956e9841e1335bd 100644 (file)
@@ -1739,7 +1739,7 @@ static int cmd_init(int argc, char *argv[]) {
                return 1;
        }
 
-       if(strcmp(confdir, confbase) && mkdir(confdir, 0755) && errno != EEXIST) {
+       if(!confbase_given && mkdir(confdir, 0755) && errno != EEXIST) {
                fprintf(stderr, "Could not create directory %s: %s\n", confdir, strerror(errno));
                return 1;
        }