Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Nov 2014 09:24:33 +0000
From:      Mark R V Murray <mark@grondar.org>
To:        =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@FreeBSD.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r273957 - in head: . etc/rc.d
Message-ID:  <C65307B8-0CC1-4FC2-89E0-5B489748AD32@grondar.org>
In-Reply-To: <201411020147.sA21lRW0082695@svn.freebsd.org>
References:  <201411020147.sA21lRW0082695@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Nice move, thanks! :-)

M

> On 2 Nov 2014, at 01:47, Dag-Erling Sm=C3=B8rgrav <des@FreeBSD.org> =
wrote:
>=20
> Author: des
> Date: Sun Nov  2 01:47:27 2014
> New Revision: 273957
> URL: https://svnweb.freebsd.org/changeset/base/273957
>=20
> Log:
>  Get rid of the postrandom script.  It was born in a time when the
>  random script ran before filesystems were mounted, which is no
>  longer the case.
>=20
>  In random_start(), immediately delete each file that is fed into
>  /dev/random, and recreate the default entropy file immediately
>  after reading and deleting it.  The logic used in random_stop()
>  to determine which file to write to should probably be factored
>  out and used here as well.
>=20
> Deleted:
>  head/etc/rc.d/postrandom
> Modified:
>  head/ObsoleteFiles.inc
>  head/etc/rc.d/Makefile
>  head/etc/rc.d/adjkerntz
>  head/etc/rc.d/random
>=20
> Modified: head/ObsoleteFiles.inc
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
> --- head/ObsoleteFiles.inc	Sun Nov  2 01:13:11 2014	=
(r273956)
> +++ head/ObsoleteFiles.inc	Sun Nov  2 01:47:27 2014	=
(r273957)
> @@ -38,6 +38,8 @@
> #   xargs -n1 | sort | uniq -d;
> # done
>=20
> +# 20141102: postrandom obsoleted by new /dev/random code
> +OLD_FILES+=3Detc/rc.d/postrandom
> # 20141031: initrandom obsoleted by new /dev/random code
> OLD_FILES+=3Detc/rc.d/initrandom
> # 20141028: debug files accidentally installed as directory name
>=20
> Modified: head/etc/rc.d/Makefile
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
> --- head/etc/rc.d/Makefile	Sun Nov  2 01:13:11 2014	=
(r273956)
> +++ head/etc/rc.d/Makefile	Sun Nov  2 01:47:27 2014	=
(r273957)
> @@ -112,7 +112,6 @@ FILES=3D	DAEMON \
> 	pf \
> 	pflog \
> 	pfsync \
> -	postrandom \
> 	powerd \
> 	power_profile \
> 	ppp \
>=20
> Modified: head/etc/rc.d/adjkerntz
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
> --- head/etc/rc.d/adjkerntz	Sun Nov  2 01:13:11 2014	=
(r273956)
> +++ head/etc/rc.d/adjkerntz	Sun Nov  2 01:47:27 2014	=
(r273957)
> @@ -4,7 +4,7 @@
> #
>=20
> # PROVIDE: adjkerntz
> -# REQUIRE: FILESYSTEMS postrandom
> +# REQUIRE: FILESYSTEMS
> # BEFORE: netif
> # KEYWORD: nojail
>=20
>=20
> Modified: head/etc/rc.d/random
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
> --- head/etc/rc.d/random	Sun Nov  2 01:13:11 2014	=
(r273956)
> +++ head/etc/rc.d/random	Sun Nov  2 01:47:27 2014	=
(r273957)
> @@ -17,41 +17,58 @@ stop_cmd=3D"random_stop"
> extra_commands=3D"saveseed"
> saveseed_cmd=3D"${name}_stop"
>=20
> +save_dev_random()
> +{
> +	for f ; do
> +		if :>>"$f" ; then
> +			debug "saving entropy to $f"
> +			dd if=3D/dev/random of=3D"$f" bs=3D4096 count=3D1 =
2>/dev/null
> +		fi
> +	done
> +}
> +
> feed_dev_random()
> {
> -	if [ -f "${1}" -a -r "${1}" -a -s "${1}" ]; then
> -		cat "${1}" | dd of=3D/dev/random bs=3D8k 2>/dev/null
> -	fi
> +	for f ; do
> +		if [ -f "$f" -a -r "$f" -a -s "$f" ] ; then
> +			if dd if=3D"$f" of=3D/dev/random bs=3D4096 =
2>/dev/null ; then
> +				debug "entropy read from $f"
> +				rm -f "$f"
> +			fi
> +		fi
> +	done
> }
>=20
> random_start()
> {
> +	echo -n 'Feeding entropy:'
> +
> +	if [ ! -w /dev/random ] ; then
> +		warn "/dev/random is not writeable"
> +		return 1
> +	fi
> +
> 	# Reseed /dev/random with previously stored entropy.
> -	case ${entropy_dir} in
> +	case ${entropy_dir:=3D/var/db/entropy} in
> 	[Nn][Oo])
> 		;;
> 	*)
> -		entropy_dir=3D${entropy_dir:-/var/db/entropy}
> -		if [ -d "${entropy_dir}" ]; then
> -			if [ -w /dev/random ]; then
> -				for seedfile in ${entropy_dir}/*; do
> -					feed_dev_random "${seedfile}"
> -				done
> -			fi
> +		if [ -d "${entropy_dir}" ] ; then
> +			feed_dev_random "${entropy_dir}"/*
> 		fi
> 		;;
> 	esac
>=20
> -	case ${entropy_file} in
> +	case ${entropy_file:=3D/entropy} in
> 	[Nn][Oo] | '')
> 		;;
> 	*)
> -		if [ -w /dev/random ]; then
> -			feed_dev_random "${entropy_file}"
> -			feed_dev_random /var/db/entropy-file
> -		fi
> +		feed_dev_random "${entropy_file}" /var/db/entropy-file
> +		save_dev_random "${entropy_file}"
> 		;;
> 	esac
> +
> +	echo '.'
> }
>=20
> random_stop()
> @@ -59,7 +76,7 @@ random_stop()
> 	# Write some entropy so when the machine reboots /dev/random
> 	# can be reseeded
> 	#
> -	case ${entropy_file} in
> +	case ${entropy_file:=3D/entropy} in
> 	[Nn][Oo] | '')
> 		;;
> 	*)
>=20

--=20
Mark R V Murray




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C65307B8-0CC1-4FC2-89E0-5B489748AD32>