Log filter result.
[apps/pfixtools.git] / postlicyd / main-postlicyd.c
index cae2d23..cfe2c56 100644 (file)
@@ -88,9 +88,18 @@ static bool policy_process(server_t *pcy, const config_t *config)
     while (true) {
         const filter_hook_t *hook = filter_run(filter, query);
         if (hook == NULL) {
-            syslog(LOG_WARNING, "request aborted");
+            syslog(LOG_WARNING, "request client=%s, from=<%s>, to=<%s>: aborted",
+                   query->client_name,
+                   query->sender == NULL ? "undefined" : query->sender,
+                   query->recipient == NULL ? "undefined" : query->recipient);
             return false;
         } else if (hook->postfix) {
+            syslog(LOG_INFO, "request client=%s, from=<%s>, to=<%s>: "
+                  "awswer %s from filter %s",
+                   query->client_name,
+                   query->sender == NULL ? "undefined" : query->sender,
+                   query->recipient == NULL ? "undefined" : query->recipient,
+                   htokens[hook->type], filter->name);
             policy_answer(pcy, "%s", hook->value);
             return true;
         } else {
@@ -183,6 +192,11 @@ int main(int argc, char *argv[])
         return EXIT_FAILURE;
     }
 
+    if (drop_privileges(RUNAS_USER, RUNAS_GROUP) < 0) {
+        syslog(LOG_CRIT, "unable to drop privileges");
+        return EXIT_FAILURE;
+    }
+
     config_t *config = config_read(argv[optind]);
     if (config == NULL) {
         return EXIT_FAILURE;
@@ -191,13 +205,11 @@ int main(int argc, char *argv[])
         config->port = port;
     }
 
-    if (common_setup(pidfile, false, RUNAS_USER, RUNAS_GROUP,
-                     daemonize) != EXIT_SUCCESS
+    if (common_setup(pidfile, true, NULL, NULL, daemonize) != EXIT_SUCCESS
         || start_listener(config->port) < 0) {
         config_delete(&config);
         return EXIT_FAILURE;
-    }
-    {
+    } else {
         int res = server_loop(query_starter, (delete_client_t)query_delete,
                               policy_run, config_refresh, config);
         config_delete(&config);