1239569Sobrien#!/bin/sh
2239569Sobrien#
3239569Sobrien# $FreeBSD$
4239569Sobrien#
5239569Sobrien
6239569Sobrien# PROVIDE: postrandom
7240336Sobrien# REQUIRE: initrandom random FILESYSTEMS
8239569Sobrien# BEFORE: LOGIN
9239569Sobrien# KEYWORD: nojail
10239569Sobrien
11239569Sobrien. /etc/rc.subr
12239569Sobrien
13239569Sobrienname="postrandom"
14239569Sobrienstart_cmd="${name}_start"
15239569Sobrienstop_cmd=":"
16239569Sobrien
17239569Sobrien# This will remove old ${entropy_file} and generate a new one.
18239596Sobrien# According to Bruce Schneier, this is strongly recommended in order
19239569Sobrien# to avoid using same ${entropy_file} across reboots.
20239596Sobrien# Reference: Chapter 10.6, Practical Cryptography, ISBN: 0-471-22357-3
21239569Sobrien
22239569Sobrienpostrandom_start()
23239569Sobrien{
24239569Sobrien	/etc/rc.d/random fastsaveseed
25239569Sobrien
26239569Sobrien	case ${entropy_dir} in
27239569Sobrien	[Nn][Oo])
28239569Sobrien		;;
29239569Sobrien	*)
30239569Sobrien		entropy_dir=${entropy_dir:-/var/db/entropy}
31239569Sobrien		if [ -d "${entropy_dir}" ]; then
32239569Sobrien			if [ -w /dev/random ]; then
33239569Sobrien				rm -f ${entropy_dir}/*
34239569Sobrien			fi
35239569Sobrien		fi
36239569Sobrien		;;
37239569Sobrien	esac
38239569Sobrien}
39239569Sobrien
40239569Sobrienload_rc_config random
41239569Sobrienrun_rc_command "$1"
42