=== modified file 'plugins.d/mandos-client.c' --- plugins.d/mandos-client.c 2009-02-09 19:26:19 +0000 +++ plugins.d/mandos-client.c 2009-02-09 19:33:46 +0000 @@ -134,7 +134,9 @@ } mandos_context; /* global context so signal handler can reach it*/ -mandos_context mc; +mandos_context mc = { .simple_poll = NULL, .server = NULL, + .dh_bits = 1024, .priority = "SECURE256" + ":!CTYPE-X.509:+CTYPE-OPENPGP" }; /* * Make additional room in "buffer" for at least BUFFER_SIZE more @@ -874,6 +876,7 @@ sig_atomic_t quit_now = 0; +/* stop main loop after sigterm has been called */ static void handle_sigterm(__attribute__((unused)) int sig){ if(quit_now){ return; @@ -1012,6 +1015,47 @@ } } + if(not debug){ + avahi_set_log_function(empty_log); + } + + /* Initialize Avahi early so avahi_simple_poll_quit() can be called + from the signal handler */ + /* Initialize the pseudo-RNG for Avahi */ + srand((unsigned int) time(NULL)); + mc.simple_poll = avahi_simple_poll_new(); + if(mc.simple_poll == NULL){ + fprintf(stderr, "Avahi: Failed to create simple poll object.\n"); + exitcode = EXIT_FAILURE; + goto end; + } + + sigemptyset(&sigterm_action.sa_mask); + ret = sigaddset(&sigterm_action.sa_mask, SIGINT); + if(ret == -1){ + perror("sigaddset"); + exitcode = EXIT_FAILURE; + goto end; + } + ret = sigaddset(&sigterm_action.sa_mask, SIGHUP); + if(ret == -1){ + perror("sigaddset"); + exitcode = EXIT_FAILURE; + goto end; + } + ret = sigaddset(&sigterm_action.sa_mask, SIGTERM); + if(ret == -1){ + perror("sigaddset"); + exitcode = EXIT_FAILURE; + goto end; + } + ret = sigaction(SIGTERM, &sigterm_action, &old_sigterm_action); + if(ret == -1){ + perror("sigaction"); + exitcode = EXIT_FAILURE; + goto end; + } + /* If the interface is down, bring it up */ if(interface[0] != '\0'){ #ifdef __linux__ @@ -1181,22 +1225,7 @@ } goto end; } - - if(not debug){ - avahi_set_log_function(empty_log); - } - - /* Initialize the pseudo-RNG for Avahi */ - srand((unsigned int) time(NULL)); - - /* Allocate main Avahi loop object */ - mc.simple_poll = avahi_simple_poll_new(); - if(mc.simple_poll == NULL){ - fprintf(stderr, "Avahi: Failed to create simple poll object.\n"); - exitcode = EXIT_FAILURE; - goto end; - } - + { AvahiServerConfig config; /* Do not publish any local Zeroconf records */ @@ -1234,32 +1263,6 @@ goto end; } - sigemptyset(&sigterm_action.sa_mask); - ret = sigaddset(&sigterm_action.sa_mask, SIGINT); - if(ret == -1){ - perror("sigaddset"); - exitcode = EXIT_FAILURE; - goto end; - } - ret = sigaddset(&sigterm_action.sa_mask, SIGHUP); - if(ret == -1){ - perror("sigaddset"); - exitcode = EXIT_FAILURE; - goto end; - } - ret = sigaddset(&sigterm_action.sa_mask, SIGTERM); - if(ret == -1){ - perror("sigaddset"); - exitcode = EXIT_FAILURE; - goto end; - } - ret = sigaction(SIGTERM, &sigterm_action, &old_sigterm_action); - if(ret == -1){ - perror("sigaction"); - exitcode = EXIT_FAILURE; - goto end; - } - /* Run the main loop */ if(debug){