projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into 1.1
[tinc]
/
src
/
tincd.c
diff --git
a/src/tincd.c
b/src/tincd.c
index
1761dc2
..
2162364
100644
(file)
--- a/
src/tincd.c
+++ b/
src/tincd.c
@@
-1,7
+1,7
@@
/*
tincd.c -- the main file for tincd
Copyright (C) 1998-2005 Ivo Timmermans
/*
tincd.c -- the main file for tincd
Copyright (C) 1998-2005 Ivo Timmermans
- 2000-20
09
Guus Sliepen <guus@tinc-vpn.org>
+ 2000-20
10
Guus Sliepen <guus@tinc-vpn.org>
2008 Max Rijevski <maksuf@gmail.com>
2009 Michael Tokarev <mjt@tls.msk.ru>
2008 Max Rijevski <maksuf@gmail.com>
2009 Michael Tokarev <mjt@tls.msk.ru>
@@
-31,7
+31,15
@@
#include <sys/mman.h>
#endif
#include <sys/mman.h>
#endif
+#include <openssl/rand.h>
+#include <openssl/rsa.h>
+#include <openssl/pem.h>
+#include <openssl/evp.h>
+#include <openssl/engine.h>
+
+#ifdef HAVE_LZO
#include LZO1X_H
#include LZO1X_H
+#endif
#ifndef HAVE_MINGW
#include <pwd.h>
#ifndef HAVE_MINGW
#include <pwd.h>
@@
-78,8
+86,8
@@
static const char *switchuser = NULL;
bool use_logfile = false;
char *identname = NULL; /* program name for syslog */
bool use_logfile = false;
char *identname = NULL; /* program name for syslog */
-char *controlsocketname = NULL; /* control socket location */
char *logfilename = NULL; /* log file location */
char *logfilename = NULL; /* log file location */
+char *controlcookiename = NULL;
char **g_argv; /* a copy of the cmdline arguments */
static int status;
char **g_argv; /* a copy of the cmdline arguments */
static int status;
@@
-96,7
+104,7
@@
static struct option const long_options[] = {
{"chroot", no_argument, NULL, 'R'},
{"user", required_argument, NULL, 'U'},
{"logfile", optional_argument, NULL, 4},
{"chroot", no_argument, NULL, 'R'},
{"user", required_argument, NULL, 'U'},
{"logfile", optional_argument, NULL, 4},
- {"control
socket
", required_argument, NULL, 5},
+ {"control
cookie
", required_argument, NULL, 5},
{NULL, 0, NULL, 0}
};
{NULL, 0, NULL, 0}
};
@@
-117,7
+125,7
@@
static void usage(bool status) {
" -n, --net=NETNAME Connect to net NETNAME.\n"
" -L, --mlock Lock tinc into main memory.\n"
" --logfile[=FILENAME] Write log entries to a logfile.\n"
" -n, --net=NETNAME Connect to net NETNAME.\n"
" -L, --mlock Lock tinc into main memory.\n"
" --logfile[=FILENAME] Write log entries to a logfile.\n"
- " --control
socket=FILENAME Open control socket at
FILENAME.\n"
+ " --control
cookie=FILENAME Write control socket cookie to
FILENAME.\n"
" --bypass-security Disables meta protocol security, for debugging.\n"
" -R, --chroot chroot to NET dir at startup.\n"
" -U, --user=USER setuid to given USER at startup.\n" " --help Display this help and exit.\n"
" --bypass-security Disables meta protocol security, for debugging.\n"
" -R, --chroot chroot to NET dir at startup.\n"
" -U, --user=USER setuid to given USER at startup.\n" " --help Display this help and exit.\n"
@@
-190,7
+198,7
@@
static bool parse_options(int argc, char **argv) {
break;
case 5: /* open control socket here */
break;
case 5: /* open control socket here */
- control
socket
name = xstrdup(optarg);
+ control
cookie
name = xstrdup(optarg);
break;
case '?':
break;
case '?':
@@
-231,6
+239,8
@@
static void make_names(void) {
else
xasprintf(&confbase, "%s", installdir);
}
else
xasprintf(&confbase, "%s", installdir);
}
+ if(!controlcookiename)
+ xasprintf(&controlcookiename, "%s/cookie", confbase);
}
RegCloseKey(key);
if(*installdir)
}
RegCloseKey(key);
if(*installdir)
@@
-238,12
+248,12
@@
static void make_names(void) {
}
#endif
}
#endif
- if(!controlsocketname)
- xasprintf(&controlsocketname, "%s/run/%s.control/socket", LOCALSTATEDIR, identname);
-
if(!logfilename)
xasprintf(&logfilename, LOCALSTATEDIR "/log/%s.log", identname);
if(!logfilename)
xasprintf(&logfilename, LOCALSTATEDIR "/log/%s.log", identname);
+ if(!controlcookiename)
+ xasprintf(&controlcookiename, LOCALSTATEDIR "/run/%s.cookie", identname);
+
if(netname) {
if(!confbase)
xasprintf(&confbase, CONFDIR "/tinc/%s", netname);
if(netname) {
if(!confbase)
xasprintf(&confbase, CONFDIR "/tinc/%s", netname);
@@
-258,7
+268,7
@@
static void make_names(void) {
static void free_names() {
if (identname) free(identname);
if (netname) free(netname);
static void free_names() {
if (identname) free(identname);
if (netname) free(netname);
- if (control
socketname) free(controlsocket
name);
+ if (control
cookiename) free(controlcookie
name);
if (logfilename) free(logfilename);
if (confbase) free(confbase);
}
if (logfilename) free(logfilename);
if (confbase) free(confbase);
}
@@
-331,7
+341,7
@@
int main(int argc, char **argv) {
if(show_version) {
printf("%s version %s (built %s %s, protocol %d)\n", PACKAGE,
VERSION, __DATE__, __TIME__, PROT_CURRENT);
if(show_version) {
printf("%s version %s (built %s %s, protocol %d)\n", PACKAGE,
VERSION, __DATE__, __TIME__, PROT_CURRENT);
- printf("Copyright (C) 1998-20
09
Ivo Timmermans, Guus Sliepen and others.\n"
+ printf("Copyright (C) 1998-20
10
Ivo Timmermans, Guus Sliepen and others.\n"
"See the AUTHORS file for a complete list.\n\n"
"tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
"and you are welcome to redistribute it under certain conditions;\n"
"See the AUTHORS file for a complete list.\n\n"
"tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
"and you are welcome to redistribute it under certain conditions;\n"
@@
-359,9
+369,6
@@
int main(int argc, char **argv) {
return 1;
}
return 1;
}
- if(!init_control())
- return 1;
-
g_argv = argv;
init_configuration(&config_tree);
g_argv = argv;
init_configuration(&config_tree);
@@
-374,10
+381,12
@@
int main(int argc, char **argv) {
if(!read_server_config())
return 1;
if(!read_server_config())
return 1;
+#ifdef HAVE_LZO
if(lzo_init() != LZO_E_OK) {
logger(LOG_ERR, "Error initializing LZO compressor!");
return 1;
}
if(lzo_init() != LZO_E_OK) {
logger(LOG_ERR, "Error initializing LZO compressor!");
return 1;
}
+#endif
#ifdef HAVE_MINGW
if(!do_detach || !init_service())
#ifdef HAVE_MINGW
if(!do_detach || !init_service())
@@
-410,6
+419,9
@@
int main2(int argc, char **argv) {
if(!setup_network())
goto end;
if(!setup_network())
goto end;
+ if(!init_control())
+ return 1;
+
/* Initiate all outgoing connections. */
try_outgoing_connections();
/* Initiate all outgoing connections. */
try_outgoing_connections();
@@
-449,9
+461,7
@@
int main2(int argc, char **argv) {
end:
logger(LOG_NOTICE, "Terminating");
end:
logger(LOG_NOTICE, "Terminating");
-#ifndef HAVE_MINGW
exit_control();
exit_control();
-#endif
crypto_exit();
crypto_exit();