[Opendnssec-commits] matthijs r6945 - trunk/OpenDNSSEC/signer/src/daemon

commits at svn.opendnssec.org commits at svn.opendnssec.org
Fri Jan 11 11:58:55 CET 2013


Author: matthijs
Date: Fri Jan 11 11:58:55 2013
New Revision: 6945
URL: http://fisheye.opendnssec.org/changelog/opendnssec?cs=6945

Log:
SUPPORT-44: only do the bind sockets before privdrop, start rest after privdrop

Modified:
   trunk/OpenDNSSEC/signer/src/daemon/dnshandler.c
   trunk/OpenDNSSEC/signer/src/daemon/dnshandler.h
   trunk/OpenDNSSEC/signer/src/daemon/engine.c

Modified: trunk/OpenDNSSEC/signer/src/daemon/dnshandler.c
==============================================================================
--- trunk/OpenDNSSEC/signer/src/daemon/dnshandler.c	Fri Jan 11 11:07:56 2013	(r6944)
+++ trunk/OpenDNSSEC/signer/src/daemon/dnshandler.c	Fri Jan 11 11:58:55 2013	(r6945)
@@ -103,6 +103,25 @@
 
 
 /**
+ * Start dns handler listener.
+ *
+ */
+ods_status
+dnshandler_listen(dnshandler_type* dnshandler)
+{
+    ods_status status = ODS_STATUS_OK;
+    ods_log_assert(dnshandler);
+    status = sock_listen(dnshandler->socklist, dnshandler->interfaces);
+    if (status != ODS_STATUS_OK) {
+        ods_log_error("[%s] unable to start: sock_listen() "
+            "failed (%s)", dnsh_str, ods_status2str(status));
+        dnshandler->thread_id = 0;
+    }
+    return status;
+}
+
+
+/**
  * Start dns handler.
  *
  */
@@ -112,21 +131,10 @@
     size_t i = 0;
     engine_type* engine = NULL;
     netio_handler_type* tcp_accept_handlers = NULL;
-    ods_status status = ODS_STATUS_OK;
 
     ods_log_assert(dnshandler);
     ods_log_assert(dnshandler->engine);
     ods_log_debug("[%s] start", dnsh_str);
-    /* setup */
-    engine = (engine_type*) dnshandler->engine;
-    status = sock_listen(dnshandler->socklist, dnshandler->interfaces);
-    if (status != ODS_STATUS_OK) {
-        ods_log_error("[%s] unable to start: sock_listen() "
-            "failed (%s)", dnsh_str, ods_status2str(status));
-        dnshandler->thread_id = 0;
-        engine->need_to_exit = 1;
-        return;
-    }
     /* udp */
     for (i=0; i < dnshandler->interfaces->count; i++) {
         struct udp_data* data = NULL;

Modified: trunk/OpenDNSSEC/signer/src/daemon/dnshandler.h
==============================================================================
--- trunk/OpenDNSSEC/signer/src/daemon/dnshandler.h	Fri Jan 11 11:07:56 2013	(r6944)
+++ trunk/OpenDNSSEC/signer/src/daemon/dnshandler.h	Fri Jan 11 11:58:55 2013	(r6945)
@@ -37,6 +37,7 @@
 #include "config.h"
 #include "shared/allocator.h"
 #include "shared/locks.h"
+#include "shared/status.h"
 #include "wire/listener.h"
 #include "wire/netio.h"
 #include "wire/query.h"
@@ -71,6 +72,14 @@
     listener_type* interfaces);
 
 /**
+ * Start dns handler listener.
+ * \param[in] dnshandler_type* dns handler
+ * \return ods_status status
+ *
+ */
+ods_status dnshandler_listen(dnshandler_type* dnshandler);
+
+/**
  * Start dns handler.
  * \param[in] dnshandler_type* dns handler
  *

Modified: trunk/OpenDNSSEC/signer/src/daemon/engine.c
==============================================================================
--- trunk/OpenDNSSEC/signer/src/daemon/engine.c	Fri Jan 11 11:07:56 2013	(r6944)
+++ trunk/OpenDNSSEC/signer/src/daemon/engine.c	Fri Jan 11 11:58:55 2013	(r6945)
@@ -473,6 +473,7 @@
 static ods_status
 engine_setup(engine_type* engine)
 {
+    ods_status status = ODS_STATUS_OK;
     struct sigaction action;
     int result = 0;
     int sockets[2] = {0,0};
@@ -502,9 +503,12 @@
         }
         engine->xfrhandler->dnshandler.fd = sockets[0];
         engine->dnshandler->xfrhandler.fd = sockets[1];
-        engine_start_dnshandler(engine);
+        status = dnshandler_listen(engine->dnshandler);
+        if (status != ODS_STATUS_OK) {
+            ods_log_error("[%s] setup: unable to listen to sockets (%s)",
+                engine_str, ods_status2str(status));
+        }
     }
-    engine_start_xfrhandler(engine);
     /* privdrop */
     engine->uid = privuid(engine->config->username);
     engine->gid = privgid(engine->config->group);
@@ -573,8 +577,10 @@
     /* create workers/drudgers */
     engine_create_workers(engine);
     engine_create_drudgers(engine);
-    /* start cmdhandler */
+    /* start cmd/dns/xfr handlers */
     engine_start_cmdhandler(engine);
+    engine_start_dnshandler(engine);
+    engine_start_xfrhandler(engine);
     tsig_handler_init(engine->allocator);
     /* write pidfile */
     if (util_write_pidfile(engine->config->pid_filename, engine->pid) == -1) {



More information about the Opendnssec-commits mailing list