git: cc495d3b679d - main - rc.d/hostid: Skip warning on systems w/o smbios
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 13 Aug 2022 22:58:28 UTC
The branch main has been updated by cperciva:
URL: https://cgit.FreeBSD.org/src/commit/?id=cc495d3b679d32324d8914adb10e293e7deae82b
commit cc495d3b679d32324d8914adb10e293e7deae82b
Author: Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2022-08-12 23:48:26 +0000
Commit: Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2022-08-13 22:58:16 +0000
rc.d/hostid: Skip warning on systems w/o smbios
The first time a FreeBSD system boots, it obtains a hostuuid and hostid
from the smbios.system.uuid kernel environment variable. If this value
is found to be invalid, a warning is printed and the boot pauses for
two seconds to give the user a chance to read it.
If the FreeBSD kernel is launched directly in a virtual machine rather
than via the FreeBSD boot loader, the smbios.system.uuid environment
variable might not be set; in this case, there's no need to alert the
user and delay the boot process since the lack of a "hardware" uuid is
entirely expected.
Distinguish between the cases of "invalid UUID" and "no UUID", warning
and delaying the boot only in the former case. In both cases we still
generate a random UUID in software.
Reviewed by: delphij
Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D36185
---
libexec/rc/rc.d/hostid | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/libexec/rc/rc.d/hostid b/libexec/rc/rc.d/hostid
index 39a0f4acb498..494e4aba84e1 100755
--- a/libexec/rc/rc.d/hostid
+++ b/libexec/rc/rc.d/hostid
@@ -106,6 +106,8 @@ hostid_hardware()
if valid_hostid $uuid; then
echo "${uuid}"
+ elif [ "$uuid" ]; then
+ echo "INVALID"
fi
}
@@ -113,9 +115,16 @@ hostid_generate()
{
# First look for UUID in hardware.
uuid=`hostid_hardware`
- if [ -z "${uuid}" ]; then
+
+ # Warn about invalid UUIDs
+ if [ "${uuid}" = "INVALID" ]; then
warn "hostid: unable to figure out a UUID from DMI data, generating a new one"
sleep 2
+ uuid=""
+ fi
+
+ # Generate a random UUID if invalid or not found
+ if [ -z "${uuid}" ]; then
# If not found, fall back to software-generated UUID.
uuid=`uuidgen`
fi