static char *name = NULL;
static char *identname = NULL; /* program name for syslog */
static char *pidfilename = NULL; /* pid file location */
+static char *confdir = NULL;
static char controlcookie[1024];
char *netname = NULL;
char *confbase = NULL;
/* netname "." is special: a "top-level name" */
- if(!strcmp(netname, ".")) {
+ if(netname && !strcmp(netname, ".")) {
free(netname);
netname = NULL;
}
if(!*installdir) {
#endif
+ confdir = xstrdup(CONFDIR);
if(!pidfilename)
xasprintf(&pidfilename, "%s/run/%s.pid", LOCALSTATEDIR, identname);
}
#ifdef HAVE_MINGW
- }
+ } else
+ confdir = xstrdup(installdir);
#endif
xasprintf(&tinc_conf, "%s/tinc.conf", confbase);
while(fgets(buf1, sizeof buf1, f)) {
buf1[sizeof buf1 - 1] = 0;
- strcpy(buf2, buf1);
+ strncpy(buf2, buf1, sizeof buf2);
// Parse line in a simple way
char *bvalue;
return 1;
}
- if(mkdir(CONFDIR, 0755) && errno != EEXIST) {
+ if(mkdir(confdir, 0755) && errno != EEXIST) {
fprintf(stderr, "Could not create directory %s: %s\n", CONFDIR, strerror(errno));
return 1;
}