Skip to content

Commit

Permalink
Merge pull request #2650 from mhashizume/FACT-3452/main/amazon-cloud
Browse files Browse the repository at this point in the history
(FACT-3452) Make Xen resolver more strict
  • Loading branch information
joshcooper authored Dec 6, 2023
2 parents d81e711 + a11f4f8 commit 352e2a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/facter/resolvers/xen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def detect_xen(fact_name)

def detect_xen_type
xen_type = 'xen0' if File.exist?('/dev/xen/evtchn')
xen_type = 'xenu' if !xen_type && (File.exist?('/proc/xen') || File.exist?('/dev/xvda1'))
if !xen_type && (File.exist?('/proc/xen') || (File.exist?('/dev/xvda1') && !File.symlink?('/dev/xvda1')))
xen_type = 'xenu'
end

xen_type
end
Expand Down
12 changes: 12 additions & 0 deletions spec/facter/resolvers/xen_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,16 @@
expect(xen_resolver.resolve(:domains)).to be_nil
end
end

context 'when /dev/xvda1 is a symlink' do
let(:evtchn_file) { false }

before do
allow(File).to receive(:symlink?).with('/dev/xvda1').and_return(true)
end

it 'returns nil' do
expect(xen_resolver.resolve(:vm)).to be_nil
end
end
end

0 comments on commit 352e2a8

Please sign in to comment.