Fix tincctl init when /etc/tinc does not yet exist.
[tinc] / src / names.c
index 5a5270a..c42b953 100644 (file)
@@ -27,6 +27,7 @@ char *netname = NULL;
 char *confdir = NULL;           /* base configuration directory */
 char *confbase = NULL;          /* base configuration directory for this instance of tinc */
 char *identname = NULL;         /* program name for syslog */
+char *unixsocketname = NULL;    /* UNIX socket location */
 char *logfilename = NULL;       /* log file location */
 char *pidfilename = NULL;
 char *program_name = NULL;
@@ -65,7 +66,7 @@ void make_names(void) {
        }
 #endif
        if(!confdir)
-               confdir = xstrdup(CONFDIR);
+               confdir = xstrdup(CONFDIR SLASH "tinc");
 
        if(!logfilename)
                xasprintf(&logfilename, LOCALSTATEDIR SLASH "log" SLASH "%s.log", identname);
@@ -73,6 +74,9 @@ void make_names(void) {
        if(!pidfilename)
                xasprintf(&pidfilename, LOCALSTATEDIR SLASH "run" SLASH "%s.pid", identname);
 
+       if(!unixsocketname)
+               xasprintf(&unixsocketname, LOCALSTATEDIR SLASH "run" SLASH "%s.socket", identname);
+
        if(netname) {
                if(!confbase)
                        xasprintf(&confbase, CONFDIR SLASH "tinc" SLASH "%s", netname);
@@ -87,6 +91,7 @@ void make_names(void) {
 void free_names(void) {
        free(identname);
        free(netname);
+       free(unixsocketname);
        free(pidfilename);
        free(logfilename);
        free(confbase);