=== modified file 'plugins.d/mandos-client.c' --- plugins.d/mandos-client.c 2009-08-30 03:10:29 +0000 +++ plugins.d/mandos-client.c 2009-09-05 01:05:25 +0000 @@ -1055,23 +1055,48 @@ exitcode = EXIT_FAILURE; goto end; } - ret = sigaction(SIGINT, &sigterm_action, &old_sigterm_action); - if(ret == -1){ - perror("sigaction"); - exitcode = EXIT_FAILURE; - goto end; - } - ret = sigaction(SIGHUP, &sigterm_action, NULL); - if(ret == -1){ - perror("sigaction"); - exitcode = EXIT_FAILURE; - goto end; - } - ret = sigaction(SIGTERM, &sigterm_action, NULL); - if(ret == -1){ - perror("sigaction"); - exitcode = EXIT_FAILURE; - goto end; + /* Need to check if the handler is SIG_IGN before handling: + | [[info:libc:Initial Signal Actions]] | + | [[info:libc:Basic Signal Handling]] | + */ + ret = sigaction(SIGINT, NULL, &old_sigterm_action); + if(ret == -1){ + perror("sigaction"); + return EXIT_FAILURE; + } + if(old_sigterm_action.sa_handler != SIG_IGN){ + ret = sigaction(SIGINT, &sigterm_action, NULL); + if(ret == -1){ + perror("sigaction"); + exitcode = EXIT_FAILURE; + goto end; + } + } + ret = sigaction(SIGHUP, NULL, &old_sigterm_action); + if(ret == -1){ + perror("sigaction"); + return EXIT_FAILURE; + } + if(old_sigterm_action.sa_handler != SIG_IGN){ + ret = sigaction(SIGHUP, &sigterm_action, NULL); + if(ret == -1){ + perror("sigaction"); + exitcode = EXIT_FAILURE; + goto end; + } + } + ret = sigaction(SIGTERM, NULL, &old_sigterm_action); + if(ret == -1){ + perror("sigaction"); + return EXIT_FAILURE; + } + if(old_sigterm_action.sa_handler != SIG_IGN){ + ret = sigaction(SIGTERM, &sigterm_action, NULL); + if(ret == -1){ + perror("sigaction"); + exitcode = EXIT_FAILURE; + goto end; + } } /* If the interface is down, bring it up */ @@ -1434,6 +1459,8 @@ } if(quit_now){ + sigemptyset(&old_sigterm_action.sa_mask); + old_sigterm_action.sa_handler = SIG_DFL; ret = sigaction(signal_received, &old_sigterm_action, NULL); if(ret == -1){ perror("sigaction"); === modified file 'plugins.d/password-prompt.c' --- plugins.d/password-prompt.c 2009-09-04 16:32:22 +0000 +++ plugins.d/password-prompt.c 2009-09-05 01:05:25 +0000 @@ -129,18 +129,30 @@ } sigemptyset(&new_action.sa_mask); - sigaddset(&new_action.sa_mask, SIGINT); - sigaddset(&new_action.sa_mask, SIGHUP); - sigaddset(&new_action.sa_mask, SIGTERM); - ret = sigaction(SIGINT, NULL, &old_action); - if(ret == -1){ - perror("sigaction"); + ret = sigaddset(&new_action.sa_mask, SIGINT); + if(ret == -1){ + perror("sigaddset"); + return EXIT_FAILURE; + } + ret = sigaddset(&new_action.sa_mask, SIGHUP); + if(ret == -1){ + perror("sigaddset"); + return EXIT_FAILURE; + } + ret = sigaddset(&new_action.sa_mask, SIGTERM); + if(ret == -1){ + perror("sigaddset"); return EXIT_FAILURE; } /* Need to check if the handler is SIG_IGN before handling: | [[info:libc:Initial Signal Actions]] | | [[info:libc:Basic Signal Handling]] | */ + ret = sigaction(SIGINT, NULL, &old_action); + if(ret == -1){ + perror("sigaction"); + return EXIT_FAILURE; + } if(old_action.sa_handler != SIG_IGN){ ret = sigaction(SIGINT, &new_action, NULL); if(ret == -1){