diff options
author | Petr Štetiar <ynezz@true.cz> | 2019-05-20 16:38:33 +0200 |
---|---|---|
committer | Petr Štetiar <ynezz@true.cz> | 2019-06-11 08:06:28 +0200 |
commit | 27bfde9c9f789dbfabebf13047e8b042c27cdeef (patch) | |
tree | dc9c5f7d394cfb157755a7dde448653aa3166c24 /package/system/urandom-seed/files/sbin | |
parent | 9b4de712cae9b3d745ea4331a804242505f58619 (diff) | |
download | upstream-27bfde9c9f789dbfabebf13047e8b042c27cdeef.tar.gz upstream-27bfde9c9f789dbfabebf13047e8b042c27cdeef.tar.bz2 upstream-27bfde9c9f789dbfabebf13047e8b042c27cdeef.zip |
base-files: move urandom seed bits into separate package
So it's possible to install or remove it as needed.
Tested-by: Lucian Cristian <lucian.cristian@gmail.com>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
Diffstat (limited to 'package/system/urandom-seed/files/sbin')
-rwxr-xr-x | package/system/urandom-seed/files/sbin/urandom_seed | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/package/system/urandom-seed/files/sbin/urandom_seed b/package/system/urandom-seed/files/sbin/urandom_seed new file mode 100755 index 0000000000..7043e8af4e --- /dev/null +++ b/package/system/urandom-seed/files/sbin/urandom_seed @@ -0,0 +1,20 @@ +#!/bin/sh +set -e + +trap '[ "$?" -eq 0 ] || echo "An error occured" >&2' EXIT + +save() { + touch "$1.tmp" + chown root:root "$1.tmp" + chmod 600 "$1.tmp" + getrandom 512 > "$1.tmp" + mv "$1.tmp" "$1" + echo "Seed saved ($1)" +} + +SEED="$(uci -q get system.@system[0].urandom_seed || true)" +[ "${SEED:0:1}" = "/" ] && save "$SEED" + +SEED=/etc/urandom.seed +[ ! -f $SEED ] && save "$SEED" +true |