Blame SOURCES/dhcp-sd_notify.patch

324fcf
diff -up dhcp-4.3.4/configure.ac.sd_notify dhcp-4.3.4/configure.ac
324fcf
--- dhcp-4.3.4/configure.ac.sd_notify	2016-04-29 13:08:52.813287060 +0200
324fcf
+++ dhcp-4.3.4/configure.ac	2016-04-29 13:08:52.872287075 +0200
324fcf
@@ -832,6 +832,17 @@ if test x$ldap = xyes || test x$ldapcryp
324fcf
     AC_SUBST(LDAP_CFLAGS, [$LDAP_CFLAGS])
324fcf
 fi
324fcf
 
324fcf
+AC_ARG_WITH(systemd,
324fcf
+        AC_HELP_STRING([--with-systemd],
324fcf
+                       [enable sending status notifications to systemd daemon (default is no)]),
324fcf
+        [systemd=$withval],
324fcf
+        [systemd=no])
324fcf
+
324fcf
+if test x$systemd = xyes ; then
324fcf
+   AC_CHECK_LIB(systemd, sd_notifyf, ,
324fcf
+                AC_MSG_FAILURE([*** systemd library not present - do you need to install systemd-libs package?]))
324fcf
+fi
324fcf
+
324fcf
 # Append selected warning levels to CFLAGS before substitution (but after
324fcf
 # AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]) & etc).
324fcf
 CFLAGS="$CFLAGS $STD_CWARNINGS"
324fcf
diff -up dhcp-4.3.4/relay/dhcrelay.c.sd_notify dhcp-4.3.4/relay/dhcrelay.c
324fcf
--- dhcp-4.3.4/relay/dhcrelay.c.sd_notify	2016-04-29 13:08:52.814287061 +0200
324fcf
+++ dhcp-4.3.4/relay/dhcrelay.c	2016-04-29 13:08:52.872287075 +0200
324fcf
@@ -37,6 +37,10 @@
324fcf
    int keep_capabilities = 0;
324fcf
 #endif
324fcf
 
324fcf
+#ifdef HAVE_LIBSYSTEMD
324fcf
+#include <systemd/sd-daemon.h>
324fcf
+#endif
324fcf
+
324fcf
 TIME default_lease_time = 43200; /* 12 hours... */
324fcf
 TIME max_lease_time = 86400; /* 24 hours... */
324fcf
 struct tree_cache *global_options[256];
324fcf
@@ -709,6 +713,14 @@ main(int argc, char **argv) {
324fcf
 	}
324fcf
 #endif
324fcf
 
324fcf
+#ifdef HAVE_LIBSYSTEMD
324fcf
+        /* We are ready to process incomming packets. Let's notify systemd */
324fcf
+        sd_notifyf(0, "READY=1\n"
324fcf
+                   "STATUS=Dispatching packets...\n"
324fcf
+                   "MAINPID=%lu",
324fcf
+                   (unsigned long) getpid());
324fcf
+#endif
324fcf
+
324fcf
 	/* Start dispatching packets and timeouts... */
324fcf
 	dispatch();
324fcf
 
324fcf
diff -up dhcp-4.3.4/server/dhcpd.c.sd_notify dhcp-4.3.4/server/dhcpd.c
324fcf
--- dhcp-4.3.4/server/dhcpd.c.sd_notify	2016-04-29 13:08:52.873287075 +0200
324fcf
+++ dhcp-4.3.4/server/dhcpd.c	2016-04-29 13:12:00.655333096 +0200
324fcf
@@ -57,6 +57,10 @@ uid_t set_uid = 0;
324fcf
 gid_t set_gid = 0;
324fcf
 #endif /* PARANOIA */
324fcf
 
324fcf
+#ifdef HAVE_LIBSYSTEMD
324fcf
+#include <systemd/sd-daemon.h>
324fcf
+#endif
324fcf
+
324fcf
 struct iaddr server_identifier;
324fcf
 int server_identifier_matched;
324fcf
 
324fcf
@@ -931,6 +935,14 @@ main(int argc, char **argv) {
324fcf
 	/* Log that we are about to start working */
324fcf
 	log_info("Server starting service.");
324fcf
 
324fcf
+#ifdef HAVE_LIBSYSTEMD
324fcf
+        /* We are ready to process incomming packets. Let's notify systemd */
324fcf
+        sd_notifyf(0, "READY=1\n"
324fcf
+                   "STATUS=Dispatching packets...\n"
324fcf
+                   "MAINPID=%lu",
324fcf
+                   (unsigned long) getpid());
324fcf
+#endif
324fcf
+
324fcf
 	/*
324fcf
 	 * Receive packets and dispatch them...
324fcf
 	 * dispatch() will never return.