Not setting hostname results in `.localhost.local` in STHostName EFI var
The hostname to be written to the STHostName EFI variable is set like this:
optHostName = fmt.Sprintf("%s.%s", optHostName, options.DefHostname)
if optFullHostName != "" {
optHostName = optFullHostName
}
The variable options.DefHostname is by default localhost.local. The Makefile by default also sets it to the same value, except it comes from a confusingly named variable DEFAULT_DOMAIN=localhost.local, which of course can be overridden.
So if user does not pass -h, the resulting hostname will be .localhost.local. This is perhaps not ideal.
A small fix to avoid the issue caused by not passing -h could be to instead:
if optHostName == "" {
optHostName = options.DefHostname
} else {
optHostName = fmt.Sprintf("%s.%s", optHostName, options.DefHostname)
}
if optFullHostName != "" {
optHostName = optFullHostName
}
But, it might also be that the intention of options.DefHostname from the beginning was to contain a domain name, to be unconditionally added to the (non-FQDN) hostname passed by the user using -h. The DEFAULT_DOMAIN could indicate that, along with the -H option for setting optFullHostName (a FQDN) which, if set, goes into optHostName without any suffix.
It is a bit confusing.