ohai 16.0.20 → 16.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 474ba3761494212a1559a82eb0fea84b9ec142762b53cdb4625a6b0d3bf1a9e8
4
- data.tar.gz: a809312e61ca2626c073c64e95043c053c6a49bb524e758a6d219345377aadbb
3
+ metadata.gz: 44803c8f4302262268fcee91c74a4ac4be53cfcd2911a04f586694836a5a4fd2
4
+ data.tar.gz: 501cc5bd1579869f0cb56300e14b1ac3a377d04a104211b187883aba47627afa
5
5
  SHA512:
6
- metadata.gz: e12e1ef3e93b78b95c6482cc5d9a4a192cd1759b4021ae2a9a11422f0ea50adaea2f739c6baccaa87dd61d3b97c7ced7204944452a5d97eee0c386d52b9ef60c
7
- data.tar.gz: 8cdb5bbcc612d1f4c19b4193f385a62769c0e3d06e4e1eb3aa6f7d8cc4a9acfcb23d3f175faf7c4f6e7e684cbf47af582afef5df54596e62489edb27453991e1
6
+ metadata.gz: 93f85ef68589fa530ee2765b3f6e7fc4694037fb4b546375de606bc0b4a23fbaaac8af1419e63a1f42937019c8a4120c95035f8991bb6114628521853331594a
7
+ data.tar.gz: 285f88f5fb97b070353d8425b5f4234e2617554e2610a933bd2bb05cce8dbbcc26268f5e9abfcde24e928e42cb28d99f65d82d2248f70b03ecef4be82d132a1a
@@ -1,201 +1,21 @@
1
- # Copyright (c) 2009 Dan Kubb
2
-
3
- # Permission is hereby granted, free of charge, to any person obtaining
4
- # a copy of this software and associated documentation files (the
5
- # "Software"), to deal in the Software without restriction, including
6
- # without limitation the rights to use, copy, modify, merge, publish,
7
- # distribute, sublicense, and/or sell copies of the Software, and to
8
- # permit persons to whom the Software is furnished to do so, subject to
9
- # the following conditions:
10
-
11
- # The above copyright notice and this permission notice shall be
12
- # included in all copies or substantial portions of the Software.
13
-
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
-
22
- # ---
23
- # ---
24
-
25
- # Some portions of blank.rb and mash.rb are verbatim copies of software
26
- # licensed under the MIT license. That license is included below:
27
-
28
- # Copyright (c) 2005-2008 David Heinemeier Hansson
29
-
30
- # Permission is hereby granted, free of charge, to any person obtaining
31
- # a copy of this software and associated documentation files (the
32
- # "Software"), to deal in the Software without restriction, including
33
- # without limitation the rights to use, copy, modify, merge, publish,
34
- # distribute, sublicense, and/or sell copies of the Software, and to
35
- # permit persons to whom the Software is furnished to do so, subject to
36
- # the following conditions:
37
-
38
- # The above copyright notice and this permission notice shall be
39
- # included in all copies or substantial portions of the Software.
40
-
41
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
42
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
43
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
44
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
45
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
46
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
47
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
48
-
49
- # This class has dubious semantics and we only have it so that people can write
50
- # params[:key] instead of params['key'].
51
- class Mash < Hash
52
-
53
- # @param constructor [Object] The default value for the mash.
54
- # If constructor is a Hash, a new mash will be created based on the keys of the hash and
55
- # no default value will be set.
56
- def initialize(constructor = {})
57
- if constructor.is_a?(Hash)
58
- super()
59
- update(constructor)
60
- else
61
- super(constructor)
62
- end
63
- end
64
-
65
- # @param key [Object] The default value for the mash.
66
- # If key is a Symbol and it is a key in the mash, then the default value will be set to
67
- # the value matching the key.
68
- def default(key = nil)
69
- if key.is_a?(Symbol) && include?(key = key.to_s)
70
- self[key]
71
- else
72
- super
73
- end
74
- end
75
-
76
- alias_method :regular_writer, :[]= unless method_defined?(:regular_writer)
77
- alias_method :regular_update, :update unless method_defined?(:regular_update)
78
-
79
- # @param key [Object] The key to set.
80
- # @param value [Object] The value to set the key to.
81
- #
82
- # @see Mash#convert_key
83
- # @see Mash#convert_value
84
- def []=(key, value)
85
- regular_writer(convert_key(key), convert_value(value))
86
- end
87
-
88
- # @param other_hash [Hash]
89
- # A hash to update values in the mash with. The keys and the values will be
90
- # converted to Mash format.
91
- #
92
- # @return [Mash] The updated mash.
93
- def update(other_hash)
94
- other_hash.each_pair { |key, value| regular_writer(convert_key(key), convert_value(value)) }
95
- self
96
- end
97
-
98
- alias_method :merge!, :update
99
-
100
- # @param key [Object] The key to check for. This will be run through convert_key.
101
- #
102
- # @return [Boolean] True if the key exists in the mash.
103
- def key?(key)
104
- super(convert_key(key))
105
- end
106
-
107
- # def include? def has_key? def member?
108
- alias_method :include?, :key?
109
- alias_method :has_key?, :key?
110
- alias_method :member?, :key?
111
-
112
- # @param key [Object] The key to fetch. This will be run through convert_key.
113
- # @param extras [Array] Default value.
114
- #
115
- # @return [Object] The value at key or the default value.
116
- def fetch(key, *extras)
117
- super(convert_key(key), *extras)
118
- end
119
-
120
- # @param indices [Array] The keys to retrieve values for. These will be run through +convert_key+.
121
- #
122
- # @return [Array] The values at each of the provided keys
123
- def values_at(*indices)
124
- indices.collect { |key| self[convert_key(key)] }
125
- end
126
-
127
- # @param hash [Hash] The hash to merge with the mash.
128
- #
129
- # @return [Mash] A new mash with the hash values merged in.
130
- def merge(hash)
131
- dup.update(hash)
132
- end
133
-
134
- # @param key [Object] The key to delete from the mash.
135
- def delete(key)
136
- super(convert_key(key))
137
- end
138
-
139
- # @param keys [Array<String, Symbol>] The mash keys to exclude.
140
- #
141
- # @return [Mash] A new mash without the selected keys.
142
- #
143
- # @example
144
- # { :one => 1, :two => 2, :three => 3 }.except(:one)
145
- # #=> { "two" => 2, "three" => 3 }
146
- def except(*keys)
147
- super(*keys.map { |k| convert_key(k) })
148
- end
149
-
150
- # Used to provide the same interface as Hash.
151
- #
152
- # @return [Mash] This mash unchanged.
153
- def stringify_keys!; self end
154
-
155
- # @return [Hash] The mash as a Hash with symbolized keys.
156
- def symbolize_keys
157
- h = Hash.new(default)
158
- each { |key, val| h[key.to_sym] = val }
159
- h
160
- end
161
-
162
- # @return [Hash] The mash as a Hash with string keys.
163
- def to_hash
164
- Hash.new(default).merge(self)
165
- end
166
-
167
- # Convert a Hash into a Mash. The input Hash's default value is maintained
168
- # @return [Mash]
169
- def self.from_hash(hash)
170
- mash = Mash.new(hash)
171
- mash.default = hash.default
172
- mash
173
- end
174
-
175
- protected
176
-
177
- # @param key [Object] The key to convert.
178
- # @return [Object] The converted key. If the key was a symbol, it will be converted to a string.
179
- #
180
- # @api private
181
- def convert_key(key)
182
- key.is_a?(Symbol) ? key.to_s : key
183
- end
184
-
185
- # @param value [Object] The value to convert.
186
- #
187
- # @return [Object]
188
- # The converted value. A Hash or an Array of hashes, will be converted to
189
- # their Mash equivalents.
190
- #
191
- # @api private
192
- def convert_value(value)
193
- if value.class == Hash
194
- Mash.from_hash(value)
195
- elsif value.is_a?(Array)
196
- value.collect { |e| convert_value(e) }
197
- else
198
- value
199
- end
200
- end
201
- end
1
+ #
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "chef-utils/mash" unless defined?(ChefUtils::Mash)
19
+
20
+ # For historical reasons we inject Mash directly into the top level class namespace
21
+ Mash = ChefUtils::Mash unless defined?(Mash)
@@ -364,7 +364,7 @@ Ohai.plugin(:CPU) do
364
364
  cpu["cpustates"][value] += 1
