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