feat: add urandom seed as source for machine-id generation

This commit is contained in:
wpetit 2023-03-06 13:09:32 +01:00
parent 7724b2b922
commit 260a9b4fae
1 changed files with 2 additions and 1 deletions

View File

@ -13,12 +13,13 @@ main() {
# Accumulate data to create unique machine id
local mac_addresses=$(cat /sys/class/net/*/address | uniq | sort)
local device_model=$(cat /sys/firmware/devicetree/base/model)
local urandom_seed=$(cat /etc/urandom.seed | sha256sum | cut -d ' ' -f1)
# Ensure destination directory
mkdir -p "$(dirname "$machine_id_file")"
# Generate SHA256 hash of data and save it to $machine_id_file
echo "$mac_adresses $device_model" | sha256sum | cut -d ' ' -f1 > "$machine_id_file"
echo "$mac_adresses $device_model $urandom_seed" | sha256sum | cut -d ' ' -f1 > "$machine_id_file"
}
main