]>
Commit | Line | Data |
---|---|---|
530cba5e SS |
1 | From 5c6204bab7279050b78b3d03d1211e9d13d3fd71 Mon Sep 17 00:00:00 2001 |
2 | From: Pavel Zhukov <pzhukov@redhat.com> | |
3 | Date: Wed, 27 Mar 2019 09:59:20 +0100 | |
4 | Subject: [PATCH] Backport sd-notify patch for systemd support (#1687040) | |
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; | |
d8feb2d7 SS |
18 | AC_SUBST(LDAP_CFLAGS, [$LDAP_CFLAGS]) |
19 | fi | |
530cba5e | 20 | |
d8feb2d7 SS |
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" | |
530cba5e SS |
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 | |
d8feb2d7 SS |
39 | @@ -37,6 +37,10 @@ |
40 | int keep_capabilities = 0; | |
41 | #endif | |
530cba5e | 42 | |
d8feb2d7 SS |
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]; | |
530cba5e SS |
50 | @@ -845,6 +849,14 @@ main(int argc, char **argv) { |
51 | } | |
d8feb2d7 | 52 | #endif |
530cba5e | 53 | |
d8feb2d7 SS |
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 | + | |
530cba5e SS |
62 | /* Start dispatching packets and timeouts... */ |
63 | dispatch(); | |
64 | ||
65 | diff --git a/server/dhcpd.c b/server/dhcpd.c | |
66 | index 530a923..e06f6b4 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 | ||
d8feb2d7 SS |
73 | +#ifdef HAVE_LIBSYSTEMD |
74 | +#include <systemd/sd-daemon.h> | |
75 | +#endif | |
76 | + | |
77 | struct iaddr server_identifier; | |
78 | int server_identifier_matched; | |
530cba5e SS |
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 | ||
d8feb2d7 SS |
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 | + | |
530cba5e SS |
92 | /* |
93 | * Receive packets and dispatch them... | |
94 | * dispatch() will never return. | |
95 | -- | |
96 | 2.14.5 |