Skip to content

Commit af386f9

Browse files
authored
Merge pull request #2620 from jonathannewman/maint/main/dont-deref-nil
(FACT-3441) improve reliability of uname resolver
2 parents 482f6a5 + 25edad7 commit af386f9

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/facter/resolvers/uname.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,16 @@ def uname_system_call(fact_name)
2828
def build_fact_list(output)
2929
uname_results = output.split("\n")
3030

31-
@fact_list[:machine] = uname_results[0].strip
32-
@fact_list[:nodename] = uname_results[1].strip
33-
@fact_list[:processor] = uname_results[2].strip
34-
@fact_list[:kernelrelease] = uname_results[3].strip
35-
@fact_list[:kernelname] = uname_results[4].strip
36-
@fact_list[:kernelversion] = uname_results[5].strip
31+
if !uname_results.empty?
32+
@fact_list[:machine],
33+
@fact_list[:nodename],
34+
@fact_list[:processor],
35+
@fact_list[:kernelrelease],
36+
@fact_list[:kernelname],
37+
@fact_list[:kernelversion] = uname_results.map(&:strip)
38+
else
39+
log.warn('Request to uname returned no output. Uname related facts are not populated.')
40+
end
3741
end
3842
end
3943
end

0 commit comments

Comments
 (0)