X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=postlicyd%2Fmain-postlicyd.c;h=5f46e76e2377171cd1d242f6e3976fcccdb1c4f1;hb=2520de08ed80b941f28c9ccb97a3785a507a831d;hp=d6c5cc4c383f4deae5fd8111ac2823a5aa644096;hpb=6154a392a1f0d96d4599a45f1c37d84dbe5bfa4d;p=apps%2Fpfixtools.git diff --git a/postlicyd/main-postlicyd.c b/postlicyd/main-postlicyd.c index d6c5cc4..5f46e76 100644 --- a/postlicyd/main-postlicyd.c +++ b/postlicyd/main-postlicyd.c @@ -56,6 +56,11 @@ static void *query_starter(server_t* server) return query_new(); } +static bool config_refresh(void *config) +{ + return config_reload(config); +} + static int postfix_parsejob(query_t *query, char *p) { #define PARSE_CHECK(expr, error, ...) \ @@ -192,7 +197,7 @@ static bool policy_process(server_t *pcy, const config_t *config) static int policy_run(server_t *pcy, void* vconfig) { - ssize_t search_offs = MAX(0, pcy->ibuf.len - 1); + ssize_t search_offs = MAX(0, (ssize_t)(pcy->ibuf.len - 1)); int nb = buffer_read(&pcy->ibuf, pcy->fd, -1); const char *eoq; query_t *query = pcy->data; @@ -246,6 +251,7 @@ int main(int argc, char *argv[]) const char *pidfile = NULL; bool daemonize = true; int port = DEFAULT_PORT; + bool port_from_cli = false; for (int c = 0; (c = getopt(argc, argv, "hf" "l:p:")) >= 0; ) { switch (c) { @@ -257,6 +263,7 @@ int main(int argc, char *argv[]) break; case 'l': port = atoi(optarg); + port_from_cli = true; break; case 'f': daemonize = false; @@ -276,15 +283,19 @@ int main(int argc, char *argv[]) if (config == NULL) { return EXIT_FAILURE; } + if (port_from_cli || config->port == 0) { + config->port = port; + } if (common_setup(pidfile, false, RUNAS_USER, RUNAS_GROUP, daemonize) != EXIT_SUCCESS - || start_listener(port) < 0) { + || start_listener(config->port) < 0) { + config_delete(&config); return EXIT_FAILURE; } { int res = server_loop(query_starter, (delete_client_t)query_delete, - policy_run, config); + policy_run, config_refresh, config); config_delete(&config); return res; }