summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authordougb <dougb@FreeBSD.org>2001-01-14 07:18:31 +0000
committerdougb <dougb@FreeBSD.org>2001-01-14 07:18:31 +0000
commit3bbfa62b632ebcb309e75f8212f4e3b53797cadf (patch)
tree9ecc11560468f3c002fda7f43b66439a52c6bb8a /libexec
parent41bf790205da9df94e6c6fe700cefca81250363d (diff)
downloadFreeBSD-src-3bbfa62b632ebcb309e75f8212f4e3b53797cadf.zip
FreeBSD-src-3bbfa62b632ebcb309e75f8212f4e3b53797cadf.tar.gz
Move the process of storing entropy from /dev/random and reseeding with
it at boot time closer to the way we want it to be in the final version. * Move the default directory to /var/db/entropy * Run the entropy saving cron job every 11 minutes. This seems to be a better default, although still bikeshed material. * Feed /dev/random some cheesy "entropy" from various commands and files before the disks are mounted. This gives /dev/random a better chance of running without blocking early. * Move the reseeding with previously stored entropy to the point immediately after the disks are mounted. * Make the harvesting script a little safer in regards to the possibility of accidentally overwriting something other than a regular file.
Diffstat (limited to 'libexec')
-rwxr-xr-xlibexec/save-entropy/save-entropy.sh30
1 files changed, 20 insertions, 10 deletions
diff --git a/libexec/save-entropy/save-entropy.sh b/libexec/save-entropy/save-entropy.sh
index 4a84fd7..82b96ca 100755
--- a/libexec/save-entropy/save-entropy.sh
+++ b/libexec/save-entropy/save-entropy.sh
@@ -29,6 +29,8 @@
# This script is called by cron to store bits of randomness which are
# then used to seed /dev/random on boot.
+# Originally developed by Doug Barton, DougB@FreeBSD.org
+
PATH=/bin:/usr/bin
# If there is a global system configuration file, suck it in.
@@ -45,33 +47,41 @@ case ${entropy_dir} in
exit 0
;;
*)
- entropy_dir=${entropy_dir:-/.entropy}
+ entropy_dir=${entropy_dir:-/var/db/entropy}
;;
esac
entropy_save_sz=${entropy_save_sz:-2048}
entropy_save_num=${entropy_save_num:-8}
-entropy_save_jot=$(($entropy_save_num - 1))
if [ ! -d "${entropy_dir}" ]; then
umask 077
mkdir "${entropy_dir}" || {
- logger -is The entropy directory "${entropy_dir}" does not \
+ logger -is -t "$0" The entropy directory "${entropy_dir}" does not \
exist, and cannot be created. Therefore no entropy can be saved. ;
exit 1;}
/usr/sbin/chown operator:operator "${entropy_dir}"
chmod 0700 "${entropy_dir}"
fi
-rm -f "${entropy_dir}/saved-entropy.${entropy_save_num}"
-
umask 377
-for file_num in `jot ${entropy_save_jot} ${entropy_save_jot} 1`; do
- if [ -f "${entropy_dir}/saved-entropy.${file_num}" ]; then
- new_num=$(($file_num + 1))
- mv "${entropy_dir}/saved-entropy.${file_num}" \
- "${entropy_dir}/saved-entropy.${new_num}"
+for file_num in `jot ${entropy_save_num} ${entropy_save_num} 1`; do
+ if [ -e "${entropy_dir}/saved-entropy.${file_num}" ]; then
+ if [ -f "${entropy_dir}/saved-entropy.${file_num}" ]; then
+ new_num=$(($file_num + 1))
+ if [ "${new_num}" -gt "${entropy_save_num}" ]; then
+ rm -f "${entropy_dir}/saved-entropy.${file_num}"
+ else
+ mv "${entropy_dir}/saved-entropy.${file_num}" \
+ "${entropy_dir}/saved-entropy.${new_num}"
+ fi
+ else
+ logger -is -t "$0" \
+"${entropy_dir}/saved-entropy.${file_num} is not a regular file, and therefore \
+it will not be rotated. Entropy file harvesting is aborted."
+ exit 1
+ fi
fi
done
OpenPOWER on IntegriCloud