Skip to content

Commit 2c65f76

Browse files
committed
Add facts to note EFI status
1 parent 77628f6 commit 2c65f76

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

lib/facter/efi.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# _Description_
2+
#
3+
# Return true if system booted via EFI
4+
#
5+
if Facter.value(:kernel).downcase == "linux" then
6+
Facter.add("efi_enabled") do
7+
setcode do
8+
File.exist?('/sys/firmware/efi')
9+
end
10+
end
11+
end

lib/facter/secure_boot_enabled.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# _Description_
2+
#
3+
# Return true if system booted via uEFI Secure Boot
4+
#
5+
if Facter.value(:kernel).downcase == "linux" then
6+
Facter.add("secure_boot_enabled") do
7+
setcode do
8+
if File.exist?('/sys/firmware/efi')
9+
Dir.glob('/sys/firmware/efi/efivars/SecureBoot-*').each do | file |
10+
File.open(file, 'r') do | hexcode |
11+
hexcode.read(4)
12+
code = hexcode.read(16).unpack('H*').first.to_i
13+
if code == 1
14+
true
15+
else
16+
false
17+
end
18+
end
19+
end
20+
else
21+
false
22+
end
23+
end
24+
end
25+
end

0 commit comments

Comments
 (0)