chef 18.1.0-x64-mingw-ucrt → 18.2.7-x64-mingw-ucrt
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -3
- data/chef-universal-mingw-ucrt.gemspec +2 -2
- data/chef.gemspec +1 -1
- data/distro/powershell/chef/chef.psm1 +459 -0
- data/lib/chef/application/base.rb +18 -2
- data/lib/chef/client.rb +23 -6
- data/lib/chef/http/authenticator.rb +117 -34
- data/lib/chef/platform/query_helpers.rb +4 -2
- data/lib/chef/resource/apt_repository.rb +20 -2
- data/lib/chef/resource/bash.rb +13 -0
- data/lib/chef/resource/dsc_script.rb +1 -1
- data/lib/chef/resource/launchd.rb +2 -2
- data/lib/chef/resource/macos_userdefaults.rb +9 -5
- data/lib/chef/resource/rhsm_register.rb +1 -1
- data/lib/chef/resource/selinux_fcontext.rb +1 -1
- data/lib/chef/resource/selinux_login.rb +129 -0
- data/lib/chef/resource/selinux_permissive.rb +1 -1
- data/lib/chef/resource/selinux_port.rb +1 -1
- data/lib/chef/resource/selinux_state.rb +1 -1
- data/lib/chef/resource/selinux_user.rb +137 -0
- data/lib/chef/resource/service.rb +1 -1
- data/lib/chef/resource/user.rb +2 -2
- data/lib/chef/resource/windows_user_privilege.rb +14 -10
- data/lib/chef/resources.rb +2 -0
- data/lib/chef/version.rb +1 -1
- data/spec/data/trusted_certs/intermediate.pem +38 -27
- data/spec/data/trusted_certs/opscode.pem +33 -54
- data/spec/functional/resource/macos_userdefaults_spec.rb +4 -4
- data/spec/integration/client/client_spec.rb +22 -16
- data/spec/spec_helper.rb +3 -3
- data/spec/unit/client_spec.rb +26 -2
- data/spec/unit/compliance/runner_spec.rb +8 -0
- data/spec/unit/http/authenticator_spec.rb +64 -11
- data/spec/unit/provider/apt_repository_spec.rb +26 -5
- 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
- metadata +16 -12
- data/lib/chef/powershell.rb +0 -81
@@ -18,6 +18,9 @@
|
|
18
18
|
|
19
19
|
require "spec_helper"
|
20
20
|
require "chef/http/authenticator"
|
21
|
+
require "chef/mixin/powershell_exec"
|
22
|
+
|
23
|
+
require_relative "../../../lib/chef/win32/registry"
|
21
24
|
|
22
25
|
describe Chef::HTTP::Authenticator, :windows_only do
|
23
26
|
let(:class_instance) { Chef::HTTP::Authenticator.new(client_name: "test") }
|
@@ -28,7 +31,7 @@ describe Chef::HTTP::Authenticator, :windows_only do
|
|
28
31
|
let(:node_name) { "test" }
|
29
32
|
let(:passwrd) { "some_insecure_password" }
|
30
33
|
|
31
|
-
before do
|
34
|
+
before(:each) do
|
32
35
|
Chef::Config[:node_name] = node_name
|
33
36
|
cert_name = "chef-#{node_name}"
|
34
37
|
d = Time.now
|
@@ -36,6 +39,7 @@ describe Chef::HTTP::Authenticator, :windows_only do
|
|
36
39
|
end_date = end_date.utc.iso8601
|
37
40
|
|
38
41
|
my_client = Chef::Client.new
|
42
|
+
class_instance.get_cert_password
|
39
43
|
pfx = my_client.generate_pfx_package(cert_name, end_date)
|
40
44
|
my_client.import_pfx_to_store(pfx)
|
41
45
|
end
|
@@ -47,10 +51,21 @@ describe Chef::HTTP::Authenticator, :windows_only do
|
|
47
51
|
delete_certificate(cert_name)
|
48
52
|
end
|
49
53
|
|
50
|
-
context "when retrieving a certificate from the certificate store" do
|
54
|
+
context "when retrieving a certificate from the certificate store it" do
|
55
|
+
it "properly creates the password hive in the registry when it doesn't exist" do
|
56
|
+
delete_registry_hive
|
57
|
+
class_instance.get_cert_password
|
58
|
+
win32registry = Chef::Win32::Registry.new
|
59
|
+
expected_path = "HKEY_LOCAL_MACHINE\\Software\\Progress\\Authentication"
|
60
|
+
path_created = win32registry.key_exists?(expected_path)
|
61
|
+
expect(path_created).to be(true)
|
62
|
+
end
|
63
|
+
|
51
64
|
it "retrieves a certificate password from the registry when the hive does not already exist" do
|
52
65
|
delete_registry_hive
|
66
|
+
password = class_instance.get_cert_password
|
53
67
|
expect { class_instance.get_cert_password }.not_to raise_error
|
68
|
+
expect(password).not_to be(nil)
|
54
69
|
end
|
55
70
|
|
56
71
|
it "should return a password of at least 14 characters in length" do
|
@@ -58,7 +73,27 @@ describe Chef::HTTP::Authenticator, :windows_only do
|
|
58
73
|
expect(password.length).to eql(14)
|
59
74
|
end
|
60
75
|
|
61
|
-
it "
|
76
|
+
it "will retrieve a password from a partial registry hive and upgrades it while using the old decryptor" do
|
77
|
+
delete_registry_hive
|
78
|
+
load_partial_registry_hive
|
79
|
+
password = class_instance.get_cert_password
|
80
|
+
expect(password).to eql(passwrd)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "verifies that the new password is now using a vector" do
|
84
|
+
win32registry = Chef::Win32::Registry.new
|
85
|
+
path = "HKEY_LOCAL_MACHINE\\Software\\Progress\\Authentication"
|
86
|
+
password_blob = win32registry.get_values(path)
|
87
|
+
if password_blob.nil? || password_blob.empty?
|
88
|
+
raise Chef::Exceptions::Win32RegKeyMissing
|
89
|
+
end
|
90
|
+
|
91
|
+
raw_data = password_blob.map { |x| x[:data] }
|
92
|
+
vector = raw_data[2]
|
93
|
+
expect(vector).not_to be(nil)
|
94
|
+
end
|
95
|
+
|
96
|
+
it "correctly retrieves a valid certificate in pem format from the LocalMachine certstore" do
|
62
97
|
require "openssl"
|
63
98
|
certificate = class_instance.retrieve_certificate_key(node_name)
|
64
99
|
cert_object = OpenSSL::PKey::RSA.new(certificate)
|
@@ -66,21 +101,39 @@ describe Chef::HTTP::Authenticator, :windows_only do
|
|
66
101
|
end
|
67
102
|
end
|
68
103
|
|
69
|
-
def
|
104
|
+
def load_partial_registry_hive
|
105
|
+
extend Chef::Mixin::PowershellExec
|
106
|
+
password = "some_insecure_password"
|
70
107
|
powershell_code = <<~CODE
|
71
|
-
|
108
|
+
$encrypted_string = ConvertTo-SecureString "#{password}" -AsPlainText -Force
|
109
|
+
$secure_string = ConvertFrom-SecureString $encrypted_string
|
110
|
+
return $secure_string
|
72
111
|
CODE
|
73
|
-
powershell_exec!(powershell_code)
|
112
|
+
encrypted_pass = powershell_exec!(powershell_code).result
|
113
|
+
Chef::Config[:auth_key_registry_type] == "user" ? store = "HKEY_CURRENT_USER" : store = "HKEY_LOCAL_MACHINE"
|
114
|
+
hive_path = "#{store}\\Software\\Progress\\Authentication"
|
115
|
+
win32registry = Chef::Win32::Registry.new
|
116
|
+
unless win32registry.key_exists?(hive_path)
|
117
|
+
win32registry.create_key(hive_path, true)
|
118
|
+
end
|
119
|
+
values = { name: "PfxPass", type: :string, data: encrypted_pass }
|
120
|
+
win32registry.set_value(hive_path, values)
|
74
121
|
end
|
75
122
|
|
76
123
|
def delete_registry_hive
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
@win32registry.delete_key(path, true)
|
124
|
+
win32registry = Chef::Win32::Registry.new
|
125
|
+
hive_path = "HKEY_LOCAL_MACHINE\\Software\\Progress"
|
126
|
+
if win32registry.key_exists?(hive_path)
|
127
|
+
win32registry.delete_key(hive_path, true)
|
82
128
|
end
|
83
129
|
end
|
130
|
+
|
131
|
+
def delete_certificate(cert_name)
|
132
|
+
powershell_code = <<~CODE
|
133
|
+
Get-ChildItem -path cert:\\LocalMachine\\My -Recurse -Force | Where-Object { $_.Subject -Match "#{cert_name}" } | Remove-item
|
134
|
+
CODE
|
135
|
+
powershell_exec!(powershell_code)
|
136
|
+
end
|
84
137
|
end
|
85
138
|
|
86
139
|
describe Chef::HTTP::Authenticator do
|
@@ -82,6 +82,15 @@ C5986B4F1257FFA86632CBA746181433FBB75451
|
|
82
82
|
843938DF228D22F7B3742BC0D94AA3F0EFE21092}
|
83
83
|
end
|
84
84
|
|
85
|
+
let(:apt_public_keys) do
|
86
|
+
%w{
|
87
|
+
pub:-:1024:17:40976EAF437D05B5:2004-09-12
|
88
|
+
pub:-:1024:17:46181433FBB75451:2004-12-30
|
89
|
+
pub:-:4096:1:3B4FE6ACC0B21F32:2012-05-11
|
90
|
+
pub:-:4096:1:D94AA3F0EFE21092:2012-05-11
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
85
94
|
it "responds to load_current_resource" do
|
86
95
|
expect(provider).to respond_to(:load_current_resource)
|
87
96
|
end
|
@@ -113,6 +122,18 @@ C5986B4F1257FFA86632CBA746181433FBB75451
|
|
113
122
|
end
|
114
123
|
end
|
115
124
|
|
125
|
+
describe "#extract_public_keys_from_cmd" do
|
126
|
+
it "runs the desired command" do
|
127
|
+
expect(provider).to receive(:shell_out).and_return(apt_key_finger)
|
128
|
+
provider.extract_public_keys_from_cmd(*apt_key_finger_cmd)
|
129
|
+
end
|
130
|
+
|
131
|
+
it "returns a list of key fingerprints" do
|
132
|
+
expect(provider).to receive(:shell_out).and_return(apt_key_finger)
|
133
|
+
expect(provider.extract_public_keys_from_cmd(*apt_key_finger_cmd)).to eql(apt_public_keys)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
116
137
|
describe "#cookbook_name" do
|
117
138
|
it "returns 'test' when the cookbook property is set" do
|
118
139
|
new_resource.cookbook("test")
|
@@ -122,22 +143,22 @@ C5986B4F1257FFA86632CBA746181433FBB75451
|
|
122
143
|
|
123
144
|
describe "#no_new_keys?" do
|
124
145
|
before do
|
125
|
-
allow(provider).to receive(:
|
146
|
+
allow(provider).to receive(:extract_public_keys_from_cmd).with(*apt_key_finger_cmd).and_return(apt_public_keys)
|
126
147
|
end
|
127
148
|
|
128
149
|
let(:file) { "/tmp/remote-gpg-keyfile" }
|
129
150
|
|
130
151
|
it "matches a set of keys" do
|
131
|
-
allow(provider).to receive(:
|
152
|
+
allow(provider).to receive(:extract_public_keys_from_cmd)
|
132
153
|
.with("gpg", "--with-fingerprint", "--with-colons", file)
|
133
|
-
.and_return(
|
154
|
+
.and_return([apt_public_keys.first])
|
134
155
|
expect(provider.no_new_keys?(file)).to be_truthy
|
135
156
|
end
|
136
157
|
|
137
158
|
it "notices missing keys" do
|
138
|
-
allow(provider).to receive(:
|
159
|
+
allow(provider).to receive(:extract_public_keys_from_cmd)
|
139
160
|
.with("gpg", "--with-fingerprint", "--with-colons", file)
|
140
|
-
.and_return(%w{
|
161
|
+
.and_return(%w{pub:-:4096:1:871920D1991BC93C:1537196506})
|
141
162
|
expect(provider.no_new_keys?(file)).to be_falsey
|
142
163
|
end
|
143
164
|
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
|
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.2.7
|
5
5
|
platform: x64-mingw-ucrt
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-04 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.2.7
|
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.2.7
|
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.2.7
|
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.2.7
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: train-core
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -483,19 +483,19 @@ dependencies:
|
|
483
483
|
- !ruby/object:Gem::Version
|
484
484
|
version: 0.3.4
|
485
485
|
- !ruby/object:Gem::Dependency
|
486
|
-
name:
|
486
|
+
name: proxifier2
|
487
487
|
requirement: !ruby/object:Gem::Requirement
|
488
488
|
requirements:
|
489
489
|
- - "~>"
|
490
490
|
- !ruby/object:Gem::Version
|
491
|
-
version: '1.
|
491
|
+
version: '1.1'
|
492
492
|
type: :runtime
|
493
493
|
prerelease: false
|
494
494
|
version_requirements: !ruby/object:Gem::Requirement
|
495
495
|
requirements:
|
496
496
|
- - "~>"
|
497
497
|
- !ruby/object:Gem::Version
|
498
|
-
version: '1.
|
498
|
+
version: '1.1'
|
499
499
|
- !ruby/object:Gem::Dependency
|
500
500
|
name: aws-sdk-s3
|
501
501
|
requirement: !ruby/object:Gem::Requirement
|
@@ -710,14 +710,14 @@ dependencies:
|
|
710
710
|
requirements:
|
711
711
|
- - "~>"
|
712
712
|
- !ruby/object:Gem::Version
|
713
|
-
version:
|
713
|
+
version: 18.0.0
|
714
714
|
type: :runtime
|
715
715
|
prerelease: false
|
716
716
|
version_requirements: !ruby/object:Gem::Requirement
|
717
717
|
requirements:
|
718
718
|
- - "~>"
|
719
719
|
- !ruby/object:Gem::Version
|
720
|
-
version:
|
720
|
+
version: 18.0.0
|
721
721
|
description: A systems integration framework, built to bring the benefits of configuration
|
722
722
|
management to your entire infrastructure.
|
723
723
|
email: adam@chef.io
|
@@ -734,6 +734,7 @@ files:
|
|
734
734
|
- Rakefile
|
735
735
|
- chef-universal-mingw-ucrt.gemspec
|
736
736
|
- chef.gemspec
|
737
|
+
- distro/powershell/chef/chef.psm1
|
737
738
|
- distro/ruby_bin_folder/AMD64/Chef.PowerShell.Wrapper.dll
|
738
739
|
- distro/ruby_bin_folder/AMD64/Chef.PowerShell.dll
|
739
740
|
- distro/ruby_bin_folder/AMD64/Ijwhost.dll
|
@@ -1679,7 +1680,6 @@ files:
|
|
1679
1680
|
- lib/chef/policy_builder/dynamic.rb
|
1680
1681
|
- lib/chef/policy_builder/expand_node_object.rb
|
1681
1682
|
- lib/chef/policy_builder/policyfile.rb
|
1682
|
-
- lib/chef/powershell.rb
|
1683
1683
|
- lib/chef/property.rb
|
1684
1684
|
- lib/chef/provider.rb
|
1685
1685
|
- lib/chef/provider/batch.rb
|
@@ -1954,10 +1954,12 @@ files:
|
|
1954
1954
|
- lib/chef/resource/selinux_boolean.rb
|
1955
1955
|
- lib/chef/resource/selinux_fcontext.rb
|
1956
1956
|
- lib/chef/resource/selinux_install.rb
|
1957
|
+
- lib/chef/resource/selinux_login.rb
|
1957
1958
|
- lib/chef/resource/selinux_module.rb
|
1958
1959
|
- lib/chef/resource/selinux_permissive.rb
|
1959
1960
|
- lib/chef/resource/selinux_port.rb
|
1960
1961
|
- lib/chef/resource/selinux_state.rb
|
1962
|
+
- lib/chef/resource/selinux_user.rb
|
1961
1963
|
- lib/chef/resource/service.rb
|
1962
1964
|
- lib/chef/resource/smartos_package.rb
|
1963
1965
|
- lib/chef/resource/snap_package.rb
|
@@ -3116,10 +3118,12 @@ files:
|
|
3116
3118
|
- spec/unit/resource/selinux_boolean_spec.rb
|
3117
3119
|
- spec/unit/resource/selinux_fcontext_spec.rb
|
3118
3120
|
- spec/unit/resource/selinux_install_spec.rb
|
3121
|
+
- spec/unit/resource/selinux_login_spec.rb
|
3119
3122
|
- spec/unit/resource/selinux_module_spec.rb
|
3120
3123
|
- spec/unit/resource/selinux_permissive_spec.rb
|
3121
3124
|
- spec/unit/resource/selinux_port_spec.rb
|
3122
3125
|
- spec/unit/resource/selinux_state_spec.rb
|
3126
|
+
- spec/unit/resource/selinux_user_spec.rb
|
3123
3127
|
- spec/unit/resource/service_spec.rb
|
3124
3128
|
- spec/unit/resource/smartos_package_spec.rb
|
3125
3129
|
- 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
|