summaryrefslogtreecommitdiffstats
path: root/etc/rc
diff options
context:
space:
mode:
authordougb <dougb@FreeBSD.org>2001-01-11 13:01:20 +0000
committerdougb <dougb@FreeBSD.org>2001-01-11 13:01:20 +0000
commited0bc299d087ff5da618344681310644e7401700 (patch)
tree6fc043516c0aa470d83378f1879f9a7cb9eee8cc /etc/rc
parent9213771385c22cde6b3f126a561bc3a8fe2de7b6 (diff)
downloadFreeBSD-src-ed0bc299d087ff5da618344681310644e7401700.zip
FreeBSD-src-ed0bc299d087ff5da618344681310644e7401700.tar.gz
Add a system to save entropy from /dev/random periodically so that
it can be used to reseed at boot time. This will greatly increase the chances that there will be sufficient entropy available at boot time to prevent long delays. For /etc/rc, remove the vmstat and iostat runs from the attempt to provide some cheesy randomness if the files fail, since those programs are dynamically linked, and ldd seems to want some randomness to do its magic. Guidance and parameters for this project were provided by Mark Murray, based on the requirements of the Yarrow algorithm. Some helpful suggestions for implementation (including the tip about iostat and vmstat) were provided by Sheldon Hearn. All blame for problems or mistakes is mine of course.
Diffstat (limited to 'etc/rc')
-rw-r--r--etc/rc36
1 files changed, 26 insertions, 10 deletions
diff --git a/etc/rc b/etc/rc
index d3db56a..3f9fba7 100644
--- a/etc/rc
+++ b/etc/rc
@@ -102,16 +102,34 @@ chkdepend NIS nis_client_enable portmap portmap_enable
# First pass at entropy recovery so the rebooting /dev/random can reseed.
#
+feed_dev_random() {
+ if [ -f "${1}" -a -r "${1}" -a -s "${1}" ]; then
+ echo "Using ${1} as an entropy file"
+ cat ${1} > /dev/random 2> /dev/random &&
+ entropy_reseeded=yes
+ fi
+}
+
case ${entropy_file} in
[Nn][Oo] | '')
;;
*)
if [ -w /dev/random ]; then
- if [ -f "${entropy_file}" -a -r "${entropy_file}" -a \
- -s "${entropy_file}" ]; then
- echo "Using ${entropy_file} as an entropy file"
- cat ${entropy_file} > /dev/random 2> /dev/random
- entropy_reseeded=yes
+ feed_dev_random "${entropy_file}"
+ fi
+ ;;
+esac
+
+case ${entropy_dir} in
+[Nn][Oo])
+ ;;
+*)
+ entropy_dir=${entropy_dir:-/.entropy}
+ if [ -d "${entropy_dir}" ]; then
+ if [ -w /dev/random ]; then
+ for seedfile in ${entropy_dir}/*; do
+ feed_dev_random "${seedfile}"
+ done
fi
fi
;;
@@ -219,20 +237,18 @@ yes)
if [ -w /dev/random ]; then
if [ -f "${entropy_file}" -a -r "${entropy_file}" -a \
-s "${entropy_file}" ]; then
- echo "Using ${entropy_file} as an entropy file"
- cat ${entropy_file} > /dev/random 2> /dev/random
+ feed_dev_random "${entropy_file}"
elif [ "${entropy_file}" != /var/db/entropy -a \
-f /var/db/entropy -a -r /var/db/entropy -a \
-s /var/db/entropy ]; then
- echo 'Using /var/db/entropy as an entropy file'
- cat /var/db/entropy > /dev/random 2> /dev/random
+ feed_dev_random /var/db/entropy
else
echo "Can't use ${entropy_file} as an entropy file, trying other sources"
# XXX temporary until we can get the entropy
# harvesting rate up
# Entropy below is not great,
# but better than nothing.
- (ps -gauxwww; iostat; vmstat; sysctl -a;
+ (ps -gauxwww; sysctl -a;
dmesg) | /bin/dd of=/dev/random bs=8k 2>/dev/null
( for i in /etc /var/run ; do
cd $i ; ls -al ; cat *
OpenPOWER on IntegriCloud