From 1fd243ff308f27504dae10e3b2c999e65b6bd102 Mon Sep 17 00:00:00 2001 From: Martin Osvald Date: Sun, 7 Dec 2025 13:28:14 +0100 Subject: [PATCH] Support for sending startup notifications to systemd II Added sd_notifyf() to the remaining daemons ddns and control agent. Resolves: RHEL-127724 --- kea-ctrl-agent.service | 1 + kea-dhcp-ddns.service | 1 + kea-sd-daemon.patch | 108 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 108 insertions(+), 2 deletions(-) diff --git a/kea-ctrl-agent.service b/kea-ctrl-agent.service index 249cc8f..e60a7bd 100644 --- a/kea-ctrl-agent.service +++ b/kea-ctrl-agent.service @@ -6,6 +6,7 @@ After=network-online.target After=time-sync.target [Service] +Type=notify User=kea Environment="KEA_PIDFILE_DIR=/run/kea" Environment="KEA_LOCKFILE_DIR=/run/kea" diff --git a/kea-dhcp-ddns.service b/kea-dhcp-ddns.service index 2f58a51..bacbd0e 100644 --- a/kea-dhcp-ddns.service +++ b/kea-dhcp-ddns.service @@ -6,6 +6,7 @@ After=network-online.target After=time-sync.target [Service] +Type=notify User=kea AmbientCapabilities=CAP_NET_BIND_SERVICE Environment="KEA_PIDFILE_DIR=/run/kea" diff --git a/kea-sd-daemon.patch b/kea-sd-daemon.patch index a3a9ea0..f059e87 100644 --- a/kea-sd-daemon.patch +++ b/kea-sd-daemon.patch @@ -36,7 +36,7 @@ index 42ccf28..cc6354a 100644 #mesondefine LIBC_MUSL diff --git a/meson.build b/meson.build -index 66e7fd0..dc86d89 100644 +index 8ed5b2d..df4f125 100644 --- a/meson.build +++ b/meson.build @@ -100,6 +100,7 @@ krb5_opt = get_option('krb5') @@ -61,7 +61,7 @@ index 66e7fd0..dc86d89 100644 # Google Test GTEST_DEP = dependency( 'gtest', -@@ -867,6 +875,11 @@ else +@@ -886,6 +894,11 @@ else report_conf_data.set('SYSREPOCPP_VERSION', 'no') report_conf_data.set('SYSREPOCPP_PREFIX', 'no') endif @@ -85,6 +85,110 @@ index 5c222d5..3ecd2e1 100644 # Options for enabling testing code (not real features). option( +diff --git a/src/bin/agent/ca_process.cc b/src/bin/agent/ca_process.cc +index f01dd97..4793067 100644 +--- a/src/bin/agent/ca_process.cc ++++ b/src/bin/agent/ca_process.cc +@@ -18,6 +18,10 @@ + #include + #include + ++#ifdef HAVE_LIBSYSTEMD_DAEMON ++#include ++#endif ++ + using namespace isc::asiolink; + using namespace isc::config; + using namespace isc::data; +@@ -42,7 +46,15 @@ CtrlAgentProcess::init() { + + void + CtrlAgentProcess::run() { ++ + LOG_INFO(agent_logger, CTRL_AGENT_STARTED).arg(VERSION); ++#ifdef HAVE_LIBSYSTEMD_DAEMON ++ // Notify systemd about the same ++ sd_notifyf(0, "READY=1\n" ++ "STATUS=Processing requests...\n" ++ "MAINPID=%lu", ++ (unsigned long) getpid()); ++#endif + + LOG_WARN(agent_logger, CTRL_AGENT_IS_DEPRECATED); + +diff --git a/src/bin/agent/meson.build b/src/bin/agent/meson.build +index c6afbfa..2d30179 100644 +--- a/src/bin/agent/meson.build ++++ b/src/bin/agent/meson.build +@@ -1,3 +1,8 @@ ++kea_ctrl_agent_dependencies = [CRYPTO_DEP] ++if SYSTEMD_DEP.found() ++ kea_ctrl_agent_dependencies += [SYSTEMD_DEP] ++endif ++ + agent_lib = static_library( + 'agent', + 'agent_lexer.cc', +@@ -17,7 +22,7 @@ agent_lib = static_library( + executable( + 'kea-ctrl-agent', + 'main.cc', +- dependencies: [CRYPTO_DEP], ++ dependencies: kea_ctrl_agent_dependencies, + include_directories: [include_directories('.')] + INCLUDES, + install: true, + install_dir: SBINDIR, +diff --git a/src/bin/d2/d2_process.cc b/src/bin/d2/d2_process.cc +index 7db49a3..cdb9cef 100644 +--- a/src/bin/d2/d2_process.cc ++++ b/src/bin/d2/d2_process.cc +@@ -21,6 +21,10 @@ + #include + #include + ++#ifdef HAVE_LIBSYSTEMD_DAEMON ++#include ++#endif ++ + using namespace isc::asiolink; + using namespace isc::config; + using namespace isc::data; +@@ -95,6 +99,13 @@ D2Process::init() { + void + D2Process::run() { + LOG_INFO(d2_logger, DHCP_DDNS_STARTED).arg(VERSION); ++#ifdef HAVE_LIBSYSTEMD_DAEMON ++ // Notify systemd about the same ++ sd_notifyf(0, "READY=1\n" ++ "STATUS=Dispatching packets...\n" ++ "MAINPID=%lu", ++ (unsigned long) getpid()); ++#endif + + if (!PathChecker::shouldEnforceSecurity()) { + LOG_WARN(d2_logger, DHCP_DDNS_SECURITY_CHECKS_DISABLED); +diff --git a/src/bin/d2/meson.build b/src/bin/d2/meson.build +index 012b40d..3aff0c1 100644 +--- a/src/bin/d2/meson.build ++++ b/src/bin/d2/meson.build +@@ -1,3 +1,8 @@ ++kea_ddns_dependencies = [CRYPTO_DEP] ++if SYSTEMD_DEP.found() ++ kea_ddns_dependencies += [SYSTEMD_DEP] ++endif ++ + d2_lib = static_library( + 'd2', + 'check_exists_add.cc', +@@ -21,7 +26,7 @@ d2_lib = static_library( + executable( + 'kea-dhcp-ddns', + 'main.cc', +- dependencies: [CRYPTO_DEP], ++ dependencies: kea_ddns_dependencies, + include_directories: [include_directories('.')] + INCLUDES, + install: true, + install_dir: SBINDIR, diff --git a/src/bin/dhcp4/main.cc b/src/bin/dhcp4/main.cc index 4f88e29..5581b7a 100644 --- a/src/bin/dhcp4/main.cc