buffer.c conf.c connection.c control.c edge.c graph.c logger.c meta.c net.c net_packet.c net_setup.c \
net_socket.c netutl.c node.c process.c protocol.c protocol_auth.c protocol_edge.c protocol_misc.c \
protocol_key.c protocol_subnet.c route.c sptps.c subnet.c subnet_parse.c event.c tincd.c \
- dummy_device.c raw_socket_device.c multicast_device.c
+ dummy_device.c raw_socket_device.c multicast_device.c names.c
if UML
tincd_SOURCES += uml_device.c
tincctl_SOURCES = \
utils.c getopt.c getopt1.c dropin.c \
- info.c list.c subnet_parse.c tincctl.c top.c
+ info.c list.c subnet_parse.c tincctl.c top.c names.c
nodist_tincctl_SOURCES = \
ecdsagen.c rsagen.c
#include "conf.h"
#include "device.h"
#include "logger.h"
+#include "names.h"
#include "net.h"
#include "route.h"
#include "utils.h"
#include "conf.h"
#include "list.h"
#include "logger.h"
+#include "names.h"
#include "netutl.h" /* for str2address */
#include "protocol.h"
#include "utils.h" /* for cp */
int pinginterval = 0; /* seconds between pings */
int pingtimeout = 0; /* seconds to wait for response */
-char *confbase = NULL; /* directory in which all config files are */
-char *netname = NULL; /* name of the vpn network */
list_t *cmdline_conf = NULL; /* global/host configuration values given at the command line */
-
static int config_compare(const config_t *a, const config_t *b) {
int result;
extern int pingtimeout;
extern int maxtimeout;
extern bool bypass_security;
-extern char *confbase;
-extern char *netname;
extern list_t *cmdline_conf;
extern void init_configuration(splay_tree_t **);
#include "graph.h"
#include "logger.h"
#include "meta.h"
+#include "names.h"
#include "net.h"
#include "netutl.h"
#include "protocol.h"
#include "xalloc.h"
char controlcookie[65];
-extern char *pidfilename;
static bool control_return(connection_t *c, int type, int error) {
return send_request(c, "%d %d %d", CONTROL, type, error);
#include "conf.h"
#include "device.h"
#include "logger.h"
+#include "names.h"
#include "net.h"
#include "route.h"
#include "utils.h"
#include "graph.h"
#include "list.h"
#include "logger.h"
+#include "names.h"
#include "netutl.h"
#include "node.h"
#include "process.h"
#include "conf.h"
#include "device.h"
#include "logger.h"
+#include "names.h"
#include "net.h"
#include "route.h"
#include "utils.h"
#include "conf.h"
#include "meta.h"
+#include "names.h"
#include "logger.h"
#include "connection.h"
#include "control_common.h"
debug_t debug_level = DEBUG_NOTHING;
static logmode_t logmode = LOGMODE_STDERR;
static pid_t logpid;
-extern char *logfilename;
static FILE *logfile = NULL;
#ifdef HAVE_MINGW
static HANDLE loghandle = NULL;
#include "conf.h"
#include "device.h"
#include "logger.h"
+#include "names.h"
#include "net.h"
#include "route.h"
#include "utils.h"
--- /dev/null
+/*
+ names.c -- generate commonly used (file)names
+ Copyright (C) 1998-2005 Ivo Timmermans
+ 2000-2013 Guus Sliepen <guus@tinc-vpn.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include "system.h"
+
+#include "logger.h"
+#include "xalloc.h"
+
+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 *logfilename = NULL; /* log file location */
+char *pidfilename = NULL;
+char *program_name = NULL;
+
+/*
+ Set all files and paths according to netname
+*/
+void make_names(void) {
+#ifdef HAVE_MINGW
+ HKEY key;
+ char installdir[1024] = "";
+ long len = sizeof installdir;
+#endif
+
+ if(netname)
+ xasprintf(&identname, "tinc.%s", netname);
+ else
+ identname = xstrdup("tinc");
+
+#ifdef HAVE_MINGW
+ if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\tinc", 0, KEY_READ, &key)) {
+ if(!RegQueryValueEx(key, NULL, 0, 0, installdir, &len)) {
+ confdir = xstrdup(installdir);
+ if(!logfilename)
+ xasprintf(&logfilename, "%s" SLASH "log" SLASH "%s.log", installdir, identname);
+ if(!confbase) {
+ if(netname)
+ xasprintf(&confbase, "%s" SLASH "%s", installdir, netname);
+ else
+ xasprintf(&confbase, "%s", installdir);
+ }
+ if(!pidfilename)
+ xasprintf(&pidfilename, "%s" SLASH "pid", confbase);
+ }
+ RegCloseKey(key);
+ }
+#endif
+ if(!confdir)
+ confdir = xstrdup(CONFDIR);
+
+ if(!logfilename)
+ xasprintf(&logfilename, LOCALSTATEDIR SLASH "log" SLASH "%s.log", identname);
+
+ if(!pidfilename)
+ xasprintf(&pidfilename, LOCALSTATEDIR SLASH "run" SLASH "%s.pid", identname);
+
+ if(netname) {
+ if(!confbase)
+ 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");
+ }
+}
+
+void free_names(void) {
+ free(identname);
+ free(netname);
+ free(pidfilename);
+ free(logfilename);
+ free(confbase);
+ free(confdir);
+}
--- /dev/null
+/*
+ names.h -- header for names.c
+ Copyright (C) 1998-2005 Ivo Timmermans
+ 2000-2013 Guus Sliepen <guus@tinc-vpn.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#ifndef __TINC_NAMES_H__
+#define __TINC_NAMES_H__
+
+extern char *confdir;
+extern char *confbase;
+extern char *netname;
+extern char *identname;
+extern char *logfilename;
+extern char *pidfilename;
+extern char *program_name;
+
+extern void make_names(void);
+extern void free_names(void);
+
+#endif /* __TINC_NAMES_H__ */
#include "graph.h"
#include "logger.h"
#include "meta.h"
+#include "names.h"
#include "net.h"
#include "netutl.h"
#include "process.h"
#include "ecdsa.h"
#include "graph.h"
#include "logger.h"
+#include "names.h"
#include "net.h"
#include "netutl.h"
#include "process.h"
#include "list.h"
#include "logger.h"
#include "meta.h"
+#include "names.h"
#include "net.h"
#include "netutl.h"
#include "protocol.h"
#include "edge.h"
#include "event.h"
#include "logger.h"
+#include "names.h"
#include "net.h"
#include "node.h"
#include "process.h"
bool do_detach = true;
bool sigalrm = false;
-extern char *identname;
extern char **g_argv;
extern bool use_logfile;
/* Some functions the less gifted operating systems might lack... */
#ifdef HAVE_MINGW
-extern char *identname;
-extern char *program_name;
-extern char **g_argv;
-
static SC_HANDLE manager = NULL;
static SC_HANDLE service = NULL;
static SERVICE_STATUS status = {0};
#include "conf.h"
#include "device.h"
#include "logger.h"
+#include "names.h"
#include "net.h"
#include "utils.h"
#include "xalloc.h"
#include "device.h"
#include "hash.h"
#include "logger.h"
+#include "names.h"
#include "net.h"
#include "netutl.h"
#include "node.h"
#include "control_common.h"
#include "ecdsagen.h"
#include "info.h"
+#include "names.h"
#include "rsagen.h"
#include "utils.h"
#include "tincctl.h"
#define mkdir(a, b) mkdir(a)
#endif
-
-/* The name this program was run with. */
-static char *program_name = NULL;
-
static char **orig_argv;
static int orig_argc;
static bool show_version = false;
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[1025];
-char *netname = NULL;
-char *confbase = NULL;
static char *tinc_conf = NULL;
static char *hosts_dir = NULL;
struct timeval now;
}
static void usage(bool status) {
- if(status)
- fprintf(stderr, "Try `%s --help\' for more information.\n",
- program_name);
- else {
+ if(status) {
+ fprintf(stderr, "Try `%s --help\' for more information.\n", program_name);
+ } else {
printf("Usage: %s [options] command\n\n", program_name);
printf("Valid options are:\n"
" -c, --config=DIR Read configuration options from DIR.\n"
return true;
}
-/*
- Set all files and paths according to netname
-*/
-static void make_names(void) {
-#ifdef HAVE_MINGW
- HKEY key;
- char installdir[1024] = "";
- long len = sizeof installdir;
-#endif
-
- if(netname)
- xasprintf(&identname, "tinc.%s", netname);
- else
- identname = xstrdup("tinc");
-
-#ifdef HAVE_MINGW
- if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\tinc", 0, KEY_READ, &key)) {
- if(!RegQueryValueEx(key, NULL, 0, 0, installdir, &len)) {
- if(!confbase) {
- if(netname)
- xasprintf(&confbase, "%s" SLASH "%s", installdir, netname);
- else
- xasprintf(&confbase, "%s", installdir);
- }
- }
- if(!pidfilename)
- xasprintf(&pidfilename, "%s" SLASH "pid", confbase);
- RegCloseKey(key);
- }
-
- if(!*installdir) {
-#endif
- confdir = xstrdup(CONFDIR);
-
- if(!pidfilename)
- xasprintf(&pidfilename, "%s" SLASH "run" SLASH "%s.pid", LOCALSTATEDIR, identname);
-
- if(netname) {
- if(!confbase)
- xasprintf(&confbase, CONFDIR SLASH "tinc" SLASH "%s", netname);
- else
- fprintf(stderr, "Both netname and configuration directory given, using the latter...\n");
- } else {
- if(!confbase)
- xasprintf(&confbase, CONFDIR SLASH "tinc");
- }
-
-#ifdef HAVE_MINGW
- } else
- confdir = xstrdup(installdir);
-#endif
-
- xasprintf(&tinc_conf, "%s" SLASH "tinc.conf", confbase);
- xasprintf(&hosts_dir, "%s" SLASH "hosts", confbase);
-}
-
static char buffer[4096];
static size_t blen = 0;
return 1;
make_names();
+ xasprintf(&tinc_conf, "%s" SLASH "tinc.conf", confbase);
+ xasprintf(&hosts_dir, "%s" SLASH "hosts", confbase);
if(show_version) {
version();
#include "crypto.h"
#include "device.h"
#include "logger.h"
+#include "names.h"
#include "net.h"
#include "netutl.h"
#include "process.h"
#include "utils.h"
#include "xalloc.h"
-/* The name this program was run with. */
-char *program_name = NULL;
-
/* If nonzero, display usage information and exit. */
static bool show_help = false;
/* If nonzero, write log entries to a separate file. */
bool use_logfile = false;
-char *identname = NULL; /* program name for syslog */
-char *logfilename = NULL; /* log file location */
-char *pidfilename = NULL;
char **g_argv; /* a copy of the cmdline arguments */
static int status = 1;
return true;
}
-/*
- Set all files and paths according to netname
-*/
-static void make_names(void) {
-#ifdef HAVE_MINGW
- HKEY key;
- char installdir[1024] = "";
- long len = sizeof installdir;
-#endif
-
- if(netname)
- xasprintf(&identname, "tinc.%s", netname);
- else
- identname = xstrdup("tinc");
-
-#ifdef HAVE_MINGW
- if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\tinc", 0, KEY_READ, &key)) {
- if(!RegQueryValueEx(key, NULL, 0, 0, installdir, &len)) {
- if(!logfilename)
- xasprintf(&logfilename, "%s" SLASH "log" SLASH "%s.log", identname);
- if(!confbase) {
- if(netname)
- xasprintf(&confbase, "%s" SLASH "%s", installdir, netname);
- else
- xasprintf(&confbase, "%s", installdir);
- }
- if(!pidfilename)
- xasprintf(&pidfilename, "%s" SLASH "pid", confbase);
- }
- RegCloseKey(key);
- if(*installdir)
- return;
- }
-#endif
-
- if(!logfilename)
- xasprintf(&logfilename, LOCALSTATEDIR SLASH "log" SLASH "%s.log", identname);
-
- if(!pidfilename)
- xasprintf(&pidfilename, LOCALSTATEDIR SLASH "run" SLASH "%s.pid", identname);
-
- if(netname) {
- if(!confbase)
- 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");
- }
-}
-
-static void free_names(void) {
- if (identname) free(identname);
- if (netname) free(netname);
- if (pidfilename) free(pidfilename);
- if (logfilename) free(logfilename);
- if (confbase) free(confbase);
-}
-
static bool drop_privs(void) {
#ifdef HAVE_MINGW
return false;
#include "control_common.h"
#include "list.h"
+#include "names.h"
#include "tincctl.h"
#include "top.h"
#include "xalloc.h"
#include "conf.h"
#include "device.h"
+#include "names.h"
#include "net.h"
#include "logger.h"
#include "utils.h"
static int state = 0;
static char *device_info;
-extern char *identname;
extern volatile bool running;
static uint64_t device_total_in = 0;
#include "conf.h"
#include "device.h"
+#include "names.h"
#include "net.h"
#include "logger.h"
#include "utils.h"
static char *group = NULL;
static char *device_info;
-extern char *identname;
extern volatile bool running;
static uint64_t device_total_in = 0;