diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-02-11 17:23:21 -0800 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-02-11 17:23:21 -0800 |
commit | 34ef6beb660e9135edc81c43c804af9bc09df915 (patch) | |
tree | 332442c6d76e42f21c2f4d2064b76924a041a3d2 | |
parent | 29355c7ae39e63ac1fc7b785d7c15da7c6d90458 (diff) | |
download | chef-34ef6beb660e9135edc81c43c804af9bc09df915.tar.gz |
Add writable? to FileAccessControl
-rw-r--r-- | lib/chef/file_access_control/unix.rb | 10 | ||||
-rw-r--r-- | lib/chef/file_access_control/windows.rb | 12 |
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/chef/file_access_control/unix.rb b/lib/chef/file_access_control/unix.rb index a5d177d47d..81ca6fe281 100644 --- a/lib/chef/file_access_control/unix.rb +++ b/lib/chef/file_access_control/unix.rb @@ -26,6 +26,16 @@ class Chef UINT = (1 << 32) UID_MAX = (1 << 32) - 10 + module ClassMethods + def writable?(path) + ::File.writable?(path) + end + end + + def self.included(base) + base.send :extend, ClassMethods + end + def set_all! set_owner! set_group! diff --git a/lib/chef/file_access_control/windows.rb b/lib/chef/file_access_control/windows.rb index 32ac2996bd..2f0e2c709a 100644 --- a/lib/chef/file_access_control/windows.rb +++ b/lib/chef/file_access_control/windows.rb @@ -18,6 +18,7 @@ # require 'chef/win32/security' +require 'chef/win32/file' class Chef class FileAccessControl @@ -29,6 +30,17 @@ class Chef ACE = Security::ACE SID = Security::SID + module ClassMethods + def writable?(path) + ::File.exists?(path) && Chef::ReservedNames::Win32::File.file_access_check( + path, Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_WRITE) + end + end + + def self.included(base) + base.send :extend, ClassMethods + end + def set_all! set_owner! set_group! |