X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftincd.c;h=9d2b03b2758c78d59dc2ec0e50390a77cd557cb0;hb=c64f64b875879591873d68faf2d3cd8e9d644101;hp=c4750da20c0c8b6991285a4ceeb25cea4778dd29;hpb=886a6f61a1f4cc48a77b42d10f34f9126377d904;p=tinc diff --git a/src/tincd.c b/src/tincd.c index c4750da2..9d2b03b2 100644 --- 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 - 2000-2010 Guus Sliepen + 2000-2011 Guus Sliepen 2008 Max Rijevski 2009 Michael Tokarev 2010 Julien Muchembled @@ -67,16 +67,16 @@ char *program_name = NULL; /* If nonzero, display usage information and exit. */ -bool show_help = false; +static bool show_help = false; /* If nonzero, print the version on standard output and exit. */ -bool show_version = false; +static bool show_version = false; /* If nonzero, use null ciphers and skip all key exchanges. */ bool bypass_security = false; /* If nonzero, disable swapping for this process. */ -bool do_mlock = false; +static bool do_mlock = false; /* If nonzero, chroot to netdir after startup. */ static bool do_chroot = 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,12 +339,12 @@ 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 # define HIGH_PRIORITY_CLASS -10 -# define setpriority(level) nice(level) +# define setpriority(level) (setpriority(PRIO_PROCESS, 0, (level))) #endif int main(int argc, char **argv) { @@ -358,7 +358,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); - printf("Copyright (C) 1998-2010 Ivo Timmermans, Guus Sliepen and others.\n" + printf("Copyright (C) 1998-2011 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" @@ -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);