81_urandom_seed 703 B

123456789101112131415161718192021222324
  1. #!/bin/sh
  2. log_urandom_seed() {
  3. echo "urandom-seed: $1" > /dev/kmsg
  4. }
  5. _do_urandom_seed() {
  6. [ -f "$1" ] || { log_urandom_seed "Seed file not found ($1)"; return; }
  7. [ -O "$1" -a -G "$1" -a ! -x "$1" ] || { log_urandom_seed "Wrong owner / permissions for $1"; return; }
  8. log_urandom_seed "Seeding with $1"
  9. cat "$1" > /dev/urandom
  10. }
  11. do_urandom_seed() {
  12. [ -c /dev/urandom ] || { log_urandom_seed "Something is wrong with /dev/urandom"; return; }
  13. _do_urandom_seed "/etc/urandom.seed"
  14. SEED="$(uci -q get system.@system[0].urandom_seed)"
  15. [ "${SEED:0:1}" == "/" -a "$SEED" != "/etc/urandom.seed" ] && _do_urandom_seed "$SEED"
  16. }
  17. boot_hook_add preinit_main do_urandom_seed