Skip to content

Commit

Permalink
Add facts to note EFI status
Browse files Browse the repository at this point in the history
  • Loading branch information
jcpunk committed Sep 15, 2020
1 parent 77628f6 commit 7e71bb7
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ See [REFERENCE.md](./REFERENCE.md) for all other reference documentation.
hash
* **defaultgateway** - Return the default gateway of the system
* **defaultgatewayiface** - Return the default gw interface of the system
* **efi_enabled** - Returns true if the system is using EFI
* **fips_ciphers** - Returns a list of available OpenSSL ciphers
* **fips_enabled** - Determine whether FIPS is enabled on this system
* **fullrun** - Determine whether to do an intensive run
Expand All @@ -91,6 +92,7 @@ See [REFERENCE.md](./REFERENCE.md) for all other reference documentation.
* **root_dir_uuid** - Return the UUID of the partition holding the
`/` directory
* **runlevel** - Return the current system runlevel
* **secure_boot_enabled** - Returns true if the host is using uEFI Secure Boot
* **shmall** - Return the value of shmall from sysctl
* **simplib__firewalls** - Return an array of known firewall commands that
are present on the system.
Expand Down
11 changes: 11 additions & 0 deletions lib/facter/efi.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# _Description_
#
# Return true if system booted via EFI
#
if Facter.value(:kernel).downcase == "linux" then
Facter.add("efi_enabled") do
setcode do
File.exist?('/sys/firmware/efi')
end
end
end
25 changes: 25 additions & 0 deletions lib/facter/secure_boot_enabled.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# _Description_
#
# Return true if system booted via uEFI Secure Boot
#
if Facter.value(:kernel).downcase == "linux" then
Facter.add("secure_boot_enabled") do
setcode do
if File.exist?('/sys/firmware/efi')
Dir.glob('/sys/firmware/efi/efivars/SecureBoot-*').each do | file |
File.open(file, 'r') do | hexcode |
hexcode.read(4)
code = hexcode.read(16).unpack('H*').first.to_i
if code == 1
true
else
false
end
end
end
else
false
end
end
end
end

0 comments on commit 7e71bb7

Please sign in to comment.