diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-02-19 15:17:05 -0800 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-02-19 15:17:05 -0800 |
commit | 864f9ac95063c7833235c8ed50dcb89653eda03f (patch) | |
tree | 93da186fd522bdfc5de6414d011f4c0dd49aeb40 /lib/chef/win32/file.rb | |
parent | 194f49bdb7737e0591271ba95021997e90379c5d (diff) | |
parent | a7f5c92960aedf8d5bfc71abbce430ab075e016a (diff) | |
download | chef-jdm/merge-into-12-stable.tar.gz |
Merge remote-tracking branch 'origin/master' into HEADjdm/merge-into-12-stable
* origin/master: (642 commits)
Remove Chef 12 release notes
Update Changelog for Chef 12.1.0
Chef 12.1.0.rc.0
Group spec needs to respond to shell_out
fix dpkg regression
fix Lint/BlockAlignment
whitespaces fixes
fix Lint/AmbiguousRegexpLiteral
fix Lint/LiteralInCondition
fix Lint/Loop style
Make tests pass on Windows
remove unreachable code
Fix unit specs for PR #2934
dont raise exceptions in load_current_resource when checking current status
update changelog
fix typo in msi provider
Added spec for #2914
fix virtual package logic in check_package_state
use scalar pkg not array package
convert is_virtual_package to hash
...
Conflicts:
.travis.yml
CHANGELOG.md
DOC_CHANGES.md
RELEASE_NOTES.md
appveyor.yml
lib/chef/application.rb
lib/chef/dsl/recipe.rb
lib/chef/knife/bootstrap.rb
lib/chef/knife/core/bootstrap_context.rb
lib/chef/node/attribute.rb
lib/chef/node/attribute_collections.rb
lib/chef/node/immutable_collections.rb
lib/chef/resource.rb
lib/chef/run_context.rb
lib/chef/version.rb
spec/functional/dsl/reboot_pending_spec.rb
spec/functional/event_loggers/windows_eventlog_spec.rb
spec/functional/resource/link_spec.rb
spec/support/platform_helpers.rb
spec/unit/knife_spec.rb
spec/unit/mixin/deep_merge_spec.rb
spec/unit/mixin/shell_out_spec.rb
spec/unit/node/attribute_spec.rb
spec/unit/node_spec.rb
spec/unit/provider/package/apt_spec.rb
spec/unit/provider/service/systemd_service_spec.rb
spec/unit/provider_resolver_spec.rb
spec/unit/recipe_spec.rb
spec/unit/resource/resource_notification_spec.rb
spec/unit/run_context_spec.rb
Diffstat (limited to 'lib/chef/win32/file.rb')
-rw-r--r-- | lib/chef/win32/file.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/chef/win32/file.rb b/lib/chef/win32/file.rb index d489c9ce8a..e6640caa3c 100644 --- a/lib/chef/win32/file.rb +++ b/lib/chef/win32/file.rb @@ -155,6 +155,27 @@ class Chef end 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 | + Chef::ReservedNames::Win32::Security::TOKEN_QUERY | + Chef::ReservedNames::Win32::Security::TOKEN_DUPLICATE | + Chef::ReservedNames::Win32::Security::STANDARD_RIGHTS_READ + token = Chef::ReservedNames::Win32::Security.open_process_token( + Chef::ReservedNames::Win32::Process.get_current_process, + token_rights) + duplicate_token = token.duplicate_token(:SecurityImpersonation) + + mapping = Chef::ReservedNames::Win32::Security::GENERIC_MAPPING.new + mapping[:GenericRead] = Chef::ReservedNames::Win32::Security::FILE_GENERIC_READ + mapping[:GenericWrite] = Chef::ReservedNames::Win32::Security::FILE_GENERIC_WRITE + mapping[:GenericExecute] = Chef::ReservedNames::Win32::Security::FILE_GENERIC_EXECUTE + mapping[:GenericAll] = Chef::ReservedNames::Win32::Security::FILE_ALL_ACCESS + + Chef::ReservedNames::Win32::Security.access_check(security_descriptor, duplicate_token, + desired_access, mapping) + end + # ::File compat class << self alias :stat :info |