This file is indexed.

/usr/lib/ruby/vendor_ruby/ohai/plugins/linux/platform.rb is in ohai 6.14.0-2.

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
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
#
# Author:: Adam Jacob (<adam@opscode.com>)
# Copyright:: Copyright (c) 2008 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

def get_redhatish_platform(contents)
  contents[/^Red Hat/i] ? "redhat" : contents[/(\w+)/i, 1].downcase
end

def get_redhatish_version(contents)
  contents[/Rawhide/i] ? contents[/((\d+) \(Rawhide\))/i, 1].downcase : contents[/release ([\d\.]+)/, 1]
end

provides "platform", "platform_version", "platform_family"

require_plugin 'linux::lsb'

# platform [ and platform_version ? ] should be lower case to avoid dealing with RedHat/Redhat/redhat matching 
if File.exists?("/etc/oracle-release")
  contents = File.read("/etc/oracle-release").chomp
  platform "oracle"
  platform_version get_redhatish_version(contents)
elsif File.exists?("/etc/enterprise-release")
  contents = File.read("/etc/enterprise-release").chomp
  platform "oracle"
  platform_version get_redhatish_version(contents)
elsif File.exists?("/etc/debian_version")
  # Ubuntu and Debian both have /etc/debian_version
  # Ubuntu should always have a working lsb, debian does not by default
  if lsb[:id] =~ /Ubuntu/i
    platform "ubuntu"
    platform_version lsb[:release]
  else 
    platform "debian"
    platform_version File.read("/etc/debian_version").chomp
  end
elsif File.exists?("/etc/redhat-release")
  contents = File.read("/etc/redhat-release").chomp
  platform get_redhatish_platform(contents)
  platform_version get_redhatish_version(contents)
elsif File.exists?("/etc/system-release")
  contents = File.read("/etc/system-release").chomp
  platform get_redhatish_platform(contents)
  platform_version get_redhatish_version(contents)
elsif File.exists?('/etc/gentoo-release')
  platform "gentoo"
  platform_version File.read('/etc/gentoo-release').scan(/(\d+|\.+)/).join
elsif File.exists?('/etc/SuSE-release')
  platform "suse"
  platform_version File.read("/etc/SuSE-release").scan(/VERSION = (\d+)\nPATCHLEVEL = (\d+)/).flatten.join(".")
  platform_version File.read("/etc/SuSE-release").scan(/VERSION = ([\d\.]{2,})/).flatten.join(".") if platform_version == ""
elsif File.exists?('/etc/slackware-version')
  platform "slackware"
  platform_version File.read("/etc/slackware-version").scan(/(\d+|\.+)/).join
elsif File.exists?('/etc/arch-release')
  platform "arch"
  # no way to determine platform_version in a rolling release distribution
  # kernel release will be used - ex. 2.6.32-ARCH
elsif lsb[:id] =~ /RedHat/i
  platform "redhat"
  platform_version lsb[:release]
elsif lsb[:id] =~ /Amazon/i
  platform "amazon"
  platform_version lsb[:release]
elsif lsb[:id] =~ /ScientificSL/i
  platform "scientific"
  platform_version lsb[:release]
elsif lsb[:id] # LSB can provide odd data that changes between releases, so we currently fall back on it rather than dealing with its subtleties 
  platform lsb[:id].downcase
  platform_version lsb[:release]
end


case platform
  when /debian/, /ubuntu/, /linuxmint/
    platform_family "debian"
  when /fedora/
    platform_family "fedora"
  when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /amazon/
    platform_family "rhel"
  when /suse/
    platform_family "suse"
  when /gentoo/
    platform_family "gentoo"
  when /slackware/
    platform_family "slackware"
  when /arch/ 
    platform_family "arch" 
end