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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 061c506cbf2b89efb7f6cd0a3c34c3899fedf6e1
4
- data.tar.gz: a5a41b7f39a7fa9bb3a0144d73ce16ebb9785051
3
+ metadata.gz: be0e226d4b48be835191333a6e6bb427cf070361
4
+ data.tar.gz: 04b92a7521c888b8b2008f62939abc31850c9a2f
5
5
  SHA512:
6
- metadata.gz: b639f26cb03a65f90db1bd19a40d9acbcffc4dba82a24aa99ea7307f82c90ec78814924eb064b377f4876cbfe79131ae6b2f77295d3112b34a5c7d4de2ee546d
7
- data.tar.gz: e0d4542426510bb753a270016498566c8111566f3304c3d20dc091217950814cdaf36f2fc1e2e9682a84ea481b8f7d02ffffa64526e5e6705fa7b21d3feb1b83
6
+ metadata.gz: 426710a08713f6828882d512b3441f5006b3bbaa404238b1f6771d714dc87c398ba357355a82bc0dce25d0a868e0c080cdeaff69bde16061a29578c52954f5bf
7
+ data.tar.gz: aa6b69eb678093ac3788ebb55caa8524743fd9122c91a2d3124d6e8bc0bfb0446066d1149c434994bfdd38225482064c22ade9e4e226a25152bb84fc679e1d8d
data/VERSION CHANGED
@@ -1 +1 @@
1
- 13.6.0
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
- gem_v1 = v1.gsub(/[_+]/, "+" => "-", "_" => "-") unless v1.nil?
132
- gem_v2 = v2.gsub(/[_+]/, "+" => "-", "_" => "-") unless v2.nil?
133
-
134
- Gem::Version.new(gem_v1) <=> Gem::Version.new(gem_v2)
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])
@@ -23,7 +23,7 @@ require "chef/version_string"
23
23
 
24
24
  class Chef
25
25
  CHEF_ROOT = File.expand_path("../..", __FILE__)
26
- VERSION = Chef::VersionString.new("13.6.0")
26
+ VERSION = Chef::VersionString.new("13.6.4")
27
27
  end
28
28
 
29
29
  #
@@ -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
- # We've done some investigation adding a negative test and it turned
30
- # out to be a lot of work since mixlib-shellout doesn't have user
31
- # support for windows.
32
- #
33
- # TODO - Add negative tests once mixlib-shellout has user support
34
- it "has_admin_privileges? returns false when running as non-admin" do
35
- skip "requires user support in mixlib-shellout"
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.0
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-10-27 00:00:00.000000000 Z
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.0
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.0
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.13
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