diff options
Diffstat (limited to 'etc')
-rw-r--r-- | etc/rc.d/initdiskless | 1 | ||||
-rw-r--r-- | etc/rc.d/preseedrandom | 47 | ||||
-rw-r--r-- | etc/rc.initdiskless | 1 |
3 files changed, 49 insertions, 0 deletions
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 |