X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=postlicyd%2Fmain-postlicyd.c;h=dab0bf0159776549858a8b031ad7453fc3028fe0;hb=8950d42993b7148718f712b8d7e77aaa21ef14ce;hp=7d7d8df5e0fdee6714daa1b8c110dba735626a55;hpb=af645f579c2652e6a095876048565d03a9434286;p=apps%2Fpfixtools.git diff --git a/postlicyd/main-postlicyd.c b/postlicyd/main-postlicyd.c index 7d7d8df..dab0bf0 100644 --- a/postlicyd/main-postlicyd.c +++ b/postlicyd/main-postlicyd.c @@ -44,7 +44,7 @@ #include "query.h" #define DAEMON_NAME "postlicyd" -#define DAEMON_VERSION "0.3" +#define DAEMON_VERSION "0.4" #define DEFAULT_PORT 10000 #define RUNAS_USER "nobody" #define RUNAS_GROUP "nogroup" @@ -83,7 +83,10 @@ static bool config_refresh(void *mconfig) if (filter_running > 0) { return true; } + log_state = "refreshing "; + info("reloading configuration"); bool ret = config_reload(mconfig); + log_state = ""; foreach (client_t **server, busy) { client_io_ro(*server); }} @@ -283,6 +286,7 @@ void usage(void) " -f stay in foreground\n" " -d grow logging level\n" " -u unsafe mode (don't drop privileges)\n" + " -c check-conf\n" , stderr); } @@ -295,8 +299,9 @@ int main(int argc, char *argv[]) bool daemonize = true; int port = DEFAULT_PORT; bool port_from_cli = false; + bool check_conf = false; - for (int c = 0; (c = getopt(argc, argv, "ufd" "l:p:")) >= 0; ) { + for (int c = 0; (c = getopt(argc, argv, "ufdc" "l:p:")) >= 0; ) { switch (c) { case 'p': pidfile = optarg; @@ -314,6 +319,11 @@ int main(int argc, char *argv[]) case 'd': ++log_level; break; + case 'c': + check_conf = true; + daemonize = false; + unsafe = true; + break; default: usage(); return EXIT_FAILURE; @@ -329,6 +339,9 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } + if (check_conf) { + return config_check(argv[optind]) ? EXIT_SUCCESS : EXIT_FAILURE; + } info("%s v%s...", DAEMON_NAME, DAEMON_VERSION); if (pidfile_open(pidfile) < 0) {