This file is indexed.

/usr/lib/ruby/vendor_ruby/specinfra/host_inventory/virtualization.rb is in ruby-specinfra 2.66.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
module Specinfra
  class HostInventory
    class Virtualization < Base
      def get
        res = {}
        ## docker 
        if backend.run_command('ls /.dockerinit').success?
          res[:system] = 'docker'
          return res
        end

        ## OpenVZ on Linux 
        if backend.run_command('test -d /proc/vz -a ! -d /proc/bc').success?
          res[:system] = 'openvz'
          return res
        end

        cmd = backend.command.get(:get_inventory_system_product_name)
        ret = backend.run_command(cmd)
        if ret.exit_status == 0
           res[:system] = parse_system_product_name(ret.stdout)   
           return res
        end

        ret = backend.run_command('systemd-detect-virt')
        if ret.success?
          res[:system] = parse_systemd_detect_virt_output(ret.stdout)
        end

        res 
      end 

      def parse_system_product_name(ret)
        product_name = case ret
          when /.*VMware Virtual Platform/
            'vmware'
          when /.*VirtualBox/
            'vbox'
          when /.*KVM/
            'kvm'
          when /.*OpenStack/
            'openstack'
          else
            nil
        end
        product_name
      end

      def parse_systemd_detect_virt_output(ret)
        detected = ret.strip

        case detected
        when 'vmware', 'kvm'
          detected
        when 'oracle'
          'vbox'
        end
      end

    end
  end
end