diff options
author | John Keiser <john@johnkeiser.com> | 2016-08-03 08:53:05 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2016-08-03 14:16:52 -0700 |
commit | ea3ccf9d95ef751e1f2efe1a645648e75e7add24 (patch) | |
tree | 2448697b8b4da94ee3169ea156fe0e8e2633a379 /lib/chef | |
parent | f34d47a1ffc29291c0ea9f544254ccaf0c9db319 (diff) | |
download | chef-ea3ccf9d95ef751e1f2efe1a645648e75e7add24.tar.gz |
Fix Ruby 2.3 `symlink?` when symlink points to nonexistent file
Diffstat (limited to 'lib/chef')
-rw-r--r-- | lib/chef/file_access_control/windows.rb | 6 | ||||
-rw-r--r-- | lib/chef/win32/file.rb | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/chef/file_access_control/windows.rb b/lib/chef/file_access_control/windows.rb index 6b7184bbd3..6f1ac5f581 100644 --- a/lib/chef/file_access_control/windows.rb +++ b/lib/chef/file_access_control/windows.rb @@ -128,7 +128,7 @@ class Chef end def should_update_dacl? - return true unless ::File.exists?(file) + return true unless ::File.exists?(file) || ::File.symlink?(file) dacl = target_dacl existing_dacl = existing_descriptor.dacl inherits = target_inherits @@ -161,7 +161,7 @@ class Chef end def should_update_group? - return true unless ::File.exists?(file) + return true unless ::File.exists?(file) || ::File.symlink?(file) (group = target_group) && (group != existing_descriptor.group) end @@ -180,7 +180,7 @@ class Chef end def should_update_owner? - return true unless ::File.exists?(file) + return true unless ::File.exists?(file) || ::File.symlink?(file) (owner = target_owner) && (owner != existing_descriptor.owner) end diff --git a/lib/chef/win32/file.rb b/lib/chef/win32/file.rb index 2a8f453432..1009f8c5a9 100644 --- a/lib/chef/win32/file.rb +++ b/lib/chef/win32/file.rb @@ -39,7 +39,7 @@ class Chef # returns nil as per MRI. # def self.link(old_name, new_name) - raise Errno::ENOENT, "(#{old_name}, #{new_name})" unless ::File.exist?(old_name) + raise Errno::ENOENT, "(#{old_name}, #{new_name})" unless ::File.exist?(old_name) || ::File.symlink?(old_name) # TODO do a check for CreateHardLinkW and # raise NotImplemented exception on older Windows old_name = encode_path(old_name) @@ -56,7 +56,7 @@ class Chef # returns nil as per MRI. # def self.symlink(old_name, new_name) - # raise Errno::ENOENT, "(#{old_name}, #{new_name})" unless ::File.exist?(old_name) + # raise Errno::ENOENT, "(#{old_name}, #{new_name})" unless ::File.exist?(old_name) || ::File.symlink?(old_name) # TODO do a check for CreateSymbolicLinkW and # raise NotImplemented exception on older Windows flags = ::File.directory?(old_name) ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0 @@ -75,7 +75,7 @@ class Chef def self.symlink?(file_name) is_symlink = false path = encode_path(file_name) - if ::File.exists?(file_name) + if ::File.exists?(file_name) || ::File.symlink?(file_name) if (GetFileAttributesW(path) & FILE_ATTRIBUTE_REPARSE_POINT) > 0 file_search_handle(file_name) do |handle, find_data| if find_data[:dw_reserved_0] == IO_REPARSE_TAG_SYMLINK @@ -93,7 +93,7 @@ class Chef # will raise a NotImplementedError, as per MRI. # def self.readlink(link_name) - raise Errno::ENOENT, link_name unless ::File.exists?(link_name) + raise Errno::ENOENT, link_name unless ::File.exists?(link_name) || ::File.symlink?(link_name) symlink_file_handle(link_name) do |handle| # Go to DeviceIoControl to get the symlink information # http://msdn.microsoft.com/en-us/library/windows/desktop/aa364571(v=vs.85).aspx |