365
365
  when /core_id/
366
366
  cpu[instance]["core_id"] = value
367
- # Detect hyperthreading/multithreading
367
+ # Detect hyperthreading/multithreading
368
368
  cpucores.push(value) if cpucores.index(value).nil?
369
369
  when /family|fpu_type|model|stepping|vendor_id/
370
370
  cpu[instance][key] = value
@@ -0,0 +1,68 @@
1
+ #
2
+ # Author:: Davide Cavalca <dcavalca@fb.com>
3
+ # Copyright:: Copyright (c) 2020 Facebook
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ Ohai.plugin(:Selinux) do
20
+ provides "selinux/status", "selinux/policy_booleans", "selinux/process_contexts", "selinux/file_contexts"
21
+ optional true
22
+
23
+ collect_data(:linux) do
24
+ sestatus_path = which("sestatus")
25
+ if sestatus_path
26
+ sestatus = shell_out("#{sestatus_path} -v -b")
27
+
28
+ selinux Mash.new unless selinux
29
+ selinux[:status] ||= Mash.new
30
+ selinux[:policy_booleans] ||= Mash.new
31
+ selinux[:process_contexts] ||= Mash.new
32
+ selinux[:file_contexts] ||= Mash.new
33
+ section = nil
34
+
35
+ sestatus.stdout.split("\n").each do |line|
36
+ line.chomp!
37
+
38
+ case line
39
+ when "Policy booleans:"
40
+ section = :policy_booleans
41
+ next
42
+ when "Process contexts:"
43
+ section = :process_contexts
44
+ next
45
+ when "File contexts:"
46
+ section = :file_contexts
47
+ next
48
+ else
49
+ if section.nil?
50
+ section = :status
51
+ end
52
+ end
53
+
54
+ key, val = line.split(/:?\s\s+/, 2)
55
+ next if key.nil?
56
+
57
+ unless key.start_with?("/")
58
+ key.downcase!
59
+ key.tr!(" ", "_")
60
+ end
61
+
62
+ selinux[section][key] = val
63
+ end
64
+ else
65
+ logger.debug("Plugin Selinux: Could not find sestatus. Skipping plugin.")
66
+ end
67
+ end
68
+ end
@@ -93,8 +93,8 @@ Ohai.plugin(:Virtualbox) do
93
93
  so_cmd = "VBoxManage list --sorted #{query_type}"
