chef 13.6.0 → 13.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/chef/provider/package.rb +3 -0
- data/lib/chef/provider/package/apt.rb +13 -4
- data/lib/chef/provider/package/dpkg.rb +16 -0
- data/lib/chef/version.rb +1 -1
- data/spec/functional/win32/security_spec.rb +33 -7
- data/spec/unit/provider/package/apt_spec.rb +34 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be0e226d4b48be835191333a6e6bb427cf070361
|
4
|
+
data.tar.gz: 04b92a7521c888b8b2008f62939abc31850c9a2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 426710a08713f6828882d512b3441f5006b3bbaa404238b1f6771d714dc87c398ba357355a82bc0dce25d0a868e0c080cdeaff69bde16061a29578c52954f5bf
|
7
|
+
data.tar.gz: aa6b69eb678093ac3788ebb55caa8524743fd9122c91a2d3124d6e8bc0bfb0446066d1149c434994bfdd38225482064c22ade9e4e226a25152bb84fc679e1d8d
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
13.6.
|
1
|
+
13.6.4
|
@@ -477,6 +477,9 @@ class Chef
|
|
477
477
|
elsif candidate_version.nil?
|
478
478
|
Chef::Log.debug("#{new_resource} #{package_name} has no candidate_version to upgrade to")
|
479
479
|
target_version_array.push(nil)
|
480
|
+
elsif current_version.nil?
|
481
|
+
Chef::Log.debug("#{new_resource} has no existing installed version. Installing install #{candidate_version}")
|
482
|
+
target_version_array.push(candidate_version)
|
480
483
|
elsif version_compare(current_version, candidate_version) == 1 && !new_resource.allow_downgrade
|
481
484
|
Chef::Log.debug("#{new_resource} #{package_name} has installed version #{current_version}, which is newer than available version #{candidate_version}. Skipping...)")
|
482
485
|
target_version_array.push(nil)
|
@@ -127,11 +127,20 @@ class Chef
|
|
127
127
|
|
128
128
|
private
|
129
129
|
|
130
|
+
# compare 2 versions to each other to see which is newer.
|
131
|
+
# this differs from the standard package method because we
|
132
|
+
# need to be able to parse debian version strings which contain
|
133
|
+
# tildes which Gem cannot properly parse
|
134
|
+
#
|
135
|
+
# @return [Integer] 1 if v1 > v2. 0 if they're equal. -1 if v1 < v2
|
130
136
|
def version_compare(v1, v2)
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
137
|
+
if !shell_out_compact_timeout("dpkg", "--compare-versions", v1.to_s, "gt", v2.to_s).error?
|
138
|
+
1
|
139
|
+
elsif !shell_out_compact_timeout("dpkg", "--compare-versions", v1.to_s, "eq", v2.to_s).error?
|
140
|
+
0
|
141
|
+
else
|
142
|
+
-1
|
143
|
+
end
|
135
144
|
end
|
136
145
|
|
137
146
|
# Runs command via shell_out with magic environment to disable
|
@@ -106,6 +106,22 @@ class Chef
|
|
106
106
|
|
107
107
|
private
|
108
108
|
|
109
|
+
# compare 2 versions to each other to see which is newer.
|
110
|
+
# this differs from the standard package method because we
|
111
|
+
# need to be able to parse debian version strings which contain
|
112
|
+
# tildes which Gem cannot properly parse
|
113
|
+
#
|
114
|
+
# @return [Integer] 1 if v1 > v2. 0 if they're equal. -1 if v1 < v2
|
115
|
+
def version_compare(v1, v2)
|
116
|
+
if !shell_out_compact_timeout("dpkg", "--compare-versions", v1.to_s, "gt", v2.to_s).error?
|
117
|
+
1
|
118
|
+
elsif !shell_out_compact_timeout("dpkg", "--compare-versions", v1.to_s, "eq", v2.to_s).error?
|
119
|
+
0
|
120
|
+
else
|
121
|
+
-1
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
109
125
|
def read_current_version_of_package(package_name)
|
110
126
|
Chef::Log.debug("#{new_resource} checking install state of #{package_name}")
|
111
127
|
status = shell_out_compact_timeout!("dpkg", "-s", package_name, returns: [0, 1])
|
data/lib/chef/version.rb
CHANGED
@@ -17,6 +17,8 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require "spec_helper"
|
20
|
+
require "mixlib/shellout"
|
21
|
+
require "chef/mixin/user_context"
|
20
22
|
if Chef::Platform.windows?
|
21
23
|
require "chef/win32/security"
|
22
24
|
end
|
@@ -26,13 +28,37 @@ describe "Chef::Win32::Security", :windows_only do
|
|
26
28
|
expect(Chef::ReservedNames::Win32::Security.has_admin_privileges?).to eq(true)
|
27
29
|
end
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
describe "running as non admin user" do
|
32
|
+
include Chef::Mixin::UserContext
|
33
|
+
let(:user) { "security_user" }
|
34
|
+
let(:password) { "Security@123" }
|
35
|
+
|
36
|
+
let(:domain) do
|
37
|
+
whoami = Mixlib::ShellOut.new("whoami")
|
38
|
+
whoami.run_command
|
39
|
+
whoami.error!
|
40
|
+
whoami.stdout.split("\\")[0]
|
41
|
+
end
|
42
|
+
before do
|
43
|
+
allow_any_instance_of(Chef::Mixin::UserContext).to receive(:node).and_return({ "platform_family" => "windows" })
|
44
|
+
allow(Chef::Platform).to receive(:windows_server_2003?).and_return(false)
|
45
|
+
allow(Chef::ReservedNames::Win32::Security).to receive(:OpenProcessToken).and_return(true)
|
46
|
+
add_user = Mixlib::ShellOut.new("net user #{user} #{password} /ADD")
|
47
|
+
add_user.run_command
|
48
|
+
add_user.error!
|
49
|
+
end
|
50
|
+
|
51
|
+
after do
|
52
|
+
delete_user = Mixlib::ShellOut.new("net user #{user} /delete")
|
53
|
+
delete_user.run_command
|
54
|
+
delete_user.error!
|
55
|
+
end
|
56
|
+
it "has_admin_privileges? returns false" do
|
57
|
+
has_admin_privileges = with_user_context(user, password, domain) do
|
58
|
+
Chef::ReservedNames::Win32::Security.has_admin_privileges?
|
59
|
+
end
|
60
|
+
expect(has_admin_privileges).to eq(false)
|
61
|
+
end
|
36
62
|
end
|
37
63
|
|
38
64
|
describe "get_file_security" do
|
@@ -475,6 +475,40 @@ mpg123 1.12.1-0ubuntu1
|
|
475
475
|
end
|
476
476
|
end
|
477
477
|
|
478
|
+
describe "#action_install" do
|
479
|
+
it "should run dpkg to compare versions if an existing version is installed" do
|
480
|
+
allow(@provider).to receive(:get_current_versions).and_return("1.4.0")
|
481
|
+
allow(@new_resource).to receive(:allow_downgrade).and_return(false)
|
482
|
+
expect(@provider).to receive(:shell_out_compact_timeout).with(
|
483
|
+
"dpkg", "--compare-versions", "1.4.0", "gt", "0.8.12-7"
|
484
|
+
).and_return(double(error?: false))
|
485
|
+
@provider.run_action(:upgrade)
|
486
|
+
end
|
487
|
+
|
488
|
+
it "should install the package if the installed version is older" do
|
489
|
+
allow(@provider).to receive(:get_current_versions).and_return("0.4.0")
|
490
|
+
allow(@new_resource).to receive(:allow_downgrade).and_return(false)
|
491
|
+
expect(@provider).to receive(:version_compare).and_return(-1)
|
492
|
+
expect(@provider).to receive(:shell_out!).with(
|
493
|
+
"apt-get", "-q", "-y", "install", "irssi=0.8.12-7",
|
494
|
+
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
|
495
|
+
:timeout => @timeout
|
496
|
+
)
|
497
|
+
@provider.run_action(:upgrade)
|
498
|
+
end
|
499
|
+
|
500
|
+
it "should not compare versions if an existing version is not installed" do
|
501
|
+
allow(@provider).to receive(:get_current_versions).and_return(nil)
|
502
|
+
allow(@new_resource).to receive(:allow_downgrade).and_return(false)
|
503
|
+
expect(@provider).not_to receive(:version_compare)
|
504
|
+
expect(@provider).to receive(:shell_out!).with(
|
505
|
+
"apt-get", "-q", "-y", "install", "irssi=0.8.12-7",
|
506
|
+
:env => { "DEBIAN_FRONTEND" => "noninteractive" },
|
507
|
+
:timeout => @timeout
|
508
|
+
)
|
509
|
+
@provider.run_action(:upgrade)
|
510
|
+
end
|
511
|
+
end
|
478
512
|
end
|
479
513
|
end
|
480
514
|
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: 13.6.
|
4
|
+
version: 13.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef-config
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 13.6.
|
19
|
+
version: 13.6.4
|
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: 13.6.
|
26
|
+
version: 13.6.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mixlib-cli
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -2645,7 +2645,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
2645
2645
|
version: '0'
|
2646
2646
|
requirements: []
|
2647
2647
|
rubyforge_project:
|
2648
|
-
rubygems_version: 2.6.
|
2648
|
+
rubygems_version: 2.6.14
|
2649
2649
|
signing_key:
|
2650
2650
|
specification_version: 4
|
2651
2651
|
summary: A systems integration framework, built to bring the benefits of configuration
|