philipp / rpms / dhcp

Forked from rpms/dhcp 4 years ago
Clone

Blame SOURCES/dhcp-sd-daemon.patch

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