Skip to content

Commit 0ad90fe

Browse files
committed
Handle case where facter is run as a non-root user
1 parent 17a3f4f commit 0ad90fe

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

lib/facter/esx_version.rb

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,31 @@
1010
if File::executable?("/usr/sbin/dmidecode")
1111
result = Facter::Util::Resolution.exec("/usr/sbin/dmidecode 2>&1")
1212
if result
13-
bios_address = /^BIOS Information$.+?Address: (0x[0-9A-F]{5})$/m.match(result)[1]
13+
begin
14+
bios_address = /^BIOS Information$.+?Address: (0x[0-9A-F]{5})$/m.match(result)[1]
1415

15-
case bios_address
16-
when '0xE8480'
17-
'2.5'
18-
when '0xE7C70'
19-
'3.0'
20-
when '0xE7910'
21-
'3.5'
22-
when '0xEA6C0'
23-
'4'
24-
when '0xEA550'
25-
'4 update 1'
26-
when '0xEA2E0'
27-
'4.1'
28-
when '0xE72C0'
29-
'5'
30-
when '0xEA0C0'
31-
'5.1'
32-
else
33-
"unknown, please report #{bios_address}"
16+
case bios_address
17+
when '0xE8480'
18+
'2.5'
19+
when '0xE7C70'
20+
'3.0'
21+
when '0xE7910'
22+
'3.5'
23+
when '0xEA6C0'
24+
'4'
25+
when '0xEA550'
26+
'4 update 1'
27+
when '0xEA2E0'
28+
'4.1'
29+
when '0xE72C0'
30+
'5'
31+
when '0xEA0C0'
32+
'5.1'
33+
else
34+
"unknown, please report #{bios_address}"
35+
end
36+
rescue
37+
'n/a'
3438
end
3539
end
3640
end

0 commit comments

Comments
 (0)