chrony/backport-close-socket-in-helper-process.patch
2025-04-15 06:22:01 +00:00

58 lines
1.6 KiB
Diff

From 7196943f112c3087bcdf04d0106213a30d177a27 Mon Sep 17 00:00:00 2001
From: Miroslav Lichvar <mlichvar@redhat.com>
Date: Thu, 28 Nov 2024 14:45:23 +0100
Subject: [PATCH] nts: close socket in helper process on exit
Close the socket used for receiving helper requests before exit to avoid
another valgrind error.
Conflict:NA
Reference:https://github.com/mlichvar/chrony/commit/7196943f112c3087bcdf04d0106213a30d177a27
---
nts_ke_server.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/nts_ke_server.c b/nts_ke_server.c
index 6fe28be..6dd6251 100644
--- a/nts_ke_server.c
+++ b/nts_ke_server.c
@@ -702,7 +702,7 @@ key_timeout(void *arg)
/* ================================================== */
static void
-run_helper(uid_t uid, gid_t gid, int scfilter_level)
+run_helper(uid_t uid, gid_t gid, int scfilter_level, int sock_fd)
{
LOG_Severity log_severity;
@@ -729,10 +729,15 @@ run_helper(uid_t uid, gid_t gid, int scfilter_level)
if (scfilter_level != 0)
SYS_EnableSystemCallFilter(scfilter_level, SYS_NTSKE_HELPER);
+ SCH_AddFileHandler(sock_fd, SCH_FILE_INPUT, handle_helper_request, NULL);
+
SCH_MainLoop();
DEBUG_LOG("Helper exiting");
+ SCH_RemoveFileHandler(sock_fd);
+ close(sock_fd);
+
NKS_Finalise();
SCK_Finalise();
SYS_Finalise();
@@ -792,9 +797,8 @@ NKS_PreInitialise(uid_t uid, gid_t gid, int scfilter_level)
LOG_CloseParentFd();
SCK_CloseSocket(sock_fd1);
- SCH_AddFileHandler(sock_fd2, SCH_FILE_INPUT, handle_helper_request, NULL);
- run_helper(uid, gid, scfilter_level);
+ run_helper(uid, gid, scfilter_level, sock_fd2);
}
SCK_CloseSocket(sock_fd2);
--
2.33.0