X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftincd.c;h=9d2b03b2758c78d59dc2ec0e50390a77cd557cb0;hb=c64f64b875879591873d68faf2d3cd8e9d644101;hp=25db1552d43e2f9c2bf3ff0672a0951208973eca;hpb=d772289f6d6adfb8932658b533349d43f08ec326;p=tinc diff --git a/src/tincd.c b/src/tincd.c index 25db1552..9d2b03b2 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -64,7 +64,7 @@ #include "xalloc.h" /* The name this program was run with. */ -static char *program_name = NULL; +char *program_name = NULL; /* If nonzero, display usage information and exit. */ static bool show_help = false; @@ -92,7 +92,7 @@ char *logfilename = NULL; /* log file location */ char *controlcookiename = NULL; char **g_argv; /* a copy of the cmdline arguments */ -static int status; +static int status = 1; static struct option const long_options[] = { {"config", required_argument, NULL, 'c'}, @@ -282,7 +282,7 @@ static void make_names(void) { } } -static void free_names() { +static void free_names(void) { if (identname) free(identname); if (netname) free(netname); if (controlcookiename) free(controlcookiename); @@ -290,7 +290,7 @@ static void free_names() { if (confbase) free(confbase); } -static bool drop_privs() { +static bool drop_privs(void) { #ifdef HAVE_MINGW if (switchuser) { logger(LOG_ERR, "%s not supported on this platform", "-U"); @@ -339,7 +339,7 @@ static bool drop_privs() { } #ifdef HAVE_MINGW -# define setpriority(level) SetPriorityClass(GetCurrentProcess(), (level)) +# define setpriority(level) !SetPriorityClass(GetCurrentProcess(), (level)) #else # define NORMAL_PRIORITY_CLASS 0 # define BELOW_NORMAL_PRIORITY_CLASS 10 @@ -434,10 +434,10 @@ int main2(int argc, char **argv) { /* Setup sockets and open device. */ if(!setup_network()) - goto end; + goto end_nonet; if(!init_control()) - return 1; + goto end_nonet; /* Initiate all outgoing connections. */ @@ -445,7 +445,7 @@ int main2(int argc, char **argv) { /* Change process priority */ - char *priority = 0; + char *priority = NULL; if(get_config_string(lookup_config(config_tree, "ProcessPriority"), &priority)) { if(!strcasecmp(priority, "Normal")) { @@ -488,10 +488,11 @@ int main2(int argc, char **argv) { close_network_connections(); end: - logger(LOG_NOTICE, "Terminating"); - exit_control(); +end_nonet: + logger(LOG_NOTICE, "Terminating"); + crypto_exit(); exit_configuration(&config_tree);