mirror of
				https://git.openwrt.org/openwrt/openwrt.git
				synced 2025-11-04 11:39:46 +00:00 
			
		
		
		
	This reverts commit 2edc017a6e.
We shouldn't be using a shell script here, but the SeedRNG integration
into OpenWRT requires a bit more thought. Etienne raised some important
points immediately after this was merged and planned to send some follow
up commits, but became busy with other things. The points he raised are
important enough that we should actually back this out until it's ready
to go, and then merge it as a cohesive unit. So let's revert this for
now, and come back to it later on.
Cc: Etienne Champetier <champetier.etienne@gmail.com>
Cc: Petr Štetiar <ynezz@true.cz>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
		
	
		
			
				
	
	
		
			21 lines
		
	
	
		
			397 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			397 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/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
 |