summaryrefslogtreecommitdiffstats
path: root/etc/rc.d/postrandom
blob: 006d56342fe85a61f42b17061d23ba46b60053ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE: postrandom
# REQUIRE: initrandom random FILESYSTEMS
# BEFORE: LOGIN
# KEYWORD: nojail

. /etc/rc.subr

name="postrandom"
start_cmd="${name}_start"
stop_cmd=":"

# This will remove old ${entropy_file} and generate a new one.
# According to Bruce Schneier, this is strongly recommended in order
# to avoid using same ${entropy_file} across reboots.
# Reference: Chapter 10.6, Practical Cryptography, ISBN: 0-471-22357-3

postrandom_start()
{
	/etc/rc.d/random fastsaveseed

	case ${entropy_dir} in
	[Nn][Oo])
		;;
	*)
		entropy_dir=${entropy_dir:-/var/db/entropy}
		if [ -d "${entropy_dir}" ]; then
			if [ -w /dev/random ]; then
				rm -f ${entropy_dir}/*
			fi
		fi
		;;
	esac
}

load_rc_config random
run_rc_command "$1"
OpenPOWER on IntegriCloud