|
|
df4638 |
From 8d974fd1f667e1b957ad4092fe66a8bb94f5f8fd Mon Sep 17 00:00:00 2001
|
|
|
df4638 |
From: Pavel Zhukov <pzhukov@redhat.com>
|
|
|
df4638 |
Date: Thu, 7 Nov 2019 14:47:45 +0100
|
|
|
df4638 |
Subject: [PATCH 1/1] Add missed sd notify patch to manage dhcpd with systemd
|
|
|
df4638 |
Cc: pzhukov@redhat.com
|
|
|
df4638 |
|
|
|
df4638 |
---
|
|
|
df4638 |
configure.ac | 11 +++++++++++
|
|
|
df4638 |
relay/dhcrelay.c | 12 ++++++++++++
|
|
|
df4638 |
server/dhcpd.c | 12 ++++++++++++
|
|
|
df4638 |
3 files changed, 35 insertions(+)
|
|
|
df4638 |
|
|
|
df4638 |
diff --git a/configure.ac b/configure.ac
|
|
|
df4638 |
index 15fc0d7..0c08000 100644
|
|
|
df4638 |
--- a/configure.ac
|
|
|
df4638 |
+++ b/configure.ac
|
|
|
df4638 |
@@ -1014,6 +1014,17 @@ if test x$ldap = xyes || test x$ldapcrypto = xyes || test x$ldap_gssapi = xyes;
|
|
|
df4638 |
AC_SUBST(LDAP_CFLAGS, [$LDAP_CFLAGS])
|
|
|
df4638 |
fi
|
|
|
df4638 |
|
|
|
df4638 |
+AC_ARG_WITH(systemd,
|
|
|
df4638 |
+ AC_HELP_STRING([--with-systemd],
|
|
|
df4638 |
+ [enable sending status notifications to systemd daemon (default is no)]),
|
|
|
df4638 |
+ [systemd=$withval],
|
|
|
df4638 |
+ [systemd=no])
|
|
|
df4638 |
+
|
|
|
df4638 |
+if test x$systemd = xyes ; then
|
|
|
df4638 |
+ AC_CHECK_LIB(systemd, sd_notifyf, ,
|
|
|
df4638 |
+ AC_MSG_FAILURE([*** systemd library not present - do you need to install systemd-libs package?]))
|
|
|
df4638 |
+fi
|
|
|
df4638 |
+
|
|
|
df4638 |
# Append selected warning levels to CFLAGS before substitution (but after
|
|
|
df4638 |
# AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]) & etc).
|
|
|
df4638 |
CFLAGS="$CFLAGS $STD_CWARNINGS"
|
|
|
df4638 |
diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c
|
|
|
df4638 |
index 7b4f4f1..9eb5bfd 100644
|
|
|
df4638 |
--- a/relay/dhcrelay.c
|
|
|
df4638 |
+++ b/relay/dhcrelay.c
|
|
|
df4638 |
@@ -37,6 +37,10 @@
|
|
|
df4638 |
int keep_capabilities = 0;
|
|
|
df4638 |
#endif
|
|
|
df4638 |
|
|
|
df4638 |
+#ifdef HAVE_LIBSYSTEMD
|
|
|
df4638 |
+#include <systemd/sd-daemon.h>
|
|
|
df4638 |
+#endif
|
|
|
df4638 |
+
|
|
|
df4638 |
TIME default_lease_time = 43200; /* 12 hours... */
|
|
|
df4638 |
TIME max_lease_time = 86400; /* 24 hours... */
|
|
|
df4638 |
struct tree_cache *global_options[256];
|
|
|
df4638 |
@@ -845,6 +849,14 @@ main(int argc, char **argv) {
|
|
|
df4638 |
}
|
|
|
df4638 |
#endif
|
|
|
df4638 |
|
|
|
df4638 |
+#ifdef HAVE_LIBSYSTEMD
|
|
|
df4638 |
+ /* We are ready to process incomming packets. Let's notify systemd */
|
|
|
df4638 |
+ sd_notifyf(0, "READY=1\n"
|
|
|
df4638 |
+ "STATUS=Dispatching packets...\n"
|
|
|
df4638 |
+ "MAINPID=%lu",
|
|
|
df4638 |
+ (unsigned long) getpid());
|
|
|
df4638 |
+#endif
|
|
|
df4638 |
+
|
|
|
df4638 |
/* Start dispatching packets and timeouts... */
|
|
|
df4638 |
dispatch();
|
|
|
df4638 |
|
|
|
df4638 |
diff --git a/server/dhcpd.c b/server/dhcpd.c
|
|
|
df4638 |
index 4aef16b..778ef8d 100644
|
|
|
df4638 |
--- a/server/dhcpd.c
|
|
|
df4638 |
+++ b/server/dhcpd.c
|
|
|
df4638 |
@@ -60,6 +60,10 @@ gid_t set_gid = 0;
|
|
|
df4638 |
struct class unknown_class;
|
|
|
df4638 |
struct class known_class;
|
|
|
df4638 |
|
|
|
df4638 |
+#ifdef HAVE_LIBSYSTEMD
|
|
|
df4638 |
+#include <systemd/sd-daemon.h>
|
|
|
df4638 |
+#endif
|
|
|
df4638 |
+
|
|
|
df4638 |
struct iaddr server_identifier;
|
|
|
df4638 |
int server_identifier_matched;
|
|
|
df4638 |
|
|
|
df4638 |
@@ -1057,6 +1061,14 @@ main(int argc, char **argv) {
|
|
|
df4638 |
/* Log that we are about to start working */
|
|
|
df4638 |
log_info("Server starting service.");
|
|
|
df4638 |
|
|
|
df4638 |
+#ifdef HAVE_LIBSYSTEMD
|
|
|
df4638 |
+ /* We are ready to process incomming packets. Let's notify systemd */
|
|
|
df4638 |
+ sd_notifyf(0, "READY=1\n"
|
|
|
df4638 |
+ "STATUS=Dispatching packets...\n"
|
|
|
df4638 |
+ "MAINPID=%lu",
|
|
|
df4638 |
+ (unsigned long) getpid());
|
|
|
df4638 |
+#endif
|
|
|
df4638 |
+
|
|
|
df4638 |
/*
|
|
|
df4638 |
* Receive packets and dispatch them...
|
|
|
df4638 |
* dispatch() will never return.
|
|
|
df4638 |
--
|
|
|
df4638 |
2.14.5
|
|
|
df4638 |
|