Band-aid diskless booting by running a new preseedrandom script before

initdiskless.  The output of several commands and if available the
contents of /entropy are feed into /dev/random to kickstart the PRNG.
/etc/rc.d/initrandom is left alone to maintain the previous behavior as
much as possiable.

Further work in this area is probably needed.

Discussed with:	markm
This commit is contained in:
Brooks Davis 2004-04-15 17:52:53 +00:00
parent d13851aa7a
commit 6ea20e1c98
3 changed files with 49 additions and 0 deletions

View File

@ -26,6 +26,7 @@
#
# $FreeBSD$
#
# REQUIRE: preseedrandom
# PROVIDE: initdiskless
# KEYWORD: FreeBSD nojail

47
etc/rc.d/preseedrandom Normal file
View File

@ -0,0 +1,47 @@
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: preseedrandom
# KEYWORD: FreeBSD nojail
feed_dev_random()
{
if [ -f "${1}" -a -r "${1}" -a -s "${1}" ]; then
cat "${1}" | dd of=/dev/random bs=8k 2>/dev/null
fi
}
entropy_file="/entropy"
soft_random_generator=`sysctl kern.random 2>/dev/null`
if [ -n "${soft_random_generator}" ] ; then
echo -n 'Pre-seeding PRNG:'
# XXX temporary until we can improve the entropy
# harvesting rate.
# Entropy below is not great, but better than nothing.
# This unblocks the generator at startup
( ps -fauxww; sysctl -a; date; df -ib; dmesg; ps -fauxww; ) \
| dd of=/dev/random bs=8k 2>/dev/null
cat /bin/ls | dd of=/dev/random bs=8k 2>/dev/null
# First pass at reseeding /dev/random.
#
case ${entropy_file} in
[Nn][Oo] | '')
;;
*)
if [ -w /dev/random ]; then
feed_dev_random "${entropy_file}"
fi
;;
esac
echo -n ' kickstart'
echo '.'
fi

View File

@ -26,6 +26,7 @@
#
# $FreeBSD$
#
# REQUIRE: preseedrandom
# PROVIDE: initdiskless
# KEYWORD: FreeBSD nojail