diff mbox series

[OpenWrt-Devel] urngd: Fix entropy provider daemon

Message ID 00a3c4d681d3fa8ebfd15446df08643de5eb1adf.1579615562.git.cristian.ciocaltea@gmail.com
State Accepted
Delegated to: Petr Štetiar
Headers show
Series [OpenWrt-Devel] urngd: Fix entropy provider daemon | expand

Commit Message

Cristian Ciocaltea Jan. 21, 2020, 2:43 p.m. UTC
From: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>

The OpenWrt Jitter RNG daemon is currently unable to continuously
provide entropy, except once on process startup.

This patch brings the following fixes:
- poll /dev/random for unblocking write operations, instead of read
- register the low entropy callback after uloop initialization, not
  before

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
---
 urngd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Petr Štetiar Jan. 21, 2020, 4:18 p.m. UTC | #1
Cristian Ciocaltea <cristian.ciocaltea@gmail.com> [2020-01-21 16:43:24]:

Hi,

> This patch brings the following fixes:
> - poll /dev/random for unblocking write operations, instead of read
> - register the low entropy callback after uloop initialization, not
>   before

nice find, thanks! I'm going to push urngd 1.0.2 with your fixes soon.

-- ynezz
diff mbox series

Patch

diff --git a/urngd.c b/urngd.c
index d8ed159..91dc72c 100644
--- a/urngd.c
+++ b/urngd.c
@@ -180,7 +180,7 @@  static bool urngd_init(struct urngd *u)
 		return false;
 	}
 
-	uloop_fd_add(&u->rnd_fd, ULOOP_READ);
+	uloop_fd_add(&u->rnd_fd, ULOOP_WRITE);
 
 	return true;
 }
@@ -227,6 +227,7 @@  int main(int argc, char **argv)
 
 	ulog_open(ulog_channels, LOG_DAEMON, "urngd");
 
+	uloop_init();
 	if (!urngd_init(&urngd_service))
 		return -1;
 
@@ -234,7 +235,6 @@  int main(int argc, char **argv)
 
 	gather_entropy(&urngd_service);
 
-	uloop_init();
 	uloop_run();
 	uloop_done();