=== modified file 'TODO' --- TODO 2009-01-31 10:33:17 +0000 +++ TODO 2009-02-09 19:26:19 +0000 @@ -2,41 +2,35 @@ * mandos-client ** TODO [#A] Clean up /tmp directory on signal -** TODO [#C] IPv4 support * plugin-runner ** TODO [#B] use scandir(3) instead of readdir(3) * mandos (server) -** TODO [#B] Log level :bugs: +** TODO [#B] Log level :BUGS: ** TODO /etc/mandos/clients.d/*.conf Watch this directory and add/remove/update clients? ** TODO config for TXT record -** TODO [#B] Run-time communication with server :bugs: +** TODO [#B] Run-time communication with server :BUGS: Probably using D-Bus - See also [[*Mandos-tools]] *** Client class *** Main server + SetLogLevel syslogger.setLevel(logging.WARNING) - + Quit + [[http://log.ometer.com/2007-05.html][Best D-Bus practices]] -** TODO Implement --foreground :bugs: +** TODO Implement --foreground :BUGS: [[info:standards:Option%20Table][Table of Long Options]] ** TODO Implement --socket [[info:standards:Option%20Table][Table of Long Options]] -** TODO Date+time on console log messages :bugs: +** TODO Date+time on console log messages :BUGS: Is this the default? -** TODO delete hook when clients fall out by timeout - This will not be strictly necessary when the D-Bus interface is - implemented. * mandos.xml ** [[file:mandos.xml::XXX][Document D-Bus interface]] * Provide and install /etc/dbus-1/system.d/mandos.conf -* mandos-list +* mandos-ctl *** Handle "no D-Bus server" and/or "no Mandos server found" better *** [#B] --dump option @@ -52,8 +46,7 @@ * Package ** /usr/share/initramfs-tools/hooks/mandos *** TODO [#C] Do not install in initrd.img if configured not to. - Use "/etc/initramfs-tools/conf.d/mandos"? Definitely a debconf - question. + Use "/etc/initramfs-tools/hooksconf.d/mandos"? ** TODO [#C] /etc/bash_completion.d/mandos From XML sources directly? === modified file 'plugin-runner.c' --- plugin-runner.c 2009-02-09 05:09:39 +0000 +++ plugin-runner.c 2009-02-09 19:26:19 +0000 @@ -62,7 +62,8 @@ #include /* struct sigaction, sigemptyset(), sigaddset(), sigaction(), sigprocmask(), SIG_BLOCK, SIGCHLD, - SIG_UNBLOCK, kill() */ + SIG_UNBLOCK, kill(), sig_atomic_t + */ #include /* errno, EBADF */ #include /* intmax_t, SCNdMAX, PRIdMAX, */ === modified file 'plugins.d/mandos-client.c' --- plugins.d/mandos-client.c 2009-02-09 05:48:04 +0000 +++ plugins.d/mandos-client.c 2009-02-09 19:26:19 +0000 @@ -76,11 +76,12 @@ argp_parse(), ARGP_KEY_ARG, ARGP_KEY_END, ARGP_ERR_UNKNOWN */ #include /* sigemptyset(), sigaddset(), - sigaction(), SIGTERM, sigaction */ + sigaction(), SIGTERM, sigaction, + sig_atomic_t */ #ifdef __linux__ #include /* klogctl() */ -#endif +#endif /* __linux__ */ /* Avahi */ /* All Avahi types, constants and functions @@ -136,9 +137,9 @@ mandos_context mc; /* - * Make additional room in "buffer" for at least BUFFER_SIZE - * additional bytes. "buffer_capacity" is how much is currently - * allocated, "buffer_length" is how much is already used. + * Make additional room in "buffer" for at least BUFFER_SIZE more + * bytes. "buffer_capacity" is how much is currently allocated, + * "buffer_length" is how much is already used. */ size_t incbuffer(char **buffer, size_t buffer_length, size_t buffer_capacity){ @@ -871,9 +872,17 @@ } } +sig_atomic_t quit_now = 0; + static void handle_sigterm(__attribute__((unused)) int sig){ + if(quit_now){ + return; + } + quit_now = 1; int old_errno = errno; - avahi_simple_poll_quit(mc.simple_poll); + if(mc.simple_poll != NULL){ + avahi_simple_poll_quit(mc.simple_poll); + } errno = old_errno; } @@ -1014,7 +1023,7 @@ restore_loglevel = false; perror("klogctl"); } -#endif +#endif /* __linux__ */ sd = socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP); if(sd < 0){ @@ -1027,7 +1036,7 @@ perror("klogctl"); } } -#endif +#endif /* __linux__ */ goto end; } strcpy(network.ifr_name, interface); @@ -1041,7 +1050,7 @@ perror("klogctl"); } } -#endif +#endif /* __linux__ */ exitcode = EXIT_FAILURE; goto end; } @@ -1058,7 +1067,7 @@ perror("klogctl"); } } -#endif +#endif /* __linux__ */ goto end; } } @@ -1088,7 +1097,7 @@ perror("klogctl"); } } -#endif +#endif /* __linux__ */ } uid = getuid(); @@ -1226,6 +1235,18 @@ } 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");