1
0
mirror of https://git.openwrt.org/feed/packages.git synced 2024-06-14 11:23:57 +02:00
openwrt-packages/utils/rng-tools/files/rngd.init
Philip Prindeville 3d4048bd9f rng-tools: start rngd early enough to actually be useful
lighttpd starts at priority 50, but promptly calls getrandom() on
initialization (li_rand_reseed() and li_rand_device_bytes() from
server_init()). If /dev/urandom (which getrandom() uses by default)
doesn't have sufficient entropy, this will block.

Since Openwrt runs the startup scripts serially, this can block
initialization indefinitely.  I've seen 15-20 minutes typically.

Seeding the pool early on can quickly built sufficient entropy to
complete booting without blocking.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
(cherry picked from commit 901ef617c7)
2017-02-03 12:52:51 +02:00

27 lines
640 B
Bash

#!/bin/sh /etc/rc.common
# Copyright (C) 2011-2014 OpenWrt.org
START=25
USE_PROCD=1
PROG=/sbin/rngd
start_service() {
local enabled=$(uci -q get system.@rngd[0].enabled)
local precmd=$(uci -q get system.@rngd[0].precmd)
local device=$(uci -q get system.@rngd[0].device)
local watermark=$(uci -q get system.@rngd[0].fill_watermark)
[ "$enabled" = "1" ] || return
[ -z "$precmd" ] || ${precmd} ${device}
[ -z "$device" ] || device="-r ${device}"
[ -z "$watermark" ] || watermark="-W ${watermark}"
procd_open_instance
procd_set_param command "$PROG" -f ${device} ${watermark}
procd_set_param stderr 1
procd_close_instance
}