Changeset View
Changeset View
Standalone View
Standalone View
libexec/rc/rc.d/random
Show All 19 Lines | |||||
save_dev_random() | save_dev_random() | ||||
{ | { | ||||
oumask=`umask` | oumask=`umask` | ||||
umask 077 | umask 077 | ||||
for f ; do | for f ; do | ||||
debug "saving entropy to $f" | debug "saving entropy to $f" | ||||
dd if=/dev/random of="$f" bs=4096 count=1 status=none && | dd if=/dev/random of="$f" bs=4096 count=1 status=none && | ||||
chmod 600 "$f" | chmod 600 "$f" && | ||||
fsync "$f" "$(dirname "$f")" | |||||
done | done | ||||
umask ${oumask} | umask ${oumask} | ||||
} | } | ||||
feed_dev_random() | feed_dev_random() | ||||
{ | { | ||||
for f ; do | for f ; do | ||||
if [ -f "$f" -a -r "$f" -a -s "$f" ] ; then | if [ -f "$f" -a -r "$f" -a -s "$f" ] ; then | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | *) | ||||
case ${entropy_file_confirmed} in | case ${entropy_file_confirmed} in | ||||
'') | '') | ||||
warn 'write failed (read-only fs?)' | warn 'write failed (read-only fs?)' | ||||
;; | ;; | ||||
*) | *) | ||||
dd if=/dev/random of=${entropy_file_confirmed} \ | dd if=/dev/random of=${entropy_file_confirmed} \ | ||||
bs=4096 count=1 2> /dev/null || | bs=4096 count=1 2> /dev/null || | ||||
warn 'write failed (unwriteable file or full fs?)' | warn 'write failed (unwriteable file or full fs?)' | ||||
fsync "${entropy_file_confirmed}" \ | |||||
"$(dirname "${entropy_file_confirmed}")" \ | |||||
2> /dev/null | |||||
echo '.' | echo '.' | ||||
;; | ;; | ||||
esac | esac | ||||
umask ${oumask} | umask ${oumask} | ||||
;; | ;; | ||||
esac | esac | ||||
case ${entropy_boot_file:=/boot/entropy} in | case ${entropy_boot_file:=/boot/entropy} in | ||||
[Nn][Oo]) | [Nn][Oo]) | ||||
Show All 9 Lines | *) | ||||
case ${entropy_boot_file_confirmed} in | case ${entropy_boot_file_confirmed} in | ||||
'') | '') | ||||
warn 'write failed (read-only fs?)' | warn 'write failed (read-only fs?)' | ||||
;; | ;; | ||||
*) | *) | ||||
dd if=/dev/random of=${entropy_boot_file_confirmed} \ | dd if=/dev/random of=${entropy_boot_file_confirmed} \ | ||||
bs=4096 count=1 2> /dev/null || | bs=4096 count=1 2> /dev/null || | ||||
warn 'write failed (unwriteable file or full fs?)' | warn 'write failed (unwriteable file or full fs?)' | ||||
fsync "${entropy_boot_file_confirmed}" \ | |||||
"$(dirname "${entropy_boot_file_confirmed}")" \ | |||||
2> /dev/null | |||||
echo '.' | echo '.' | ||||
;; | ;; | ||||
esac | esac | ||||
umask ${oumask} | umask ${oumask} | ||||
;; | ;; | ||||
esac | esac | ||||
} | } | ||||
load_rc_config $name | load_rc_config $name | ||||
run_rc_command "$1" | run_rc_command "$1" |