void-packages/srcpkgs/rng-tools/patches/rngd-test-signal-in-loop.patch

37 lines
1017 B
Diff

From: Leonardo Chiquitto <leonardo@ngdn.org>
Subject: Check for signals in update_kernel_random()
When running as a daemon, a signal handler is installed to catch
SIGINT/SIGTERM. This handler sets a flag that's tested in the main
loop. However, rngd loops in update_kernel_random() as well, where
the flag was not tested.
This patch adds the check to update_kernel_random() so that the
daemon exits properly after receiving a SIGINT/SIGTERM signal.
Index: rngd.c
===================================================================
--- rngd.c
+++ rngd.c
@@ -218,6 +218,8 @@ static int update_kernel_random(int rand
for (p = buf; p + random_step <= &buf[FIPS_RNG_BUFFER_SIZE];
p += random_step) {
+ if (!server_running)
+ return 0;
random_add_entropy(p, random_step);
random_sleep();
}
@@ -239,10 +241,10 @@ static void do_loop(int random_step)
{
int rc;
+ retry_same:
if (!server_running)
return;
- retry_same:
if (iter->disabled)
continue; /* failed, no work */