Skip to content

Commit

Permalink
kernel-install: check machine ID
Browse files Browse the repository at this point in the history
Let's do at least a minimal check that the read machine ID is valid.

RHEL-only: feature

Related: RHEL-50672
  • Loading branch information
dtardon authored and github-actions[bot] committed Aug 1, 2024
1 parent 42330aa commit 09d24c0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/kernel-install/kernel-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,12 @@ if [ -z "$MACHINE_ID" ] && [ -f /etc/machine-info ]; then
fi
if [ -z "$MACHINE_ID" ] && [ -s /etc/machine-id ]; then
read -r MACHINE_ID </etc/machine-id
[ "$MACHINE_ID" = "uninitialized" ] && unset MACHINE_ID
if [ "$MACHINE_ID" = "uninitialized" ]; then
unset MACHINE_ID
elif [ {{ '${#MACHINE_ID}' }} -ne 32 ]; then
echo "Error: invalid machine-id $MACHINE_ID read from /etc/machine-id" >&2
exit 1
fi
[ -n "$MACHINE_ID" ] && \
log_verbose "machine-id $MACHINE_ID acquired from /etc/machine-id"
fi
Expand Down

0 comments on commit 09d24c0

Please sign in to comment.