chef 18.1.29 → 18.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/chef-universal-mingw-ucrt.gemspec +2 -2
- data/chef.gemspec +1 -2
- data/lib/chef/application/base.rb +2 -0
- data/lib/chef/client.rb +2 -2
- data/lib/chef/cookbook/synchronizer.rb +20 -2
- data/lib/chef/cookbook_version.rb +1 -1
- data/lib/chef/http/authenticator.rb +2 -2
- data/lib/chef/http/ssl_policies.rb +2 -2
- data/lib/chef/mixin/homebrew_user.rb +12 -5
- data/lib/chef/mixin/proxified_socket.rb +1 -1
- data/lib/chef/monkey_patches/net-http.rb +127 -0
- data/lib/chef/node/attribute_collections.rb +8 -0
- data/lib/chef/node/immutable_collections.rb +5 -2
- data/lib/chef/node/mixin/state_tracking.rb +1 -1
- data/lib/chef/platform/query_helpers.rb +4 -2
- data/lib/chef/provider/launchd.rb +1 -1
- data/lib/chef/provider/mount/linux.rb +1 -1
- data/lib/chef/provider/mount/mount.rb +5 -5
- data/lib/chef/provider/package/chocolatey.rb +18 -1
- data/lib/chef/provider/package/zypper.rb +1 -0
- data/lib/chef/provider/remote_file/http.rb +1 -1
- data/lib/chef/provider/yum_repository.rb +1 -1
- data/lib/chef/resource/apt_repository.rb +25 -6
- data/lib/chef/resource/homebrew_cask.rb +6 -7
- data/lib/chef/resource/homebrew_package.rb +1 -1
- data/lib/chef/resource/homebrew_tap.rb +5 -5
- data/lib/chef/resource/launchd.rb +5 -1
- data/lib/chef/resource/macos_userdefaults.rb +9 -5
- data/lib/chef/resource/selinux_login.rb +129 -0
- data/lib/chef/resource/selinux_user.rb +137 -0
- data/lib/chef/resource/windows_certificate.rb +1 -1
- data/lib/chef/resource/windows_security_policy.rb +2 -2
- data/lib/chef/resource.rb +11 -1
- data/lib/chef/resources.rb +2 -0
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/security.rb +7 -1
- data/spec/data/apt/chef-integration-test-1.0/debian/rules +0 -0
- data/spec/data/apt/chef-integration-test-1.1/debian/rules +0 -0
- data/spec/data/apt/chef-integration-test2-1.0/debian/rules +0 -0
- data/spec/data/trusted_certs/intermediate.pem +38 -27
- data/spec/data/trusted_certs/opscode.pem +33 -54
- data/spec/functional/assets/chefinittest +0 -0
- data/spec/functional/assets/testchefsubsys +0 -0
- data/spec/functional/provider/remote_file/cache_control_data_spec.rb +0 -0
- data/spec/functional/resource/aix_service_spec.rb +0 -0
- data/spec/functional/resource/aixinit_service_spec.rb +0 -0
- data/spec/functional/resource/chocolatey_package_spec.rb +32 -20
- data/spec/functional/resource/execute_spec.rb +1 -1
- data/spec/functional/resource/macos_userdefaults_spec.rb +4 -4
- data/spec/functional/resource/windows_certificate_spec.rb +25 -0
- data/spec/unit/client_spec.rb +2 -2
- data/spec/unit/mixin/homebrew_user_spec.rb +30 -7
- data/spec/unit/node/vivid_mash_spec.rb +42 -0
- data/spec/unit/provider/apt_repository_spec.rb +17 -7
- data/spec/unit/provider/launchd_spec.rb +2 -2
- data/spec/unit/provider/mount/aix_spec.rb +2 -2
- data/spec/unit/provider/mount/linux_spec.rb +6 -5
- data/spec/unit/provider/mount/mount_spec.rb +8 -8
- data/spec/unit/provider/package/chocolatey_spec.rb +19 -3
- data/spec/unit/provider/package/rpm_spec.rb +2 -2
- data/spec/unit/provider/package/zypper_spec.rb +10 -0
- data/spec/unit/provider/remote_file/http_spec.rb +4 -4
- data/spec/unit/resource/apt_repository_spec.rb +5 -0
- data/spec/unit/resource/macos_user_defaults_spec.rb +4 -4
- data/spec/unit/resource/selinux_login_spec.rb +73 -0
- data/spec/unit/resource/selinux_user_spec.rb +92 -0
- data/spec/unit/resource_spec.rb +86 -0
- metadata +19 -15
- data/lib/chef/powershell.rb +0 -81
- /data/spec/functional/assets/chocolatey_feed/{test-A.1.0.nupkg → test-A.1.0.0.nupkg} +0 -0
- /data/spec/functional/assets/chocolatey_feed/{test-A.1.5.nupkg → test-A.1.5.0.nupkg} +0 -0
- /data/spec/functional/assets/chocolatey_feed/{test-A.2.0.nupkg → test-A.2.0.0.nupkg} +0 -0
- /data/spec/functional/assets/chocolatey_feed/{test-B.1.0.nupkg → test-B.1.0.0.nupkg} +0 -0
@@ -251,7 +251,7 @@ describe Chef::Provider::RemoteFile::HTTP do
|
|
251
251
|
end
|
252
252
|
|
253
253
|
context "and the response has no Date or Last-Modified header" do
|
254
|
-
let(:last_response) { { "date" => nil, "
|
254
|
+
let(:last_response) { { "date" => nil, "last-modified" => nil } }
|
255
255
|
it "does not set an mtime in the result" do
|
256
256
|
# RFC 2616 suggests that servers that do not set a Date header do not
|
257
257
|
# have a reliable clock, so no use in making them deal with dates.
|
@@ -265,19 +265,19 @@ describe Chef::Provider::RemoteFile::HTTP do
|
|
265
265
|
context "and the response has a Last-Modified header" do
|
266
266
|
let(:last_response) do
|
267
267
|
# Last-Modified should be preferred to Date if both are set
|
268
|
-
{ "date" => "Fri, 17 May 2013 23:23:23 GMT", "
|
268
|
+
{ "date" => "Fri, 17 May 2013 23:23:23 GMT", "last-modified" => "Fri, 17 May 2013 11:11:11 GMT" }
|
269
269
|
end
|
270
270
|
|
271
271
|
it "sets the mtime to the Last-Modified time in the response" do
|
272
272
|
fetcher.fetch
|
273
273
|
expect(cache_control_data.etag).to be_nil
|
274
|
-
expect(cache_control_data.mtime).to eq(last_response["
|
274
|
+
expect(cache_control_data.mtime).to eq(last_response["last-modified"])
|
275
275
|
end
|
276
276
|
end
|
277
277
|
|
278
278
|
context "and the response has a Date header but no Last-Modified header" do
|
279
279
|
let(:last_response) do
|
280
|
-
{ "date" => "Fri, 17 May 2013 23:23:23 GMT", "
|
280
|
+
{ "date" => "Fri, 17 May 2013 23:23:23 GMT", "last-modified" => nil }
|
281
281
|
end
|
282
282
|
|
283
283
|
it "sets the mtime to the Date in the response" do
|
@@ -68,6 +68,11 @@ describe Chef::Resource::AptRepository do
|
|
68
68
|
expect(resource.key).to eql(["key1"])
|
69
69
|
end
|
70
70
|
|
71
|
+
it "allows setting options to a String and coerces it to an Array" do
|
72
|
+
resource.options = "by-hash=no"
|
73
|
+
expect(resource.options).to eql(["by-hash=no"])
|
74
|
+
end
|
75
|
+
|
71
76
|
it "fails if the user provides a repo_name with a forward slash" do
|
72
77
|
expect { resource.repo_name "foo/bar" }.to raise_error(ArgumentError)
|
73
78
|
end
|
@@ -39,12 +39,12 @@ describe Chef::Resource::MacosUserDefaults, :macos_only do
|
|
39
39
|
expect(resource.domain).to eq("NSGlobalDomain")
|
40
40
|
end
|
41
41
|
|
42
|
-
it "
|
43
|
-
expect(resource.host).to
|
42
|
+
it ":all for the host property" do
|
43
|
+
expect(resource.host).to eq(:all)
|
44
44
|
end
|
45
45
|
|
46
|
-
it "
|
47
|
-
expect(resource.user).to
|
46
|
+
it ":current for the user property" do
|
47
|
+
expect(resource.user).to eq(:current)
|
48
48
|
end
|
49
49
|
|
50
50
|
it ":write for resource action" do
|
@@ -0,0 +1,73 @@
|
|
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 "spec_helper"
|
19
|
+
|
20
|
+
describe Chef::Resource::SelinuxLogin do
|
21
|
+
let(:node) { Chef::Node.new }
|
22
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
23
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
24
|
+
let(:resource) { Chef::Resource::SelinuxLogin.new("fakey_fakerton", run_context) }
|
25
|
+
let(:provider) { resource.provider_for_action(:manage) }
|
26
|
+
|
27
|
+
it "sets login property as name_property" do
|
28
|
+
expect(resource.login).to eql("fakey_fakerton")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "sets the default action as :manage" do
|
32
|
+
expect(resource.action).to eql([:manage])
|
33
|
+
end
|
34
|
+
|
35
|
+
it "supports :manage, :add, :modify, :delete actions" do
|
36
|
+
expect { resource.action :manage }.not_to raise_error
|
37
|
+
expect { resource.action :add }.not_to raise_error
|
38
|
+
expect { resource.action :modify }.not_to raise_error
|
39
|
+
expect { resource.action :delete }.not_to raise_error
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#semanage_login_args" do
|
43
|
+
let(:provider) { resource.provider_for_action(:modify) }
|
44
|
+
|
45
|
+
context "when no parameters are provided" do
|
46
|
+
it "returns an empty string" do
|
47
|
+
expect(provider.semanage_login_args).to eq("")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "when all parameters are provided" do
|
52
|
+
it "returns all params" do
|
53
|
+
resource.user "user_u"
|
54
|
+
resource.range "s0"
|
55
|
+
expect(provider.semanage_login_args).to eq(" -s user_u -r s0")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context "when no user is provided" do
|
60
|
+
it "returns range param" do
|
61
|
+
resource.range "s0"
|
62
|
+
expect(provider.semanage_login_args).to eq(" -r s0")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "when no range is provided" do
|
67
|
+
it "returns user param" do
|
68
|
+
resource.user "user_u"
|
69
|
+
expect(provider.semanage_login_args).to eq(" -s user_u")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,92 @@
|
|
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 "spec_helper"
|
19
|
+
|
20
|
+
describe Chef::Resource::SelinuxUser do
|
21
|
+
let(:node) { Chef::Node.new }
|
22
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
23
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
24
|
+
let(:resource) { Chef::Resource::SelinuxUser.new("fakey_fakerton", run_context) }
|
25
|
+
let(:provider) { resource.provider_for_action(:manage) }
|
26
|
+
let(:semanage_list) { double("shellout", stdout: "") }
|
27
|
+
|
28
|
+
it "sets user property as name_property" do
|
29
|
+
expect(resource.user).to eql("fakey_fakerton")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "sets the default action as :manage" do
|
33
|
+
expect(resource.action).to eql([:manage])
|
34
|
+
end
|
35
|
+
|
36
|
+
it "supports :manage, :add, :modify, :delete actions" do
|
37
|
+
expect { resource.action :manage }.not_to raise_error
|
38
|
+
expect { resource.action :add }.not_to raise_error
|
39
|
+
expect { resource.action :modify }.not_to raise_error
|
40
|
+
expect { resource.action :delete }.not_to raise_error
|
41
|
+
end
|
42
|
+
|
43
|
+
it "sorts roles property values" do
|
44
|
+
expect { resource.roles %w{c a b} }.not_to raise_error
|
45
|
+
expect(resource.roles).to eq(%w{a b c})
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#semanage_user_args" do
|
49
|
+
let(:provider) { resource.provider_for_action(:modify) }
|
50
|
+
|
51
|
+
context "when no parameters are provided" do
|
52
|
+
it "returns an empty string" do
|
53
|
+
expect(provider.semanage_user_args).to eq("")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "when all parameters are provided" do
|
58
|
+
it "returns all params" do
|
59
|
+
resource.level "s0"
|
60
|
+
resource.range "s0"
|
61
|
+
resource.roles %w{sysadm_r staff_r}
|
62
|
+
expect(provider.semanage_user_args).to eq(" -L s0 -r s0 -R 'staff_r sysadm_r'")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "when no roles are provided" do
|
67
|
+
it "returns level and range params" do
|
68
|
+
resource.level "s0"
|
69
|
+
resource.range "s0"
|
70
|
+
resource.roles []
|
71
|
+
|
72
|
+
expect(provider.semanage_user_args).to eq(" -L s0 -r s0")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "when no range is provided" do
|
77
|
+
it "returns level and roles params" do
|
78
|
+
resource.level "s0"
|
79
|
+
resource.roles %w{sysadm_r staff_r}
|
80
|
+
expect(provider.semanage_user_args).to eq(" -L s0 -R 'staff_r sysadm_r'")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context "when no level is provided" do
|
85
|
+
it "returns range and roles params" do
|
86
|
+
resource.range "s0"
|
87
|
+
resource.roles %w{sysadm_r staff_r}
|
88
|
+
expect(provider.semanage_user_args).to eq(" -r s0 -R 'staff_r sysadm_r'")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/spec/unit/resource_spec.rb
CHANGED
@@ -803,6 +803,92 @@ describe Chef::Resource do
|
|
803
803
|
end
|
804
804
|
end
|
805
805
|
|
806
|
+
describe "when using resource partials" do
|
807
|
+
let(:resource_using_core_partial) do
|
808
|
+
Class.new(Chef::Resource) do
|
809
|
+
use "core::core_partial"
|
810
|
+
end
|
811
|
+
end
|
812
|
+
|
813
|
+
let(:resource_using_cookbook_partial) do
|
814
|
+
Class.new(Chef::Resource) do
|
815
|
+
use "my_local_partial"
|
816
|
+
end
|
817
|
+
end
|
818
|
+
|
819
|
+
let(:resource_using_nested_partials) do
|
820
|
+
FakeCaller = Struct.new(:label, :path, keyword_init: true)
|
821
|
+
NonDynamicResource = Chef::Resource.dup
|
822
|
+
|
823
|
+
# Fake a caller_locations array, as RSpec uses a different execution path
|
824
|
+
NonDynamicResource.define_singleton_method(:caller_locations) do
|
825
|
+
[
|
826
|
+
FakeCaller.new(label: "use", path: File.join(__dir__, "resource.rb")),
|
827
|
+
FakeCaller.new(label: "noise", path: File.join(__dir__, "no_file")),
|
828
|
+
FakeCaller.new(label: "class_from_file", path: File.join(__dir__, "_level3_partial.rb")),
|
829
|
+
FakeCaller.new(label: "noise", path: File.join(__dir__, "no_file")),
|
830
|
+
FakeCaller.new(label: "class_from_file", path: File.join(__dir__, "_level2_partial.rb")),
|
831
|
+
FakeCaller.new(label: "noise", path: File.join(__dir__, "no_file")),
|
832
|
+
FakeCaller.new(label: "class_from_file", path: File.join(__dir__, "_level1_partial.rb")),
|
833
|
+
FakeCaller.new(label: "noise", path: File.join(__dir__, "no_file")),
|
834
|
+
FakeCaller.new(label: "class_from_file", path: File.join(__dir__, "_level0_partial.rb")),
|
835
|
+
]
|
836
|
+
end
|
837
|
+
|
838
|
+
Class.new(NonDynamicResource) do
|
839
|
+
use "level3_partial"
|
840
|
+
end
|
841
|
+
end
|
842
|
+
|
843
|
+
it "correcly includes a core partial" do
|
844
|
+
expected_path = File.expand_path(File.join(__dir__, "../..", "lib/chef", "resource/_core_partial.rb"))
|
845
|
+
partial = "property :addon_property, default: true"
|
846
|
+
|
847
|
+
expect(IO).to receive(:read).with(expected_path).and_return(partial)
|
848
|
+
expect(resource_using_core_partial.properties.keys).to include(:addon_property)
|
849
|
+
end
|
850
|
+
|
851
|
+
it "correctly includes a cookbook partial" do
|
852
|
+
expected_path = File.expand_path(File.join(__dir__, "_my_local_partial.rb"))
|
853
|
+
partial = "property :addon_property, default: true"
|
854
|
+
|
855
|
+
expect(IO).to receive(:read).with(expected_path).and_return(partial)
|
856
|
+
expect(resource_using_cookbook_partial.properties.keys).to include(:addon_property)
|
857
|
+
end
|
858
|
+
|
859
|
+
it "correctly includes nested partials" do
|
860
|
+
level0_path = File.expand_path(File.join(__dir__, "_level0_partial.rb"))
|
861
|
+
level0_partial = "property :level0_property, default: true"
|
862
|
+
expect(IO).to receive(:read).with(level0_path).and_return(level0_partial)
|
863
|
+
|
864
|
+
level1_path = File.expand_path(File.join(__dir__, "_level1_partial.rb"))
|
865
|
+
level1_partial = <<-EOF
|
866
|
+
use 'level0_partial'
|
867
|
+
property :level1_property, default: true
|
868
|
+
EOF
|
869
|
+
expect(IO).to receive(:read).with(level1_path).and_return(level1_partial)
|
870
|
+
|
871
|
+
level2_path = File.expand_path(File.join(__dir__, "_level2_partial.rb"))
|
872
|
+
level2_partial = <<-EOF
|
873
|
+
use 'level1_partial'
|
874
|
+
property :level2_property, default: true
|
875
|
+
EOF
|
876
|
+
expect(IO).to receive(:read).with(level2_path).and_return(level2_partial)
|
877
|
+
|
878
|
+
level3_path = File.expand_path(File.join(__dir__, "_level3_partial.rb"))
|
879
|
+
level3_partial = <<-EOF
|
880
|
+
use 'level2_partial'
|
881
|
+
property :level3_property, default: true
|
882
|
+
EOF
|
883
|
+
expect(IO).to receive(:read).with(level3_path).and_return(level3_partial)
|
884
|
+
|
885
|
+
expect(resource_using_nested_partials.properties.keys).to include(:level0_property)
|
886
|
+
expect(resource_using_nested_partials.properties.keys).to include(:level1_property)
|
887
|
+
expect(resource_using_nested_partials.properties.keys).to include(:level2_property)
|
888
|
+
expect(resource_using_nested_partials.properties.keys).to include(:level3_property)
|
889
|
+
end
|
890
|
+
end
|
891
|
+
|
806
892
|
describe "should_skip?" do
|
807
893
|
before do
|
808
894
|
resource = Chef::Resource::Cat.new("sugar", run_context)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 18.
|
4
|
+
version: 18.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef-config
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 18.
|
19
|
+
version: 18.3.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 18.
|
26
|
+
version: 18.3.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: chef-utils
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 18.
|
33
|
+
version: 18.3.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 18.
|
40
|
+
version: 18.3.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: train-core
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -336,20 +336,20 @@ dependencies:
|
|
336
336
|
requirements:
|
337
337
|
- - "~>"
|
338
338
|
- !ruby/object:Gem::Version
|
339
|
-
version: '1.
|
339
|
+
version: '1.0'
|
340
340
|
- - ">="
|
341
341
|
- !ruby/object:Gem::Version
|
342
|
-
version: 1.
|
342
|
+
version: 1.0.3
|
343
343
|
type: :runtime
|
344
344
|
prerelease: false
|
345
345
|
version_requirements: !ruby/object:Gem::Requirement
|
346
346
|
requirements:
|
347
347
|
- - "~>"
|
348
348
|
- !ruby/object:Gem::Version
|
349
|
-
version: '1.
|
349
|
+
version: '1.0'
|
350
350
|
- - ">="
|
351
351
|
- !ruby/object:Gem::Version
|
352
|
-
version: 1.
|
352
|
+
version: 1.0.3
|
353
353
|
- !ruby/object:Gem::Dependency
|
354
354
|
name: chef-zero
|
355
355
|
requirement: !ruby/object:Gem::Requirement
|
@@ -857,6 +857,7 @@ files:
|
|
857
857
|
- lib/chef/mixin/windows_env_helper.rb
|
858
858
|
- lib/chef/mixin/xml_escape.rb
|
859
859
|
- lib/chef/mixins.rb
|
860
|
+
- lib/chef/monkey_patches/net-http.rb
|
860
861
|
- lib/chef/monkey_patches/webrick-utils.rb
|
861
862
|
- lib/chef/monkey_patches/win32/registry.rb
|
862
863
|
- lib/chef/monologger.rb
|
@@ -887,7 +888,6 @@ files:
|
|
887
888
|
- lib/chef/policy_builder/dynamic.rb
|
888
889
|
- lib/chef/policy_builder/expand_node_object.rb
|
889
890
|
- lib/chef/policy_builder/policyfile.rb
|
890
|
-
- lib/chef/powershell.rb
|
891
891
|
- lib/chef/property.rb
|
892
892
|
- lib/chef/provider.rb
|
893
893
|
- lib/chef/provider/batch.rb
|
@@ -1162,10 +1162,12 @@ files:
|
|
1162
1162
|
- lib/chef/resource/selinux_boolean.rb
|
1163
1163
|
- lib/chef/resource/selinux_fcontext.rb
|
1164
1164
|
- lib/chef/resource/selinux_install.rb
|
1165
|
+
- lib/chef/resource/selinux_login.rb
|
1165
1166
|
- lib/chef/resource/selinux_module.rb
|
1166
1167
|
- lib/chef/resource/selinux_permissive.rb
|
1167
1168
|
- lib/chef/resource/selinux_port.rb
|
1168
1169
|
- lib/chef/resource/selinux_state.rb
|
1170
|
+
- lib/chef/resource/selinux_user.rb
|
1169
1171
|
- lib/chef/resource/service.rb
|
1170
1172
|
- lib/chef/resource/smartos_package.rb
|
1171
1173
|
- lib/chef/resource/snap_package.rb
|
@@ -1712,10 +1714,10 @@ files:
|
|
1712
1714
|
- spec/functional/assets/PkgA.1.0.0.0.bff
|
1713
1715
|
- spec/functional/assets/PkgA.2.0.0.0.bff
|
1714
1716
|
- spec/functional/assets/chefinittest
|
1715
|
-
- spec/functional/assets/chocolatey_feed/test-A.1.0.nupkg
|
1716
|
-
- spec/functional/assets/chocolatey_feed/test-A.1.5.nupkg
|
1717
|
-
- spec/functional/assets/chocolatey_feed/test-A.2.0.nupkg
|
1718
|
-
- spec/functional/assets/chocolatey_feed/test-B.1.0.nupkg
|
1717
|
+
- spec/functional/assets/chocolatey_feed/test-A.1.0.0.nupkg
|
1718
|
+
- spec/functional/assets/chocolatey_feed/test-A.1.5.0.nupkg
|
1719
|
+
- spec/functional/assets/chocolatey_feed/test-A.2.0.0.nupkg
|
1720
|
+
- spec/functional/assets/chocolatey_feed/test-B.1.0.0.nupkg
|
1719
1721
|
- spec/functional/assets/dummy-1-0.aix6.1.noarch.rpm
|
1720
1722
|
- spec/functional/assets/dummy-2-0.aix6.1.noarch.rpm
|
1721
1723
|
- spec/functional/assets/inittest
|
@@ -2324,10 +2326,12 @@ files:
|
|
2324
2326
|
- spec/unit/resource/selinux_boolean_spec.rb
|
2325
2327
|
- spec/unit/resource/selinux_fcontext_spec.rb
|
2326
2328
|
- spec/unit/resource/selinux_install_spec.rb
|
2329
|
+
- spec/unit/resource/selinux_login_spec.rb
|
2327
2330
|
- spec/unit/resource/selinux_module_spec.rb
|
2328
2331
|
- spec/unit/resource/selinux_permissive_spec.rb
|
2329
2332
|
- spec/unit/resource/selinux_port_spec.rb
|
2330
2333
|
- spec/unit/resource/selinux_state_spec.rb
|
2334
|
+
- spec/unit/resource/selinux_user_spec.rb
|
2331
2335
|
- spec/unit/resource/service_spec.rb
|
2332
2336
|
- spec/unit/resource/smartos_package_spec.rb
|
2333
2337
|
- spec/unit/resource/snap_package_spec.rb
|
data/lib/chef/powershell.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Stuart Preston (<stuart@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) Chef Software Inc.
|
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
|
-
require "ffi" unless defined?(FFI)
|
19
|
-
require_relative "json_compat"
|
20
|
-
|
21
|
-
class Chef
|
22
|
-
class PowerShell
|
23
|
-
extend FFI::Library
|
24
|
-
|
25
|
-
attr_reader :result
|
26
|
-
attr_reader :errors
|
27
|
-
attr_reader :verbose
|
28
|
-
|
29
|
-
# Run a command under PowerShell via FFI
|
30
|
-
# This implementation requires the managed dll and native wrapper to be in the library search
|
31
|
-
# path on Windows (i.e. c:\windows\system32 or in the same location as ruby.exe).
|
32
|
-
#
|
33
|
-
# Requires: .NET Framework 4.0 or higher on the target machine.
|
34
|
-
#
|
35
|
-
# @param script [String] script to run
|
36
|
-
# @param timeout [Integer, nil] timeout in seconds.
|
37
|
-
# @return [Object] output
|
38
|
-
def initialize(script, timeout: -1)
|
39
|
-
# This Powershell DLL source lives here: https://github.com/chef/chef-powershell-shim
|
40
|
-
# Every merge into that repo triggers a Habitat build and promotion. Running
|
41
|
-
# the rake :update_chef_exec_dll task in this (chef/chef) repo will pull down
|
42
|
-
# the built packages and copy the binaries to distro/ruby_bin_folder. Bundle install
|
43
|
-
# ensures that the correct architecture binaries are installed into the path.
|
44
|
-
@dll ||= "Chef.PowerShell.Wrapper.dll"
|
45
|
-
exec(script, timeout: timeout)
|
46
|
-
end
|
47
|
-
|
48
|
-
#
|
49
|
-
# Was there an error running the command
|
50
|
-
#
|
51
|
-
# @return [Boolean]
|
52
|
-
#
|
53
|
-
def error?
|
54
|
-
return true if errors.count > 0
|
55
|
-
|
56
|
-
false
|
57
|
-
end
|
58
|
-
|
59
|
-
class CommandFailed < RuntimeError; end
|
60
|
-
|
61
|
-
#
|
62
|
-
# @raise [Chef::PowerShell::CommandFailed] raise if the command failed
|
63
|
-
#
|
64
|
-
def error!
|
65
|
-
raise Chef::PowerShell::CommandFailed, "Unexpected exit in PowerShell command: #{@errors}" if error?
|
66
|
-
end
|
67
|
-
|
68
|
-
private
|
69
|
-
|
70
|
-
def exec(script, timeout: -1)
|
71
|
-
FFI.ffi_lib @dll
|
72
|
-
FFI.attach_function :execute_powershell, :ExecuteScript, %i{string int}, :pointer
|
73
|
-
timeout = -1 if timeout == 0 || timeout.nil?
|
74
|
-
execution = FFI.execute_powershell(script, timeout).read_utf16string
|
75
|
-
hashed_outcome = Chef::JSONCompat.parse(execution)
|
76
|
-
@result = Chef::JSONCompat.parse(hashed_outcome["result"])
|
77
|
-
@errors = hashed_outcome["errors"]
|
78
|
-
@verbose = hashed_outcome["verbose"]
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|