Skip to content

Commit

Permalink
sysutils/py-salt: fix the efi grain on FreeBSD
Browse files Browse the repository at this point in the history
The logic to detect whether we booted from EFI only worked on Linux and
Apple, AFAICT.
  • Loading branch information
asomers authored and dwoz committed Dec 16, 2023
1 parent a87238e commit 1aff516
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions salt/grains/extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,25 @@ def __secure_boot(efivars_dir):

def uefi():
"""Populate UEFI grains."""
efivars_dir = next(
filter(os.path.exists, ["/sys/firmware/efi/efivars", "/sys/firmware/efi/vars"]),
None,
)
grains = {
"efi": bool(efivars_dir),
"efi-secure-boot": __secure_boot(efivars_dir) if efivars_dir else False,
}
if salt.utils.platform.is_freebsd():
grains = {
"efi": os.path.exists("/dev/efi"),
# Needs a contributor with a secure boot system to implement this
# part.
"efi-secure-boot": False,
}
else:
# Works on Linux and Apple ?
efivars_dir = next(
filter(
os.path.exists, ["/sys/firmware/efi/efivars", "/sys/firmware/efi/vars"]
),
None,
)
grains = {
"efi": bool(efivars_dir),
"efi-secure-boot": __secure_boot(efivars_dir) if efivars_dir else False,
}

return grains

Expand Down

0 comments on commit 1aff516

Please sign in to comment.