aboutsummaryrefslogtreecommitdiff
path: root/init.d/urandom
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-05-11 10:33:49 +0000
committerRoy Marples <roy@marples.name>2007-05-11 10:33:49 +0000
commit81ccc674462dea1609664f0b887c5729dac9ba6d (patch)
treed236be845de7ba2f28c0b5ee6b1176e35a5a90e6 /init.d/urandom
parent56148d60ddc1838afe9dafd90f18dd7aca758420 (diff)
Store the defined random pool size, #177722 thanks to Yaroslav Isakov.
Diffstat (limited to 'init.d/urandom')
-rwxr-xr-xinit.d/urandom19
1 files changed, 14 insertions, 5 deletions
diff --git a/init.d/urandom b/init.d/urandom
index a09153a5..b901d6d8 100755
--- a/init.d/urandom
+++ b/init.d/urandom
@@ -6,6 +6,17 @@ depend() {
need localmount
}
+save_seed() {
+ local poolsize=1
+
+ if [ -e /proc/sys/kernel/random/poolsize ] ; then
+ poolsize=$(($(cat /proc/sys/kernel/random/poolsize) / 4096))
+ fi
+
+ umask 077
+ dd if=/dev/urandom of=/var/run/random-seed count=${poolsize} 2>/dev/null
+}
+
start() {
[ -c /dev/urandom ] || return
if [ -f /var/run/random-seed ] ; then
@@ -16,8 +27,7 @@ start() {
return 0
fi
ebegin "Initializing random number generator"
- umask 077
- dd if=/dev/urandom of=/var/run/random-seed count=1 2>/dev/null
+ save_seed
eend $? "Error initializing random number generator"
umask 022
}
@@ -26,9 +36,8 @@ stop() {
ebegin "Saving random seed"
# Carry a random seed from shut-down to start-up;
# see documentation in linux/drivers/char/random.c
- umask 077
- dd if=/dev/urandom of=/var/run/random-seed count=1 2>/dev/null
+ save_seed
eend $? "Failed to save random seed"
}
-# vim:ts=4
+# vim: set ts=4 :