94
94
  logger.trace(so_cmd)
95
95
  so = shell_out(so_cmd)
96
- # raise an exception if the command fails
97
- # so.error!
96
+ # raise an exception if the command fails
97
+ # so.error!
98
98
 
99
99
  if so.exitstatus == 0
100
100
  # break the result into paragraph blocks, on successive newlines
@@ -18,5 +18,5 @@
18
18
 
19
19
  module Ohai
20
20
  OHAI_ROOT = File.expand_path(File.dirname(__FILE__))
21
- VERSION = "16.0.20".freeze
21
+ VERSION = "16.1.1".freeze
22
22
  end
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.add_dependency "wmi-lite", "~> 1.0"
26
26
  s.add_dependency "ffi", "~> 1.9"
27
27
  s.add_dependency "chef-config", ">= 12.8", "< 17"
28
+ s.add_dependency "chef-utils", ">= 16.0", "< 17"
28
29
  # Note for ohai developers: If chef-config causes you grief, try:
29
30
  # bundle install --with development
30
31
  # this should work as long as chef is a development dependency in Gemfile.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohai
3
3
  version: !ruby/object:Gem::Version
4
- version: 16.0.20
4
+ version: 16.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-25 00:00:00.000000000 Z
11
+ date: 2020-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: systemu
@@ -188,6 +188,26 @@ dependencies:
188
188
  - - "<"
189
189
  - !ruby/object:Gem::Version
190
190
  version: '17'
191
+ - !ruby/object:Gem::Dependency
192
+ name: chef-utils
193
+ requirement: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - ">="
196
+ - !ruby/object:Gem::Version
197
+ version: '16.0'
198
+ - - "<"
199
+ - !ruby/object:Gem::Version
200
+ version: '17'
201
+ type: :runtime
202
+ prerelease: false
203
+ version_requirements: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: '16.0'
208
+ - - "<"
209
+ - !ruby/object:Gem::Version
210
+ version: '17'
191
211
  description: Ohai profiles your system and emits JSON
192
212
  email: adam@chef.io
193
213
  executables:
@@ -282,6 +302,7 @@ files:
282
302
  - lib/ohai/plugins/linux/memory.rb
283
303
  - lib/ohai/plugins/linux/network.rb
284
304
  - lib/ohai/plugins/linux/platform.rb
305
+ - lib/ohai/plugins/linux/selinux.rb
285
306
  - lib/ohai/plugins/linux/sessions.rb
286
307
  - lib/ohai/plugins/linux/sysctl.rb
287
308
  - lib/ohai/plugins/linux/systemd_paths.rb