projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
GitHub CI: update list of container images
[tinc]
/
src
/
tincd.c
diff --git
a/src/tincd.c
b/src/tincd.c
index
539f527
..
4c33dc0
100644
(file)
--- a/
src/tincd.c
+++ b/
src/tincd.c
@@
-56,6
+56,8
@@
#include "version.h"
#include "random.h"
#include "sandbox.h"
#include "version.h"
#include "random.h"
#include "sandbox.h"
+#include "watchdog.h"
+#include "fs.h"
/* If nonzero, display usage information and exit. */
static bool show_help = false;
/* If nonzero, display usage information and exit. */
static bool show_help = false;
@@
-185,6
+187,7
@@
static bool parse_options(int argc, char **argv) {
goto exit_fail;
case OPT_CONFIG_FILE:
goto exit_fail;
case OPT_CONFIG_FILE:
+ assert(optarg);
free(confbase);
confbase = get_path_arg(optarg);
break;
free(confbase);
confbase = get_path_arg(optarg);
break;
@@
-216,6
+219,7
@@
static bool parse_options(int argc, char **argv) {
break;
case OPT_NETNAME:
break;
case OPT_NETNAME:
+ assert(optarg);
free(netname);
netname = xstrdup(optarg);
break;
free(netname);
netname = xstrdup(optarg);
break;
@@
-280,6
+284,7
@@
static bool parse_options(int argc, char **argv) {
break;
case OPT_PIDFILE:
break;
case OPT_PIDFILE:
+ assert(optarg);
free(pidfilename);
pidfilename = get_path_arg(optarg);
break;
free(pidfilename);
pidfilename = get_path_arg(optarg);
break;
@@
-411,7
+416,9
@@
static bool drop_privs(void) {
return false;
}
return false;
}
-#endif
+#endif // HAVE_WINDOWS
+
+ makedirs(DIR_CACHE | DIR_HOSTS | DIR_INVITATIONS);
return sandbox_enter();
}
return sandbox_enter();
}
@@
-496,6
+503,9
@@
int main(int argc, char **argv) {
#endif
#ifdef ENABLE_VDE
" vde"
#endif
#ifdef ENABLE_VDE
" vde"
+#endif
+#ifdef HAVE_WATCHDOG
+ " watchdog"
#endif
"\n\n"
"Copyright (C) 1998-2021 Ivo Timmermans, Guus Sliepen and others.\n"
#endif
"\n\n"
"Copyright (C) 1998-2021 Ivo Timmermans, Guus Sliepen and others.\n"
@@
-556,7
+566,9
@@
int main(int argc, char **argv) {
g_argv = argv;
g_argv = argv;
- if(getenv("LISTEN_PID") && atoi(getenv("LISTEN_PID")) == getpid()) {
+ const char *listen_pid = getenv("LISTEN_PID");
+
+ if(listen_pid && atoi(listen_pid) == getpid()) {
do_detach = false;
}
do_detach = false;
}
@@
-691,8
+703,16
@@
int main2(int argc, char **argv) {
try_outgoing_connections();
try_outgoing_connections();
+#ifdef HAVE_WATCHDOG
+ watchdog_start();
+#endif
+
status = main_loop();
status = main_loop();
+#ifdef HAVE_WATCHDOG
+ watchdog_stop();
+#endif
+
/* Shutdown properly. */
end:
/* Shutdown properly. */
end: