aboutsummaryrefslogtreecommitdiff
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
parent56148d60ddc1838afe9dafd90f18dd7aca758420 (diff)
Store the defined random pool size, #177722 thanks to Yaroslav Isakov.
-rw-r--r--ChangeLog1
-rwxr-xr-xinit.d/hostname2
-rwxr-xr-xinit.d/local3
-rwxr-xr-xinit.d/rmnologin3
-rwxr-xr-xinit.d/urandom19
5 files changed, 18 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 25ff2c0c..3de66a3e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
11 May 2007; Roy Marples <uberlord@gentoo.org>:
+ Store the defined random pool size, #177722 thanks to Yaroslav Isakov.
Use auto for /mnt/cdrom, #177990.
Use clock MONOTONIC to timeout, not localtime, #177514.
diff --git a/init.d/hostname b/init.d/hostname
index 86eb989a..4e804520 100755
--- a/init.d/hostname
+++ b/init.d/hostname
@@ -17,4 +17,4 @@ start() {
eend $? "Failed to set the hostname"
}
-# vim: ts=4 :
+# vim: set ts=4 :
diff --git a/init.d/local b/init.d/local
index 4e4c265c..77d02668 100755
--- a/init.d/local
+++ b/init.d/local
@@ -30,5 +30,4 @@ stop() {
eend $? $"Failed to stop local"
}
-
-# vim:ts=4
+# vim: set ts=4 :
diff --git a/init.d/rmnologin b/init.d/rmnologin
index 56b20ea1..0c1691f7 100755
--- a/init.d/rmnologin
+++ b/init.d/rmnologin
@@ -12,5 +12,4 @@ start() {
fi
}
-
-# vim:ts=4
+# vim: set ts=4 :
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 :