From 16ffa6d5b238bc0437919e2b5e4d381900692c8a Mon Sep 17 00:00:00 2001 From: Pavel Zhukov Date: Wed, 27 Mar 2019 10:03:09 +0100 Subject: [PATCH] readd sd_notify patch --- ...fy-patch-for-systemd-support-1687040.patch | 97 +++++++++++++++++++ dhcp.spec | 6 +- 2 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 0022-Backport-sd-notify-patch-for-systemd-support-1687040.patch diff --git a/0022-Backport-sd-notify-patch-for-systemd-support-1687040.patch b/0022-Backport-sd-notify-patch-for-systemd-support-1687040.patch new file mode 100644 index 0000000..2c9f46b --- /dev/null +++ b/0022-Backport-sd-notify-patch-for-systemd-support-1687040.patch @@ -0,0 +1,97 @@ +From 5c6204bab7279050b78b3d03d1211e9d13d3fd71 Mon Sep 17 00:00:00 2001 +From: Pavel Zhukov +Date: Wed, 27 Mar 2019 09:59:20 +0100 +Subject: [PATCH] Backport sd-notify patch for systemd support (#1687040) +Cc: pzhukov@redhat.com + +--- + configure.ac | 11 +++++++++++ + relay/dhcrelay.c | 12 ++++++++++++ + server/dhcpd.c | 12 ++++++++++++ + 3 files changed, 35 insertions(+) + +diff --git a/configure.ac b/configure.ac +index 15fc0d7..0c08000 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1014,6 +1014,17 @@ if test x$ldap = xyes || test x$ldapcrypto = xyes || test x$ldap_gssapi = xyes; + AC_SUBST(LDAP_CFLAGS, [$LDAP_CFLAGS]) + fi + ++AC_ARG_WITH(systemd, ++ AC_HELP_STRING([--with-systemd], ++ [enable sending status notifications to systemd daemon (default is no)]), ++ [systemd=$withval], ++ [systemd=no]) ++ ++if test x$systemd = xyes ; then ++ AC_CHECK_LIB(systemd, sd_notifyf, , ++ AC_MSG_FAILURE([*** systemd library not present - do you need to install systemd-libs package?])) ++fi ++ + # Append selected warning levels to CFLAGS before substitution (but after + # AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]) & etc). + CFLAGS="$CFLAGS $STD_CWARNINGS" +diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c +index 7b4f4f1..9eb5bfd 100644 +--- a/relay/dhcrelay.c ++++ b/relay/dhcrelay.c +@@ -37,6 +37,10 @@ + int keep_capabilities = 0; + #endif + ++#ifdef HAVE_LIBSYSTEMD ++#include ++#endif ++ + TIME default_lease_time = 43200; /* 12 hours... */ + TIME max_lease_time = 86400; /* 24 hours... */ + struct tree_cache *global_options[256]; +@@ -845,6 +849,14 @@ main(int argc, char **argv) { + } + #endif + ++#ifdef HAVE_LIBSYSTEMD ++ /* We are ready to process incomming packets. Let's notify systemd */ ++ sd_notifyf(0, "READY=1\n" ++ "STATUS=Dispatching packets...\n" ++ "MAINPID=%lu", ++ (unsigned long) getpid()); ++#endif ++ + /* Start dispatching packets and timeouts... */ + dispatch(); + +diff --git a/server/dhcpd.c b/server/dhcpd.c +index 530a923..e06f6b4 100644 +--- a/server/dhcpd.c ++++ b/server/dhcpd.c +@@ -60,6 +60,10 @@ gid_t set_gid = 0; + struct class unknown_class; + struct class known_class; + ++#ifdef HAVE_LIBSYSTEMD ++#include ++#endif ++ + struct iaddr server_identifier; + int server_identifier_matched; + +@@ -1057,6 +1061,14 @@ main(int argc, char **argv) { + /* Log that we are about to start working */ + log_info("Server starting service."); + ++#ifdef HAVE_LIBSYSTEMD ++ /* We are ready to process incomming packets. Let's notify systemd */ ++ sd_notifyf(0, "READY=1\n" ++ "STATUS=Dispatching packets...\n" ++ "MAINPID=%lu", ++ (unsigned long) getpid()); ++#endif ++ + /* + * Receive packets and dispatch them... + * dispatch() will never return. +-- +2.14.5 + diff --git a/dhcp.spec b/dhcp.spec index b7ca5ff..d95c455 100644 --- a/dhcp.spec +++ b/dhcp.spec @@ -15,7 +15,7 @@ Summary: Dynamic host configuration protocol software Name: dhcp Version: 4.4.1 -Release: 7%{?dist} +Release: 8%{?dist} # NEVER CHANGE THE EPOCH on this package. The previous maintainer (prior to # dcantrell maintaining the package) made incorrect use of the epoch and # that's why it is at 12 now. It should have never been used, but it was. @@ -54,6 +54,7 @@ Patch18: 0018-No-subnet-declaration-for-iface-should-be-info-not-e.patch Patch19: 0019-dhclient-write-DUID_LLT-even-in-stateless-mode-11563.patch Patch20: 0020-Discover-all-hwaddress-for-xid-uniqueness.patch Patch21: 0021-Load-leases-DB-in-non-replay-mode-only.patch +Patch22: 0022-Backport-sd-notify-patch-for-systemd-support-1687040.patch Obsoletes: dhcp-libs < 4.4 @@ -511,6 +512,9 @@ done %endif %changelog +* Wed Mar 27 2019 Pavel Zhukov - 12:4.4.1-8 +- Add sd_notify patch to support systemd notify (1687040) + * Mon Mar 18 2019 Pavel Zhukov - 12:4.4.1-7 - Provides specific version of libs