rng-tools: only print the success message when initialize entropy sources
PATCH 1/1 rng-tools: only print the success message when initialize entropy sources
From: Mingli Yu <[email protected]>
There is below message when check rngd service status in qemu env.
[rdrand]: Initialization Failed
The complete service status as below in qemu env:
# systemctl status rngd
rngd.service - Hardware RNG Entropy Gatherer Daemon
Loaded: loaded (/lib/systemd/system/rngd.service; enabled; vendor preset: >
Active: active (running) since Tue 2020-02-25 05:08:11 UTC; 42min ago
Main PID: 133 (rngd)
Tasks: 2 (limit: 3591)
Memory: 1.0M
CGroup: /system.slice/rngd.service
`-133 /usr/sbin/rngd -f -r /dev/hwrng
Feb 25 05:08:14 qemux86-64 rngd[133]: Initializing available sources
Feb 25 05:08:14 qemux86-64 rngd[133]: [hwrng ]: Initialized
Feb 25 05:08:14 qemux86-64 rngd[133]: [rdrand]: Initialization Failed
Feb 25 05:08:14 qemux86-64 rngd[133]: [jitter]: Initializing AES buffer
Feb 25 05:08:31 qemux86-64 rngd[133]: [jitter]: Enabling JITTER rng support
Feb 25 05:08:39 qemux86-64 rngd[133]: [jitter]: Initialized
Warning: Journal has been rotated since unit was started. Log output is incomplThe message "[rdrand]: Initialization Failed" is misleading and also results in parselogs.ParseLogsTest.test_parselogs failed in do_testimage.
In fact, the message only indicates the rdrand entropy source initialized failed and it doesn't affect the rngd function. So improve to only print the message for the entropy sources which initialized successfully to avoid misleading users.
That makes sense as after check the available entropy sources, there is a logic to check whether there is at least one available entropy source exist as below in rngd.c
if (!ent_sources) { message(LOG_DAEMON|LOG_ERR,
"can't open any entropy source"); message(LOG_DAEMON|LOG_ERR,
"Maybe RNG device modules are not loaded\n"); return 1;
}
That's to say, only printing the message for the entropy sources which initialized successfully is safe.
--- ...-print-the-success-message-when-initializ.patch | 47 ++++++++++++++++++++++ meta/recipes-support/rng-tools/rng-tools_6.9.bb | 1 + 2 files changed, 48 insertions(+) create mode 100644 meta/recipes-support/rng-tools/rng-tools/0001-rngd.c-only-print-the-success-message-when-initializ.patch
meta/recipes-support/rng-tools/rng-tools/0001-rngd.c-only-print-the-success-message-when-initializ.patch new file +47 -0
@@ -0,0 +1,47 @@ +From 820d7fc8477b690803f9640452ce6df2f3eb6a79 Mon Sep 17 00:00:00 2001 +From: Mingli Yu <[email protected]> +Date: Fri, 28 Feb 2020 02:39:53 +0000 +Subject: [PATCH] rngd.c: only print the success message when initialize + +Only print the message for the entropy sources which +initialized successfully to avoid misleading users. + +That makes sense as after check the available entropy +sources, there is logic to check whether there is at +least one available entropy source exist as below: +if (!ent_sources) { + message(LOG_DAEMON|LOG_ERR, + "can't open any entropy source"); + message(LOG_DAEMON|LOG_ERR, + "Maybe RNG device modules are not loaded\n"); + return 1; +} + +That's to say, only printing the message for the entropy +sources which initialized successfully is safe. + +Upstream-Status: Submitted [https://github.com/nhorman/rng-tools/pull/84] + +Signed-off-by: Mingli Yu <[email protected]> +--- + rngd.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/rngd.c b/rngd.c +index d8cd9af..78dae36 100644 +--- a/rngd.c ++++ b/rngd.c +@@ -795,9 +795,8 @@ int main(int argc, char **argv) + ent_sources++; + ent_src->fipsctx = malloc(sizeof(fips_ctx_t)); + fips_init(ent_src->fipsctx, discard_initial_data(ent_src)); +- message_entsrc(ent_src, LOG_DAEMON|LOG_INFO, "Initialized\n"); ++ message_entsrc(ent_src, LOG_DAEMON|LOG_INFO, "Initialized successfully\n"); + } else { +- message_entsrc(ent_src, LOG_DAEMON|LOG_ERR, "Initialization Failed\n"); + ent_src->disabled = true; + } + } +-- +2.24.1 +
meta/recipes-support/rng-tools/rng-tools_6.9.bb +1 -0
@@ -10,6 +10,7 @@ DEPENDS = "sysfsutils" SRC_URI = "\ git://github.com/nhorman/rng-tools.git \ + file://0001-rngd.c-only-print-the-success-message-when-initializ.patch \ file://init \ file://default \ file://rngd.service \
Signature · 1 line
2.7.4
Quoted 5 lines · On Fri, 2020-02-28 at 12:20 +0800, [email protected] wrote:
From: Mingli Yu <[email protected]>
There is below message when check rngd service status in qemu env.
[rdrand]: Initialization Failed
It looks like upstream aren't keen on the patch and I'm not sure we'd want to carry it. Whitelist this "error" instead?
Cheers,
Richard