From 02b720e951160f652b0744f679d57623b81b1d8f Mon Sep 17 00:00:00 2001 From: Neil Horman Date: Mon, 2 Dec 2019 11:35:16 -0500 Subject: [PATCH 2/2] Add reserved option value to not change write_wakeup_threshold several distributions use a separate single shot service to set the write_wakeup_threashold, which allows for non-root users to run rngd. This results in a warning however, when rngd attempts to write the write_wakeup_threshold. Avoid this by allowing a reserved value, 0 for the fill-watermark option that causes rngd to just not touch the write_wakeup_threshold Signed-off-by: Neil Horman --- rngd.8.in | 4 +++- rngd_linux.c | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/rngd.8.in b/rngd.8.in index 181f35d..16a359a 100644 --- a/rngd.8.in +++ b/rngd.8.in @@ -106,7 +106,9 @@ if the entropy pool size couldn't be determined. Setting this too high will cause \fIrngd\fR to dominate the contents of the entropy pool. Low values will hurt system performance during entropy starves. Do not set \fIfill-watermark\fR above the size of the -entropy pool (usually 4096 bits). +entropy pool (usually 4096 bits). A value of 0 to this option will cause no +watermark to be set. + .TP \fB\-q\fR, \fB\-\-quiet\fR Suppress all messages diff --git a/rngd_linux.c b/rngd_linux.c index 51c38ac..9e60088 100644 --- a/rngd_linux.c +++ b/rngd_linux.c @@ -94,6 +94,9 @@ void init_kernel_rng(const char* randomdev) randomdev, strerror(errno)); exit(EXIT_USAGE); } + /* Don't set the watermark if the watermark is zero */ + if (!arguments->fill_watermark) + return; f = fopen("/proc/sys/kernel/random/write_wakeup_threshold", "w"); if (!f) { @@ -105,7 +108,7 @@ void init_kernel_rng(const char* randomdev) } if (err) { message(LOG_DAEMON|LOG_WARNING, - "unable to adjust write_wakeup_threshold: %s", + "unable to adjust write_wakeup_threshold: %s\n", strerror(errno)); } -- 2.21.0