Blame SOURCES/dhcp-sd-daemon.patch

54343e
diff -up dhcp-4.2.5/configure.ac.sd-daemon dhcp-4.2.5/configure.ac
54343e
--- dhcp-4.2.5/configure.ac.sd-daemon	2014-07-07 12:13:21.474322606 +0200
54343e
+++ dhcp-4.2.5/configure.ac	2014-07-07 12:16:11.320964893 +0200
54343e
@@ -714,6 +714,17 @@ if test x$ldap = xyes || test x$ldapcryp
54343e
     fi
54343e
 fi
54343e
 
54343e
+AC_ARG_WITH(systemd,
54343e
+        AC_HELP_STRING([--with-systemd],
54343e
+                       [enable sending status notifications to systemd daemon (default is no)]),
54343e
+        [systemd=$withval],
54343e
+        [systemd=no])
54343e
+
54343e
+if test x$systemd = xyes ; then
54343e
+   AC_CHECK_LIB(systemd-daemon, sd_notify, ,
54343e
+                AC_MSG_FAILURE([*** sd-daemon library not present - do you need to install systemd-libs package?]))
54343e
+fi
54343e
+
54343e
 # Append selected warning levels to CFLAGS before substitution (but after
54343e
 # AC_TRY_COMPILE & etc).
54343e
 CFLAGS="$CFLAGS $STD_CWARNINGS"
54343e
diff -up dhcp-4.2.5/relay/dhcrelay.c.sd-daemon dhcp-4.2.5/relay/dhcrelay.c
54343e
--- dhcp-4.2.5/relay/dhcrelay.c.sd-daemon	2014-07-07 12:13:21.329324619 +0200
54343e
+++ dhcp-4.2.5/relay/dhcrelay.c	2014-07-07 12:13:21.475322592 +0200
54343e
@@ -41,6 +41,10 @@
54343e
    int keep_capabilities = 0;
54343e
 #endif
54343e
 
54343e
+#ifdef HAVE_LIBSYSTEMD_DAEMON
54343e
+#include <systemd/sd-daemon.h>
54343e
+#endif
54343e
+
54343e
 TIME default_lease_time = 43200; /* 12 hours... */
54343e
 TIME max_lease_time = 86400; /* 24 hours... */
54343e
 struct tree_cache *global_options[256];
54343e
@@ -608,6 +612,14 @@ main(int argc, char **argv) {
54343e
 	}
54343e
 #endif
54343e
 
54343e
+#ifdef HAVE_LIBSYSTEMD_DAEMON
54343e
+        /* We are ready to process incomming packets. Let's notify systemd */
54343e
+        sd_notifyf(0, "READY=1\n"
54343e
+                   "STATUS=Dispatching packets...\n"
54343e
+                   "MAINPID=%lu",
54343e
+                   (unsigned long) getpid());
54343e
+#endif
54343e
+
54343e
 	/* Start dispatching packets and timeouts... */
54343e
 	dispatch();
54343e
 
54343e
diff -up dhcp-4.2.5/server/dhcpd.c.sd-daemon dhcp-4.2.5/server/dhcpd.c
54343e
--- dhcp-4.2.5/server/dhcpd.c.sd-daemon	2014-07-07 12:13:21.419323370 +0200
54343e
+++ dhcp-4.2.5/server/dhcpd.c	2014-07-07 12:16:57.838319165 +0200
54343e
@@ -60,6 +60,10 @@ static const char url [] =
54343e
 
54343e
 #include "trace.h"
54343e
 
54343e
+#ifdef HAVE_LIBSYSTEMD_DAEMON
54343e
+#include <systemd/sd-daemon.h>
54343e
+#endif
54343e
+
54343e
 #ifndef UNIT_TEST
54343e
 static void usage(void);
54343e
 #endif
54343e
@@ -869,6 +873,15 @@ main(int argc, char **argv) {
54343e
 			     (omapi_object_t *)0, "state", server_running);
54343e
 
54343e
         TRACE(DHCPD_MAIN());
54343e
+
54343e
+#ifdef HAVE_LIBSYSTEMD_DAEMON
54343e
+        /* We are ready to process incomming packets. Let's notify systemd */
54343e
+        sd_notifyf(0, "READY=1\n"
54343e
+                   "STATUS=Dispatching packets...\n"
54343e
+                   "MAINPID=%lu",
54343e
+                   (unsigned long) getpid());
54343e
+#endif
54343e
+
54343e
 	/* Receive packets and dispatch them... */
54343e
 	dispatch ();
54343e