2013-12-22 02:21:11 +05:30
|
|
|
#!@SBINDIR@/openrc-run
|
2022-03-25 09:37:16 +05:30
|
|
|
# Copyright (c) 2007-2022 The OpenRC Authors.
|
2015-12-05 04:22:19 +05:30
|
|
|
# See the Authors file at the top-level directory of this distribution and
|
2021-12-21 06:37:00 +05:30
|
|
|
# https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS
|
2015-12-05 04:22:19 +05:30
|
|
|
#
|
|
|
|
# This file is part of OpenRC. It is subject to the license terms in
|
|
|
|
# the LICENSE file found in the top-level directory of this
|
2021-12-21 06:37:00 +05:30
|
|
|
# distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE
|
2015-12-05 04:22:19 +05:30
|
|
|
# This file may not be copied, modified, propagated, or distributed
|
|
|
|
# except according to the terms contained in the LICENSE file.
|
2007-11-14 20:52:04 +05:30
|
|
|
|
2022-03-25 09:37:16 +05:30
|
|
|
export SEEDRNG_SEED_DIR="${seed_dir:-/var/lib/seedrng}"
|
|
|
|
export SEEDRNG_LOCK_FILE="${lock_file:-/var/run/seedrng.lock}"
|
|
|
|
export SEEDRNG_SKIP_CREDIT="${skip_credit:-false}"
|
|
|
|
: ${urandom_seed:=${SEEDRNG_SEED_DIR}/../misc/random-seed}
|
2007-07-11 00:39:41 +05:30
|
|
|
description="Initializes the random number generator."
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
depend()
|
|
|
|
{
|
2017-03-16 20:46:39 +05:30
|
|
|
after clock
|
2007-04-05 16:48:42 +05:30
|
|
|
need localmount
|
2016-07-31 23:31:17 +05:30
|
|
|
keyword -docker -jail -lxc -openvz -prefix -systemd-nspawn
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
save_seed()
|
|
|
|
{
|
2007-06-22 08:27:40 +05:30
|
|
|
( # sub shell to prevent umask pollution
|
|
|
|
umask 077
|
2022-03-25 09:37:16 +05:30
|
|
|
dd if=/dev/urandom of="$urandom_seed" count=1 2>/dev/null
|
2007-06-22 08:27:40 +05:30
|
|
|
)
|
2007-05-11 16:03:49 +05:30
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
start()
|
|
|
|
{
|
2022-03-25 09:37:16 +05:30
|
|
|
if [ "$RC_UNAME" = Linux ]; then
|
|
|
|
seedrng
|
|
|
|
else
|
|
|
|
[ -c /dev/urandom ] || return
|
|
|
|
if [ -f "$urandom_seed" ]; then
|
|
|
|
ebegin "Initializing random number generator"
|
|
|
|
cat "$urandom_seed" > /dev/urandom
|
|
|
|
eend $? "Error initializing random number generator"
|
|
|
|
fi
|
|
|
|
rm -f "$urandom_seed" && save_seed
|
2007-04-05 16:48:42 +05:30
|
|
|
fi
|
2007-11-23 17:34:11 +05:30
|
|
|
return 0
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2008-01-11 17:43:46 +05:30
|
|
|
stop()
|
|
|
|
{
|
2022-03-25 09:37:16 +05:30
|
|
|
if [ "$RC_UNAME" = Linux ]; then
|
|
|
|
seedrng
|
|
|
|
else
|
|
|
|
ebegin "Saving random seed"
|
|
|
|
save_seed
|
|
|
|
eend $? "Failed to save random seed"
|
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|