after fork restore the default signal mask

This commit is contained in:
Nikos Mavrogiannopoulos
2014-08-22 15:23:16 +02:00
parent c567a129f4
commit 817f757577
3 changed files with 6 additions and 2 deletions
+2
View File
@@ -66,6 +66,8 @@ const char* script;
char local[64] = ""; char local[64] = "";
char remote[64] = ""; char remote[64] = "";
sigprocmask(SIG_SETMASK, &sig_default_set, NULL);
snprintf(real, sizeof(real), "%u", (unsigned)proc->pid); snprintf(real, sizeof(real), "%u", (unsigned)proc->pid);
setenv("ID", real, 1); setenv("ID", real, 1);
+3 -2
View File
@@ -64,6 +64,7 @@ static unsigned int terminate = 0;
static unsigned int reload_conf = 0; static unsigned int reload_conf = 0;
unsigned int need_maintenance = 0; unsigned int need_maintenance = 0;
static unsigned int need_children_cleanup = 0; static unsigned int need_children_cleanup = 0;
sigset_t sig_default_set;
static void ms_sleep(unsigned ms) static void ms_sleep(unsigned ms)
{ {
@@ -974,7 +975,7 @@ int main(int argc, char** argv)
exit(1); exit(1);
} }
sigprocmask(SIG_BLOCK, &blockset, NULL); sigprocmask(SIG_BLOCK, &blockset, &sig_default_set);
alarm(MAINTAINANCE_TIME(s)); alarm(MAINTAINANCE_TIME(s));
for (;;) { for (;;) {
@@ -1061,6 +1062,7 @@ int main(int argc, char** argv)
/* close any open descriptors, and erase /* close any open descriptors, and erase
* sensitive data before running the worker * sensitive data before running the worker
*/ */
sigprocmask(SIG_SETMASK, &sig_default_set, NULL);
close(cmd_fd[0]); close(cmd_fd[0]);
clear_lists(s); clear_lists(s);
@@ -1096,7 +1098,6 @@ int main(int argc, char** argv)
* sensitive data have to be overwritten anyway. */ * sensitive data have to be overwritten anyway. */
malloc_trim(0); malloc_trim(0);
#endif #endif
sigprocmask(SIG_UNBLOCK, &blockset, NULL);
vpn_server(ws); vpn_server(ws);
exit(0); exit(0);
} else if (pid == -1) { } else if (pid == -1) {
+1
View File
@@ -39,6 +39,7 @@
#define COOKIE_KEY_SIZE 16 #define COOKIE_KEY_SIZE 16
extern sigset_t sig_default_set;
int cmd_parser (void *pool, int argc, char **argv, struct cfg_st** config); int cmd_parser (void *pool, int argc, char **argv, struct cfg_st** config);
void reload_cfg_file(void *pool, struct cfg_st* config); void reload_cfg_file(void *pool, struct cfg_st* config);
void clear_cfg_file(struct cfg_st* config); void clear_cfg_file(struct cfg_st* config);