freebsd-dev/etc/rc.d/preseedrandom
David E. O'Brien 1a32b4cbcf Back out rev 1.3.
This is one of the few RC scripts that doesn't use rc.subr, and thus
doesn't source rc.conf. :-(
2004-06-08 19:53:25 +00:00

40 lines
806 B
Bash

#!/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
}
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.
#
if [ -w /dev/random ]; then
feed_dev_random "/entropy"
fi
echo -n ' kickstart'
echo '.'
fi