summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2004-04-15 17:52:53 +0000
committerbrooks <brooks@FreeBSD.org>2004-04-15 17:52:53 +0000
commit5ba6f20e07cd479774bfe57f96ca671ca9f67d88 (patch)
treedf7d2a8525837950bebb3648bfcb875b13893024 /etc
parentcc363f9f35fbc60cd86cd107ee3e40b017d84053 (diff)
downloadFreeBSD-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')
-rw-r--r--etc/rc.d/initdiskless1
-rw-r--r--etc/rc.d/preseedrandom47
-rw-r--r--etc/rc.initdiskless1
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
OpenPOWER on IntegriCloud