[arch-projects] [RFC initscripts 25/29] Add functions for random seed handling

Tom Gundersen teg at jklm.no
Fri May 18 19:25:24 EDT 2012


On Fri, May 18, 2012 at 6:22 PM, Matthew Monaco <dgbaley27 at 0x01b.net> wrote:
> From: Matthew Monaco <matthew.monaco at 0x01b.net>
>
> The differences compared to the existing inline implementation are:
>
>  - can use cat again for loading
>  - the calculated pool size can be local
>  - quote file names... can't hurt

Looks good. We might end up moving to the systemd implementation of
these things if Dave packages "systemd-tools" or something like that,
but I'm happy to take this for the time being.

> ---
>  functions |   21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
>
> diff --git a/functions b/functions
> index fd20349..b1dd5c1 100644
> --- a/functions
> +++ b/functions
> @@ -506,6 +506,27 @@ bootlogd_stop() {
>                  -e 's/\^\[(\[1?[0-9][0-9]|%)G//g' -e 's/\^\[\[0;1//g'  /var/log/boot
>  }
>
> +RANDOM_SEED=/var/lib/misc/random-seed
> +RANDOM_POOL_FILE=/proc/sys/kernel/random/poolsize
> +
> +load_random_seed() {
> +       if [[ -f "$RANDOM_SEED" ]]; then
> +               cat "$RANDOM_SEED" > /dev/urandom
> +       fi
> +}
> +
> +store_random_seed() {
> +       local pool_size
> +       install -TDm 0600 /dev/null "$RANDOM_SEED"
> +       if [[ -r "$RANDOM_POOL_FILE" ]]; then
> +               read pool_size < "$RANDOM_POOL_FILE"
> +               (( pool_size /= 8 ))
> +       else
> +               pool_size=512
> +       fi
> +       dd if=/dev/urandom of="$RANDOM_SEED" count=1 bs=$pool_size &> /dev/null
> +}
> +
>  ###############################
>  # Custom hooks in initscripts #
>  ###############################
> --
> 1.7.10.2
>


More information about the arch-projects mailing list