summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-03-05 20:37:08 -0800
committerTim Smith <tsmith84@gmail.com>2020-03-05 20:37:08 -0800
commit7c6ef6bff121a22a9346c8559196e5661551df32 (patch)
tree1f19ac4fa82694a137d2d6e3934d3bda101a32a6
parente06e4ae6833fb2ef7cadd154130914aaf300420d (diff)
downloadchef-link_check.tar.gz
link resource: Remove checks for link support on Windowslink_check
2008+ have support for links. There's no reason to perform this check every time on Windows. It's just wasting CPU cycles Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/link.rb23
-rw-r--r--lib/chef/win32/file.rb12
-rw-r--r--spec/unit/provider/link_spec.rb3
-rw-r--r--spec/unit/resource/link_spec.rb6
4 files changed, 5 insertions, 39 deletions
diff --git a/lib/chef/resource/link.rb b/lib/chef/resource/link.rb
index df4ab81dd1..8c9e522b87 100644
--- a/lib/chef/resource/link.rb
+++ b/lib/chef/resource/link.rb
@@ -1,7 +1,7 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Tyler Cloke (<tyler@chef.io>)
-# Copyright:: Copyright 2008-2019, Chef Software Inc.
+# Copyright:: Copyright 2008-2020, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -44,11 +44,6 @@ class Chef
default_action :create
allowed_actions :create, :delete
- def initialize(name, run_context = nil)
- verify_links_supported!
- super
- end
-
property :target_file, String,
description: "An optional property to set the target file if it differs from the resource block's name.",
name_property: true, identity: true
@@ -73,22 +68,6 @@ class Chef
def path
target_file
end
-
- private
-
- # On certain versions of windows links are not supported. Make
- # sure we are not on such a platform.
- def verify_links_supported!
- if ChefUtils.windows?
- require_relative "../win32/file"
- begin
- Chef::ReservedNames::Win32::File.verify_links_supported!
- rescue Chef::Exceptions::Win32APIFunctionNotImplemented => e
- Chef::Log.fatal("Link resource is not supported on this version of Windows")
- raise e
- end
- end
- end
end
end
end
diff --git a/lib/chef/win32/file.rb b/lib/chef/win32/file.rb
index 4fac3fe797..ccbff43f01 100644
--- a/lib/chef/win32/file.rb
+++ b/lib/chef/win32/file.rb
@@ -1,7 +1,7 @@
#
# Author:: Seth Chisamore (<schisamo@chef.io>)
-# Author:: Mark Mzyk (<mmzyk@ospcode.com>)
-# Copyright:: Copyright 2011-2016, Chef Software Inc.
+# Author:: Mark Mzyk (<mmzyk@chef.io>)
+# Copyright:: Copyright 2011-2020, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -166,14 +166,6 @@ class Chef
VersionInfo.new(file_name)
end
- def self.verify_links_supported!
- CreateSymbolicLinkW(nil)
- rescue Chef::Exceptions::Win32APIFunctionNotImplemented => e
- raise e
- rescue Exception
- # things are ok.
- end
-
def self.file_access_check(path, desired_access)
security_descriptor = Chef::ReservedNames::Win32::Security.get_file_security(path)
token_rights = Chef::ReservedNames::Win32::Security::TOKEN_IMPERSONATE |
diff --git a/spec/unit/provider/link_spec.rb b/spec/unit/provider/link_spec.rb
index 154197e730..30c752b5ea 100644
--- a/spec/unit/provider/link_spec.rb
+++ b/spec/unit/provider/link_spec.rb
@@ -1,7 +1,7 @@
#
# Author:: AJ Christensen (<aj@junglist.gen.nz>)
# Author:: John Keiser (<jkeiser@chef.io>)
-# Copyright:: Copyright 2008-2018, Chef Software Inc.
+# Copyright:: Copyright 2008-2020, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -358,7 +358,6 @@ describe Chef::Resource::Link do
allow(Chef::Resource::Link).to receive(:new).with(
provider.new_resource.name
).and_return(resource_link)
- allow(resource_link).to receive(:verify_links_supported!)
allow(ChefUtils).to receive(:windows?).and_return(true)
end
diff --git a/spec/unit/resource/link_spec.rb b/spec/unit/resource/link_spec.rb
index ae32e4aa30..792305ee55 100644
--- a/spec/unit/resource/link_spec.rb
+++ b/spec/unit/resource/link_spec.rb
@@ -1,7 +1,7 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Tyler Cloke (<tyler@chef.io>)
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2020, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,10 +22,6 @@ require "spec_helper"
describe Chef::Resource::Link do
let(:resource) { Chef::Resource::Link.new("fakey_fakerton") }
- before(:each) do
- expect_any_instance_of(Chef::Resource::Link).to receive(:verify_links_supported!).and_return(true)
- end
-
it "the target_file property is the name_property" do
expect(resource.target_file).to eql("fakey_fakerton")
end