]> git.pld-linux.org Git - packages/dhcp.git/blob - systemd-notify.patch
4f7407595f751d6c8add62c44e93456a462ecb0b
[packages/dhcp.git] / systemd-notify.patch
1 From 8d974fd1f667e1b957ad4092fe66a8bb94f5f8fd 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 1/1] Add missed sd notify patch to manage dhcpd with systemd
5 Cc: pzhukov@redhat.com
6
7 ---
8  configure.ac     | 11 +++++++++++
9  relay/dhcrelay.c | 12 ++++++++++++
10  server/dhcpd.c   | 12 ++++++++++++
11  3 files changed, 35 insertions(+)
12
13 diff --git a/configure.ac b/configure.ac
14 index 15fc0d7..0c08000 100644
15 --- a/configure.ac
16 +++ b/configure.ac
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])
19  fi
20  
21 +AC_ARG_WITH(systemd,
22 +        AC_HELP_STRING([--with-systemd],
23 +                       [enable sending status notifications to systemd daemon (default is no)]),
24 +        [systemd=$withval],
25 +        [systemd=no])
26 +
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?]))
30 +fi
31 +
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
39 @@ -37,6 +37,10 @@
40  #include <sys/time.h>
41  #include <isc/file.h>
42  
43 +#ifdef HAVE_LIBSYSTEMD
44 +#include <systemd/sd-daemon.h>
45 +#endif
46 +
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) {
51         signal(SIGTERM, dhcp_signal_handler);  /* kill */
52  #endif
53  
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"
58 +                   "MAINPID=%lu",
59 +                   (unsigned long) getpid());
60 +#endif
61 +
62         /* Start dispatching packets and timeouts... */
63         dispatch();
64  
65 diff --git a/server/dhcpd.c b/server/dhcpd.c
66 index 4aef16b..778ef8d 100644
67 --- a/server/dhcpd.c
68 +++ b/server/dhcpd.c
69 @@ -60,6 +60,10 @@ gid_t set_gid = 0;
70  struct class unknown_class;
71  struct class known_class;
72  
73 +#ifdef HAVE_LIBSYSTEMD
74 +#include <systemd/sd-daemon.h>
75 +#endif
76 +
77  struct iaddr server_identifier;
78  int server_identifier_matched;
79  
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.");
83  
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"
88 +                   "MAINPID=%lu",
89 +                   (unsigned long) getpid());
90 +#endif
91 +
92         /*
93          * Receive packets and dispatch them...
94          * dispatch() will never return.
95 -- 
96 2.14.5
97
This page took 0.135878 seconds and 2 git commands to generate.