From 5ba6f20e07cd479774bfe57f96ca671ca9f67d88 Mon Sep 17 00:00:00 2001 From: brooks Date: Thu, 15 Apr 2004 17:52:53 +0000 Subject: 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 --- etc/rc.d/initdiskless | 1 + etc/rc.d/preseedrandom | 47 +++++++++++++++++++++++++++++++++++++++++++++++ etc/rc.initdiskless | 1 + 3 files changed, 49 insertions(+) create mode 100644 etc/rc.d/preseedrandom (limited to 'etc') diff --git a/etc/rc.d/initdiskless b/etc/rc.d/initdiskless index b84dab9..47ab3ec 100644 --- a/etc/rc.d/initdiskless +++ b/etc/rc.d/initdiskless @@ -26,6 +26,7 @@ # # $FreeBSD$ # +# REQUIRE: preseedrandom # PROVIDE: initdiskless # KEYWORD: FreeBSD nojail 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 diff --git a/etc/rc.initdiskless b/etc/rc.initdiskless index b84dab9..47ab3ec 100644 --- a/etc/rc.initdiskless +++ b/etc/rc.initdiskless @@ -26,6 +26,7 @@ # # $FreeBSD$ # +# REQUIRE: preseedrandom # PROVIDE: initdiskless # KEYWORD: FreeBSD nojail -- cgit v1.1