diff options
author | brooks <brooks@FreeBSD.org> | 2004-04-15 17:52:53 +0000 |
---|---|---|
committer | brooks <brooks@FreeBSD.org> | 2004-04-15 17:52:53 +0000 |
commit | 5ba6f20e07cd479774bfe57f96ca671ca9f67d88 (patch) | |
tree | df7d2a8525837950bebb3648bfcb875b13893024 /etc/rc.d/preseedrandom | |
parent | cc363f9f35fbc60cd86cd107ee3e40b017d84053 (diff) | |
download | FreeBSD-src-5ba6f20e07cd479774bfe57f96ca671ca9f67d88.zip FreeBSD-src-5ba6f20e07cd479774bfe57f96ca671ca9f67d88.tar.gz |
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
Diffstat (limited to 'etc/rc.d/preseedrandom')
-rw-r--r-- | etc/rc.d/preseedrandom | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/etc/rc.d/preseedrandom b/etc/rc.d/preseedrandom new file mode 100644 index 0000000..ecbfc3c --- /dev/null +++ b/etc/rc.d/preseedrandom @@ -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 |