diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-02-11 17:23:21 -0800 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2015-02-17 09:24:45 -0500 |
commit | e6981adeb7b1cb5622249d301d6bb3377dc89659 (patch) | |
tree | f42cfdd3348e91e3bee8838d930fdc85b764ddf1 | |
parent | 7b3adb30399daf3cb32a738a0f8b93e4a95e95b1 (diff) | |
download | chef-e6981adeb7b1cb5622249d301d6bb3377dc89659.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! |