Browse Source

* move SA_REGISTER() macro to daemon.c, cleanup headers

master
Alex 'AdUser' Z 4 years ago
parent
commit
8988d5f8bc
  1. 20
      src/common.h
  2. 12
      src/daemon.c

20
src/common.h

@ -39,17 +39,13 @@
*/ */
#define DEFAULT_PIDFILE_PATH "/var/run/f2b.pid" #define DEFAULT_PIDFILE_PATH "/var/run/f2b.pid"
/** /**
* Default path of unix control socket (server endpoint) * Default path of unix control socket
*/ */
#define DEFAULT_CSOCKET_PATH "/var/run/f2b.sock" #define DEFAULT_CSOCKET_PATH "/var/run/f2b.sock"
/** /**
* Default path of directory to store ip states for jails * Default path of directory to store ip states for jails
*/ */
#define DEFAULT_STATEDIR_PATH "/var/db/f2b" #define DEFAULT_STATEDIR_PATH "/var/db/f2b"
/**
* Template for making path for client side of connection to control socket
*/
#define DEFAULT_CSOCKET_CPATH "/tmp/f2bc-sock-XXXXXX"
/** /**
* @def UNUSED * @def UNUSED
@ -57,16 +53,8 @@
*/ */
#define UNUSED(x) (void)(x) #define UNUSED(x) (void)(x)
/** /* default size of buffers */
* @def SA_REGISTER #define RBUF_SIZE 256
* Register signal handler #define WBUF_SIZE 32768 /* 32Kb */
*/
#define SA_REGISTER(SIGNUM, HANDLER) \
memset(&act, 0x0, sizeof(act)); \
act.sa_handler = HANDLER; \
if (sigaction(SIGNUM, &act, NULL) != 0) { \
f2b_log_msg(log_fatal, "can't register handler for " #SIGNUM); \
return EXIT_FAILURE; \
}
#endif /* F2B_COMMON_H_ */ #endif /* F2B_COMMON_H_ */

12
src/daemon.c

@ -17,6 +17,18 @@
#include <getopt.h> #include <getopt.h>
#include <signal.h> #include <signal.h>
/**
* @def SA_REGISTER
* Register signal handler
*/
#define SA_REGISTER(SIGNUM, HANDLER) \
memset(&act, 0x0, sizeof(act)); \
act.sa_handler = HANDLER; \
if (sigaction(SIGNUM, &act, NULL) != 0) { \
f2b_log_msg(log_fatal, "can't register handler for " #SIGNUM); \
return EXIT_FAILURE; \
}
enum { stop = 0, run, reconfig, logrotate, test } state = run; enum { stop = 0, run, reconfig, logrotate, test } state = run;
void signal_handler(int signum) { void signal_handler(int signum) {

Loading…
Cancel
Save