0027-Add-missed-sd-notify-patch-to-manage-dhcpd-with-syst.patch 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. From d1b1f91a7982be28acdfb580996c93aafcc76cc2 Mon Sep 17 00:00:00 2001
  2. From: Pavel Zhukov <pzhukov@redhat.com>
  3. Date: Thu, 7 Nov 2019 14:47:45 +0100
  4. Subject: [PATCH 27/28] Add missed sd notify patch to manage dhcpd with systemd
  5. ---
  6. configure.ac | 11 +++++++++++
  7. relay/dhcrelay.c | 12 ++++++++++++
  8. server/dhcpd.c | 12 ++++++++++++
  9. 3 files changed, 35 insertions(+)
  10. Index: dhcp-4.4.3/configure.ac+lt
  11. ===================================================================
  12. --- dhcp-4.4.3.orig/configure.ac+lt
  13. +++ dhcp-4.4.3/configure.ac+lt
  14. @@ -983,6 +983,17 @@ if test x$ldap = xyes || test x$ldapcryp
  15. AC_SUBST(LDAP_CFLAGS, [$LDAP_CFLAGS])
  16. fi
  17. +AC_ARG_WITH(systemd,
  18. + AC_HELP_STRING([--with-systemd],
  19. + [enable sending status notifications to systemd daemon (default is no)]),
  20. + [systemd=$withval],
  21. + [systemd=no])
  22. +
  23. +if test x$systemd = xyes ; then
  24. + AC_CHECK_LIB(systemd, sd_notifyf, ,
  25. + AC_MSG_FAILURE([*** systemd library not present - do you need to install systemd-libs package?]))
  26. +fi
  27. +
  28. # Append selected warning levels to CFLAGS before substitution (but after
  29. # AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[],[]) & etc).
  30. CFLAGS="$CFLAGS $STD_CWARNINGS"
  31. Index: dhcp-4.4.3/relay/dhcrelay.c
  32. ===================================================================
  33. --- dhcp-4.4.3.orig/relay/dhcrelay.c
  34. +++ dhcp-4.4.3/relay/dhcrelay.c
  35. @@ -32,6 +32,10 @@
  36. #include <sys/time.h>
  37. #include <isc/file.h>
  38. +#ifdef HAVE_LIBSYSTEMD
  39. +#include <systemd/sd-daemon.h>
  40. +#endif
  41. +
  42. TIME default_lease_time = 43200; /* 12 hours... */
  43. TIME max_lease_time = 86400; /* 24 hours... */
  44. struct tree_cache *global_options[256];
  45. @@ -840,6 +844,14 @@ main(int argc, char **argv) {
  46. signal(SIGTERM, dhcp_signal_handler); /* kill */
  47. #endif
  48. +#ifdef HAVE_LIBSYSTEMD
  49. + /* We are ready to process incomming packets. Let's notify systemd */
  50. + sd_notifyf(0, "READY=1\n"
  51. + "STATUS=Dispatching packets...\n"
  52. + "MAINPID=%lu",
  53. + (unsigned long) getpid());
  54. +#endif
  55. +
  56. /* Start dispatching packets and timeouts... */
  57. dispatch();
  58. Index: dhcp-4.4.3/server/dhcpd.c
  59. ===================================================================
  60. --- dhcp-4.4.3.orig/server/dhcpd.c
  61. +++ dhcp-4.4.3/server/dhcpd.c
  62. @@ -60,6 +60,10 @@ gid_t set_gid = 0;
  63. struct class unknown_class;
  64. struct class known_class;
  65. +#ifdef HAVE_LIBSYSTEMD
  66. +#include <systemd/sd-daemon.h>
  67. +#endif
  68. +
  69. struct iaddr server_identifier;
  70. int server_identifier_matched;
  71. @@ -1057,6 +1061,14 @@ main(int argc, char **argv) {
  72. /* Log that we are about to start working */
  73. log_info("Server starting service.");
  74. +#ifdef HAVE_LIBSYSTEMD
  75. + /* We are ready to process incomming packets. Let's notify systemd */
  76. + sd_notifyf(0, "READY=1\n"
  77. + "STATUS=Dispatching packets...\n"
  78. + "MAINPID=%lu",
  79. + (unsigned long) getpid());
  80. +#endif
  81. +
  82. /*
  83. * Receive packets and dispatch them...
  84. * dispatch() will never return.