3 # $FreeBSD: src/etc/rc.d/random,v 1.3 2003/04/18 17:55:05 mtm Exp $
7 # REQUIRE: diskless mountcritlocal initrandom
14 start_cmd
="random_start"
15 stop_cmd
="random_stop"
19 if [ -f "${1}" -a -r "${1}" -a -s "${1}" ]; then
20 ${SYSCTL_W} kern.seedenable
=1 >/dev
/null
21 # Feed using a small block size so that a pool-based CSPRNG
22 # is more likely to distribute the entropy over several
24 cat "${1}" |
dd of
=/dev
/random bs
=512 2>/dev
/null
25 ${SYSCTL_W} kern.seedenable
=0 >/dev
/null
31 # Reseed /dev/random with previously stored entropy.
32 case ${entropy_dir} in
36 entropy_dir
=${entropy_dir:-/var/db/entropy}
37 if [ -d "${entropy_dir}" ]; then
38 if [ -w /dev
/random
]; then
39 for seedfile
in ${entropy_dir}/*; do
40 feed_dev_random
"${seedfile}"
47 case ${entropy_file} in
51 if [ -w /dev
/random
]; then
52 feed_dev_random
"${entropy_file}"
60 # Write some entropy so when the machine reboots /dev/random
63 case ${entropy_file} in
67 echo -n 'Writing entropy file:'
71 if touch ${entropy_file}; then
72 entropy_file_confirmed
="${entropy_file}"
74 case ${entropy_file_confirmed} in
76 err
1 '${entropy_file}:' \
77 ' entropy file write failed.'
80 dd if=/dev
/random of
=${entropy_file_confirmed} \
81 bs
=${entropy_save_sz} count
=1 2> /dev
/null