Skip to content

Commit

Permalink
Merge pull request #300 from puppetlabs/CAT-1839-pdk-test-fix-on-non-…
Browse files Browse the repository at this point in the history
…windows

(CAT-1839) - PDK test fixes on non windows machine
  • Loading branch information
Ramesh7 authored Jun 27, 2024
2 parents d0ff408 + e868726 commit 0cf7290
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/puppet/provider/acl/windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def validate
case @resource[:target_type]
when :file
# Target may not be set, this is called prior to initialize
if Puppet::Util::Windows::File.symlink?(@resource[:target] || @resource[:name])
if Puppet::Util::Windows::File.respond_to?(:symlink?) && Puppet::Util::Windows::File.symlink?(@resource[:target] || @resource[:name])
raise Puppet::ResourceError, "Puppet cannot manage ACLs of symbolic links (symlinks) on Windows. Resource target '#{@resource[:target] || @resource[:name]}' is a symlink."
end
end
Expand Down
24 changes: 9 additions & 15 deletions lib/puppet/provider/acl/windows/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,35 +108,29 @@ module Base
#
# @note Puppet 3.7 deprecated methods at old locations in favor of SID class
def name_to_sid(name)
if Puppet::Util::Windows::SID.respond_to?(:name_to_sid)
Puppet::Util::Windows::SID.name_to_sid(name)
else
Puppet::Util::Windows::Security.name_to_sid(name)
end
return Puppet::Util::Windows::SID.name_to_sid(name) if Puppet::Util::Windows::SID.respond_to?(:name_to_sid)

defined?(Puppet::Util::Windows::Security) && Puppet::Util::Windows::Security.respond_to?(:name_to_sid) && Puppet::Util::Windows::Security.name_to_sid(name)
end

# Converts an SID string to an account name.
#
# @param [String] value SID string
# @return [String] Extracted name
def sid_to_name(value)
if Puppet::Util::Windows::SID.respond_to?(:sid_to_name)
Puppet::Util::Windows::SID.sid_to_name(value)
else
Puppet::Util::Windows::Security.sid_to_name(value)
end
return Puppet::Util::Windows::SID.sid_to_name(value) if Puppet::Util::Windows::SID.respond_to?(:sid_to_name)

defined?(Puppet::Util::Windows::Security) && Puppet::Util::Windows::Security.respond_to?(:sid_to_name) && Puppet::Util::Windows::Security.sid_to_name(value)
end

# Checks if supplied SID string is valid
#
# @param [String] string_sid SID string
# @return [Bool] Whether supplied string is a valid SID
def valid_sid?(string_sid)
if Puppet::Util::Windows::SID.respond_to?(:valid_sid?)
Puppet::Util::Windows::SID.valid_sid?(string_sid)
else
Puppet::Util::Windows::Security.valid_sid?(string_sid)
end
return Puppet::Util::Windows::SID.valid_sid?(string_sid) if Puppet::Util::Windows::SID.respond_to?(:valid_sid?)

defined?(Puppet::Util::Windows::Security) && Puppet::Util::Windows::Security.respond_to?(:valid_sid?) && Puppet::Util::Windows::Security.valid_sid?(string_sid)
end

# Retrieves permissions of current instance.
Expand Down

0 comments on commit 0cf7290

Please sign in to comment.