1 From 5c6204bab7279050b78b3d03d1211e9d13d3fd71 Mon Sep 17 00:00:00 2001
2 From: Pavel Zhukov <pzhukov@redhat.com>
3 Date: Wed, 27 Mar 2019 09:59:20 +0100
4 Subject: [PATCH] Backport sd-notify patch for systemd support (#1687040)
8 configure.ac | 11 +++++++++++
9 relay/dhcrelay.c | 12 ++++++++++++
10 server/dhcpd.c | 12 ++++++++++++
11 3 files changed, 35 insertions(+)
13 diff --git a/configure.ac b/configure.ac
14 index 15fc0d7..0c08000 100644
17 @@ -1014,6 +1014,17 @@ if test x$ldap = xyes || test x$ldapcrypto = xyes || test x$ldap_gssapi = xyes;
18 AC_SUBST(LDAP_CFLAGS, [$LDAP_CFLAGS])
22 + AC_HELP_STRING([--with-systemd],
23 + [enable sending status notifications to systemd daemon (default is no)]),
27 +if test x$systemd = xyes ; then
28 + AC_CHECK_LIB(systemd, sd_notifyf, ,
29 + AC_MSG_FAILURE([*** systemd library not present - do you need to install systemd-libs package?]))
32 # Append selected warning levels to CFLAGS before substitution (but after
33 # AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]) & etc).
34 CFLAGS="$CFLAGS $STD_CWARNINGS"
35 diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c
36 index 7b4f4f1..9eb5bfd 100644
37 --- a/relay/dhcrelay.c
38 +++ b/relay/dhcrelay.c
40 int keep_capabilities = 0;
43 +#ifdef HAVE_LIBSYSTEMD
44 +#include <systemd/sd-daemon.h>
47 TIME default_lease_time = 43200; /* 12 hours... */
48 TIME max_lease_time = 86400; /* 24 hours... */
49 struct tree_cache *global_options[256];
50 @@ -845,6 +849,14 @@ main(int argc, char **argv) {
54 +#ifdef HAVE_LIBSYSTEMD
55 + /* We are ready to process incomming packets. Let's notify systemd */
56 + sd_notifyf(0, "READY=1\n"
57 + "STATUS=Dispatching packets...\n"
59 + (unsigned long) getpid());
62 /* Start dispatching packets and timeouts... */
65 diff --git a/server/dhcpd.c b/server/dhcpd.c
66 index 530a923..e06f6b4 100644
69 @@ -60,6 +60,10 @@ gid_t set_gid = 0;
70 struct class unknown_class;
71 struct class known_class;
73 +#ifdef HAVE_LIBSYSTEMD
74 +#include <systemd/sd-daemon.h>
77 struct iaddr server_identifier;
78 int server_identifier_matched;
80 @@ -1057,6 +1061,14 @@ main(int argc, char **argv) {
81 /* Log that we are about to start working */
82 log_info("Server starting service.");
84 +#ifdef HAVE_LIBSYSTEMD
85 + /* We are ready to process incomming packets. Let's notify systemd */
86 + sd_notifyf(0, "READY=1\n"
87 + "STATUS=Dispatching packets...\n"
89 + (unsigned long) getpid());
93 * Receive packets and dispatch them...
94 * dispatch() will never return.