summaryrefslogtreecommitdiff
path: root/lib/chef/win32
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/win32')
-rw-r--r--lib/chef/win32/api.rb2
-rw-r--r--lib/chef/win32/api/crypto.rb6
-rw-r--r--lib/chef/win32/api/error.rb12
-rw-r--r--lib/chef/win32/api/file.rb19
-rw-r--r--lib/chef/win32/api/installer.rb19
-rw-r--r--lib/chef/win32/api/net.rb2
-rw-r--r--lib/chef/win32/api/registry.rb2
-rw-r--r--lib/chef/win32/api/security.rb27
-rw-r--r--lib/chef/win32/file.rb10
-rw-r--r--lib/chef/win32/file/info.rb1
-rw-r--r--lib/chef/win32/file/version_info.rb2
-rw-r--r--lib/chef/win32/net.rb10
-rw-r--r--lib/chef/win32/registry.rb15
-rw-r--r--lib/chef/win32/security.rb11
-rw-r--r--lib/chef/win32/security/acl.rb6
-rw-r--r--lib/chef/win32/security/sid.rb38
-rw-r--r--lib/chef/win32/unicode.rb4
-rw-r--r--lib/chef/win32/version.rb38
18 files changed, 122 insertions, 102 deletions
diff --git a/lib/chef/win32/api.rb b/lib/chef/win32/api.rb
index e7cd3b5bd0..ad65b087cc 100644
--- a/lib/chef/win32/api.rb
+++ b/lib/chef/win32/api.rb
@@ -239,7 +239,7 @@ class Chef
# In WinNT.h: host.typedef wchar_t WCHAR;
#WINAPI: K, # Calling convention for system functions. WinDef.h: define WINAPI __stdcall
host.typedef :ushort, :WORD # 16-bit unsigned integer. The range is 0 through 65535 decimal.
- host.typedef :uint, :WPARAM # Message parameter. WinDef.h as follows: host.typedef UINT_PTR WPARAM;
+ host.typedef :uint, :WPARAM # Message parameter. WinDef.h as follows: host.typedef UINT_PTR WPARAM;
end
module Macros
diff --git a/lib/chef/win32/api/crypto.rb b/lib/chef/win32/api/crypto.rb
index a2c44dcb42..0abb908622 100644
--- a/lib/chef/win32/api/crypto.rb
+++ b/lib/chef/win32/api/crypto.rb
@@ -35,9 +35,9 @@ class Chef
CRYPTPROTECT_AUDIT = 0x10
class CRYPT_INTEGER_BLOB < FFI::Struct
- layout :cbData, :DWORD, # Count, in bytes, of data
+ layout :cbData, :DWORD, # Count, in bytes, of data
:pbData, :pointer # Pointer to data buffer
- def initialize(str=nil)
+ def initialize(str = nil)
super(nil)
if str
self[:pbData] = FFI::MemoryPointer.from_string(str)
@@ -48,7 +48,7 @@ class Chef
end
safe_attach_function :CryptProtectData, [
- :PDATA_BLOB,
+ :PDATA_BLOB,
:LPCWSTR,
:PDATA_BLOB,
:pointer,
diff --git a/lib/chef/win32/api/error.rb b/lib/chef/win32/api/error.rb
index 0b10fc6e3d..aa80f89743 100644
--- a/lib/chef/win32/api/error.rb
+++ b/lib/chef/win32/api/error.rb
@@ -178,7 +178,7 @@ class Chef
ERROR_LOCK_FAILED = 167
ERROR_BUSY = 170
ERROR_CANCEL_VIOLATION = 173
- ERROR_ATOMIC_LOCKS_NOT_SUPPORTED= 174
+ ERROR_ATOMIC_LOCKS_NOT_SUPPORTED = 174
ERROR_INVALID_SEGMENT_NUMBER = 180
ERROR_INVALID_CALLGATE = 181
@@ -446,7 +446,7 @@ class Chef
ERROR_DOWNGRADE_DETECTED = 1265
ERROR_MACHINE_LOCKED = 1271
ERROR_CALLBACK_SUPPLIED_INVALID_DATA = 1273
- ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED= 1274
+ ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED = 1274
ERROR_DRIVER_BLOCKED = 1275
ERROR_INVALID_IMPORT_OF_NON_DLL = 1276
ERROR_NOT_ALL_ASSIGNED = 1300
@@ -750,7 +750,7 @@ class Chef
ERROR_NETLOGON_NOT_STARTED = 1792
ERROR_ACCOUNT_EXPIRED = 1793
ERROR_REDIRECTOR_HAS_OPEN_HANDLES = 1794
- ERROR_PRINTER_DRIVER_ALREADY_INSTALLED= 1795
+ ERROR_PRINTER_DRIVER_ALREADY_INSTALLED = 1795
ERROR_UNKNOWN_PORT = 1796
ERROR_UNKNOWN_PRINTER_DRIVER = 1797
ERROR_UNKNOWN_PRINTPROCESSOR = 1798
@@ -824,9 +824,9 @@ class Chef
ERROR_CONTEXT_EXPIRED = 1931
ERROR_PER_USER_TRUST_QUOTA_EXCEEDED = 1932
ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED = 1933
- ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED= 1934
- ERROR_AUTHENTICATION_FIREWALL_FAILED = 1935
- ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED= 1936
+ ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED = 1934
+ ERROR_AUTHENTICATION_FIREWALL_FAILED = 1935
+ ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED = 1936
ERROR_INVALID_PIXEL_FORMAT = 2000
ERROR_BAD_DRIVER = 2001
ERROR_INVALID_WINDOW_STYLE = 2002
diff --git a/lib/chef/win32/api/file.rb b/lib/chef/win32/api/file.rb
index 992c595e9a..52ac4868c7 100644
--- a/lib/chef/win32/api/file.rb
+++ b/lib/chef/win32/api/file.rb
@@ -163,7 +163,7 @@ class Chef
(device_type << 16) | (access << 14) | (function << 2) | method
end
- FSCTL_GET_REPARSE_POINT = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
+ FSCTL_GET_REPARSE_POINT = CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
# Reparse point tags
IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003
@@ -176,7 +176,7 @@ class Chef
IO_REPARSE_TAG_SYMLINK = 0xA000000C
IO_REPARSE_TAG_DFSR = 0x80000012
- MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16*1024
+ MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16 * 1024
###############################################
# Win32 API Bindings
@@ -238,7 +238,7 @@ typedef struct _WIN32_FIND_DATA {
:n_file_size_low, :DWORD,
:dw_reserved_0, :DWORD,
:dw_reserved_1, :DWORD,
- :c_file_name, [:BYTE, MAX_PATH*2],
+ :c_file_name, [:BYTE, MAX_PATH * 2],
:c_alternate_file_name, [:BYTE, 14]
end
@@ -307,11 +307,12 @@ typedef struct _REPARSE_DATA_BUFFER {
def substitute_name
string_pointer = FFI::Pointer.new(pointer.address) + offset_of(:PathBuffer) + self[:SubstituteNameOffset]
- string_pointer.read_wstring(self[:SubstituteNameLength]/2)
+ string_pointer.read_wstring(self[:SubstituteNameLength] / 2)
end
+
def print_name
string_pointer = FFI::Pointer.new(pointer.address) + offset_of(:PathBuffer) + self[:PrintNameOffset]
- string_pointer.read_wstring(self[:PrintNameLength]/2)
+ string_pointer.read_wstring(self[:PrintNameLength] / 2)
end
end
class REPARSE_DATA_BUFFER_MOUNT_POINT < FFI::Struct
@@ -323,11 +324,12 @@ typedef struct _REPARSE_DATA_BUFFER {
def substitute_name
string_pointer = FFI::Pointer.new(pointer.address) + offset_of(:PathBuffer) + self[:SubstituteNameOffset]
- string_pointer.read_wstring(self[:SubstituteNameLength]/2)
+ string_pointer.read_wstring(self[:SubstituteNameLength] / 2)
end
+
def print_name
string_pointer = FFI::Pointer.new(pointer.address) + offset_of(:PathBuffer) + self[:PrintNameOffset]
- string_pointer.read_wstring(self[:PrintNameLength]/2)
+ string_pointer.read_wstring(self[:PrintNameLength] / 2)
end
end
class REPARSE_DATA_BUFFER_GENERIC < FFI::Struct
@@ -458,7 +460,6 @@ BOOL WINAPI DeviceIoControl(
=end
safe_attach_function :DeviceIoControl, [:HANDLE, :DWORD, :LPVOID, :DWORD, :LPVOID, :DWORD, :LPDWORD, :pointer], :BOOL
-
#BOOL WINAPI DeleteVolumeMountPoint(
#_In_ LPCTSTR lpszVolumeMountPoint
#);
@@ -606,7 +607,7 @@ BOOL WINAPI VerQueryValue(
if file_size == 0
Chef::ReservedNames::Win32::Error.raise!
end
-
+
version_info = FFI::MemoryPointer.new(file_size)
unless GetFileVersionInfoW(file_name, 0, file_size, version_info)
Chef::ReservedNames::Win32::Error.raise!
diff --git a/lib/chef/win32/api/installer.rb b/lib/chef/win32/api/installer.rb
index e1be747245..caf7b23f59 100644
--- a/lib/chef/win32/api/installer.rb
+++ b/lib/chef/win32/api/installer.rb
@@ -32,7 +32,6 @@ class Chef
# Win32 API Constants
###############################################
-
###############################################
# Win32 API Bindings
###############################################
@@ -94,7 +93,7 @@ UINT MsiCloseHandle(
msg << Chef::ReservedNames::Win32::Error.format_message(status)
raise Chef::Exceptions::Package, msg
end
-
+
buffer_length = FFI::Buffer.new(:long).write_long(buffer_length.read_long + 1)
buffer = 0.chr * buffer_length.read_long
@@ -114,18 +113,18 @@ UINT MsiCloseHandle(
# Opens a Microsoft Installer (MSI) file from an absolute path and returns a pointer to a handle
# Remember to close the handle with msi_close_handle()
def open_package(package_path)
- # MsiOpenPackage expects a perfect absolute Windows path to the MSI
+ # MsiOpenPackage expects a perfect absolute Windows path to the MSI
raise ArgumentError, "Provided path '#{package_path}' must be an absolute path" unless Pathname.new(package_path).absolute?
pkg_ptr = FFI::MemoryPointer.new(:pointer, 4)
status = msi_open_package(package_path, 1, pkg_ptr)
case status
- when 0
+ when 0
# success
else
raise Chef::Exceptions::Package, "msi_open_package: unexpected status #{status}: #{Chef::ReservedNames::Win32::Error.format_message(status)}"
end
- return pkg_ptr
+ return pkg_ptr
end
# All installed product_codes should have a VersionString
@@ -133,11 +132,11 @@ UINT MsiCloseHandle(
def get_installed_version(product_code)
version = 0.chr
version_length = FFI::Buffer.new(:long).write_long(0)
-
+
status = msi_get_product_info(product_code, "VersionString", version, version_length)
-
+
return nil if status == 1605 # ERROR_UNKNOWN_PRODUCT (0x645)
-
+
# We expect error ERROR_MORE_DATA (234) here because we passed a buffer length of 0
if status != 234
msg = "msi_get_product_info: product code '#{product_code}' returned unknown error #{status} when retrieving VersionString: "
@@ -149,9 +148,9 @@ UINT MsiCloseHandle(
version_length = FFI::Buffer.new(:long).write_long(version_length.read_long + 1)
version = 0.chr * version_length.read_long
-
+
status = msi_get_product_info(product_code, "VersionString", version, version_length)
-
+
if status != 0
msg = "msi_get_product_info: product code '#{product_code}' returned unknown error #{status} when retrieving VersionString: "
msg << Chef::ReservedNames::Win32::Error.format_message(status)
diff --git a/lib/chef/win32/api/net.rb b/lib/chef/win32/api/net.rb
index fdbe55579f..bec00f638a 100644
--- a/lib/chef/win32/api/net.rb
+++ b/lib/chef/win32/api/net.rb
@@ -90,7 +90,6 @@ class Chef
end
end
-
class USER_INFO_3 < FFI::Struct
include StructHelpers
layout :usri3_name, :LPWSTR,
@@ -159,7 +158,6 @@ class Chef
:ui2_domainname, :LMSTR
end
-
#NET_API_STATUS NetLocalGroupAdd(
#_In_ LPCWSTR servername,
#_In_ DWORD level,
diff --git a/lib/chef/win32/api/registry.rb b/lib/chef/win32/api/registry.rb
index 8f394ad12a..dec25118a3 100644
--- a/lib/chef/win32/api/registry.rb
+++ b/lib/chef/win32/api/registry.rb
@@ -48,4 +48,4 @@ class Chef
end
end
end
-end \ No newline at end of file
+end
diff --git a/lib/chef/win32/api/security.rb b/lib/chef/win32/api/security.rb
index 61c65971be..44968372b5 100644
--- a/lib/chef/win32/api/security.rb
+++ b/lib/chef/win32/api/security.rb
@@ -136,20 +136,10 @@ class Chef
SYNCHRONIZE |
0x1FF
FILE_GENERIC_READ = STANDARD_RIGHTS_READ |
- FILE_READ_DATA |
- FILE_READ_ATTRIBUTES |
- FILE_READ_EA |
- SYNCHRONIZE
- FILE_GENERIC_WRITE = STANDARD_RIGHTS_WRITE |
- FILE_WRITE_DATA |
- FILE_WRITE_ATTRIBUTES |
- FILE_WRITE_EA |
- FILE_APPEND_DATA |
- SYNCHRONIZE
- FILE_GENERIC_EXECUTE = STANDARD_RIGHTS_EXECUTE |
- FILE_READ_ATTRIBUTES |
- FILE_EXECUTE |
- SYNCHRONIZE
+ FILE_READ_DATA | FILE_READ_ATTRIBUTES |
+ FILE_READ_EA | SYNCHRONIZE
+ FILE_GENERIC_WRITE = STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE
+ FILE_GENERIC_EXECUTE = STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE
# Access Token Rights (for OpenProcessToken)
# Access Rights for Access-Token Objects (used in OpenProcessToken)
TOKEN_ASSIGN_PRIMARY = 0x0001
@@ -173,9 +163,7 @@ class Chef
SE_PRIVILEGE_REMOVED = 0X00000004
SE_PRIVILEGE_USED_FOR_ACCESS = 0x80000000
SE_PRIVILEGE_VALID_ATTRIBUTES = SE_PRIVILEGE_ENABLED_BY_DEFAULT |
- SE_PRIVILEGE_ENABLED |
- SE_PRIVILEGE_REMOVED |
- SE_PRIVILEGE_USED_FOR_ACCESS
+ SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_REMOVED | SE_PRIVILEGE_USED_FOR_ACCESS
# Minimum size of a SECURITY_DESCRIPTOR. TODO: this is probably platform dependent.
# Make it work on 64 bit.
@@ -315,7 +303,6 @@ class Chef
:SecurityDelegation,
]
-
# SECURITY_DESCRIPTOR is an opaque structure whose contents can vary. Pass the
# pointer around and free it with LocalFree.
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa379561(v=vs.85).aspx
@@ -384,7 +371,7 @@ class Chef
:Privileges, LUID_AND_ATTRIBUTES
def self.size_with_privileges(num_privileges)
- offset_of(:Privileges) + LUID_AND_ATTRIBUTES.size*num_privileges
+ offset_of(:Privileges) + LUID_AND_ATTRIBUTES.size * num_privileges
end
def size_with_privileges
@@ -431,7 +418,7 @@ class Chef
safe_attach_function :GetAce, [ :pointer, :DWORD, :pointer ], :BOOL
safe_attach_function :GetFileSecurityW, [:LPCWSTR, :DWORD, :pointer, :DWORD, :pointer], :BOOL
safe_attach_function :GetLengthSid, [ :pointer ], :DWORD
- safe_attach_function :GetNamedSecurityInfoW, [ :LPWSTR, :SE_OBJECT_TYPE, :DWORD, :pointer, :pointer, :pointer, :pointer, :pointer ], :DWORD
+ safe_attach_function :GetNamedSecurityInfoW, [ :LPWSTR, :SE_OBJECT_TYPE, :DWORD, :pointer, :pointer, :pointer, :pointer, :pointer ], :DWORD
safe_attach_function :GetSecurityDescriptorControl, [ :pointer, :PWORD, :LPDWORD], :BOOL
safe_attach_function :GetSecurityDescriptorDacl, [ :pointer, :LPBOOL, :pointer, :LPBOOL ], :BOOL
safe_attach_function :GetSecurityDescriptorGroup, [ :pointer, :pointer, :LPBOOL], :BOOL
diff --git a/lib/chef/win32/file.rb b/lib/chef/win32/file.rb
index a0aa34d481..19b17b7d7c 100644
--- a/lib/chef/win32/file.rb
+++ b/lib/chef/win32/file.rb
@@ -125,8 +125,8 @@ class Chef
if size == 0
Chef::ReservedNames::Win32::Error.raise!
end
- result = FFI::MemoryPointer.new :char, (size+1)*2
- if GetShortPathNameW(path, result, size+1) == 0
+ result = FFI::MemoryPointer.new :char, (size + 1) * 2
+ if GetShortPathNameW(path, result, size + 1) == 0
Chef::ReservedNames::Win32::Error.raise!
end
result.read_wstring(size)
@@ -139,8 +139,8 @@ class Chef
if size == 0
Chef::ReservedNames::Win32::Error.raise!
end
- result = FFI::MemoryPointer.new :char, (size+1)*2
- if GetLongPathNameW(path, result, size+1) == 0
+ result = FFI::MemoryPointer.new :char, (size + 1) * 2
+ if GetLongPathNameW(path, result, size + 1) == 0
Chef::ReservedNames::Win32::Error.raise!
end
result.read_wstring(size)
@@ -199,7 +199,7 @@ class Chef
def self.get_volume_name_for_volume_mount_point(mount_point)
buffer = FFI::MemoryPointer.new(2, 128)
- unless GetVolumeNameForVolumeMountPointW(wstring(mount_point), buffer, buffer.size/buffer.type_size)
+ unless GetVolumeNameForVolumeMountPointW(wstring(mount_point), buffer, buffer.size / buffer.type_size)
Chef::ReservedNames::Win32::Error.raise!
end
buffer.read_wstring
diff --git a/lib/chef/win32/file/info.rb b/lib/chef/win32/file/info.rb
index 010bf80079..55873f8a0b 100644
--- a/lib/chef/win32/file/info.rb
+++ b/lib/chef/win32/file/info.rb
@@ -93,7 +93,6 @@ class Chef
file_time_struct[:dw_high_date_time]))
end
-
end
end
end
diff --git a/lib/chef/win32/file/version_info.rb b/lib/chef/win32/file/version_info.rb
index 37cfd944e6..fa04096cf1 100644
--- a/lib/chef/win32/file/version_info.rb
+++ b/lib/chef/win32/file/version_info.rb
@@ -75,7 +75,7 @@ class Chef
end
def to_hex(integer)
- integer.to_s(16).rjust(4,"0")
+ integer.to_s(16).rjust(4, "0")
end
def get_version_info_string(string_key)
diff --git a/lib/chef/win32/net.rb b/lib/chef/win32/net.rb
index 4ee278aa28..0454b17d49 100644
--- a/lib/chef/win32/net.rb
+++ b/lib/chef/win32/net.rb
@@ -40,7 +40,7 @@ class Chef
usri3_priv: 0,
usri3_home_dir: nil,
usri3_comment: nil,
- usri3_flags: UF_SCRIPT|UF_DONT_EXPIRE_PASSWD|UF_NORMAL_ACCOUNT,
+ usri3_flags: UF_SCRIPT | UF_DONT_EXPIRE_PASSWD | UF_NORMAL_ACCOUNT,
usri3_script_path: nil,
usri3_auth_flags: 0,
usri3_full_name: nil,
@@ -63,7 +63,7 @@ class Chef
usri3_profile: nil,
usri3_home_dir_drive: nil,
usri3_password_expired: 0,
- }.each do |(k,v)|
+ }.each do |(k, v)|
s.set(k, v)
end
end
@@ -254,7 +254,7 @@ class Chef
end
end
- def self.net_use_del(server_name, use_name, force=:use_noforce)
+ def self.net_use_del(server_name, use_name, force = :use_noforce)
server_name = wstring(server_name)
use_name = wstring(use_name)
force_const = case force
@@ -296,8 +296,8 @@ class Chef
buf = USE_INFO_2.new
- ui2_hash.each do |(k,v)|
- buf.set(k,v)
+ ui2_hash.each do |(k, v)|
+ buf.set(k, v)
end
rc = NetUseAdd(server_name, 2, buf, nil)
diff --git a/lib/chef/win32/registry.rb b/lib/chef/win32/registry.rb
index 4113e5eb2b..5f8d23b452 100644
--- a/lib/chef/win32/registry.rb
+++ b/lib/chef/win32/registry.rb
@@ -42,7 +42,7 @@ class Chef
attr_accessor :run_context
attr_accessor :architecture
- def initialize(run_context=nil, user_architecture=:machine)
+ def initialize(run_context = nil, user_architecture = :machine)
@run_context = run_context
self.architecture = user_architecture
end
@@ -56,7 +56,7 @@ class Chef
hive, key = get_hive_and_key(key_path)
key_exists!(key_path)
values = hive.open(key, ::Win32::Registry::KEY_READ | registry_system_architecture) do |reg|
- reg.map { |name, type, data| {:name=>name, :type=>get_name_from_type(type), :data=>data} }
+ reg.map { |name, type, data| { :name => name, :type => get_name_from_type(type), :data => data } }
end
end
@@ -175,7 +175,7 @@ class Chef
key_exists!(key_path)
hive, key = get_hive_and_key(key_path)
hive.open(key, ::Win32::Registry::KEY_READ | registry_system_architecture) do |reg|
- reg.each_key{ |key| return true }
+ reg.each_key { |key| return true }
end
return false
end
@@ -185,7 +185,7 @@ class Chef
key_exists!(key_path)
hive, key = get_hive_and_key(key_path)
hive.open(key, ::Win32::Registry::KEY_READ | registry_system_architecture) do |reg|
- reg.each_key{ |current_key| subkeys << current_key }
+ reg.each_key { |current_key| subkeys << current_key }
end
return subkeys
end
@@ -200,7 +200,7 @@ class Chef
key_exists!(key_path)
hive, key = get_hive_and_key(key_path)
hive.open(key, ::Win32::Registry::KEY_READ | registry_system_architecture) do |reg|
- return true if reg.any? {|val| safely_downcase(val) == safely_downcase(value[:name]) }
+ return true if reg.any? { |val| safely_downcase(val) == safely_downcase(value[:name]) }
end
return false
end
@@ -211,8 +211,8 @@ class Chef
hive.open(key, ::Win32::Registry::KEY_READ | registry_system_architecture) do |reg|
reg.each do |val_name, val_type, val_data|
if safely_downcase(val_name) == safely_downcase(value[:name]) &&
- val_type == get_type_from_name(value[:type]) &&
- val_data == value[:data]
+ val_type == get_type_from_name(value[:type]) &&
+ val_data == value[:data]
return true
end
end
@@ -273,7 +273,6 @@ class Chef
private
-
def safely_downcase(val)
if val.is_a? String
return val.downcase
diff --git a/lib/chef/win32/security.rb b/lib/chef/win32/security.rb
index 13b4604469..7fc3215786 100644
--- a/lib/chef/win32/security.rb
+++ b/lib/chef/win32/security.rb
@@ -235,7 +235,6 @@ class Chef
SecurityDescriptor.new(security_descriptor_ptr)
end
-
def self.get_named_security_info(path, type = :SE_FILE_OBJECT, info = OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION)
security_descriptor = FFI::MemoryPointer.new :pointer
hr = GetNamedSecurityInfoW(path.to_wstring, type, info, nil, nil, nil, nil, security_descriptor)
@@ -385,7 +384,7 @@ class Chef
end
sid = FFI::MemoryPointer.new :char, sid_size.read_long
- referenced_domain_name = FFI::MemoryPointer.new :char, (referenced_domain_name_size.read_long*2)
+ referenced_domain_name = FFI::MemoryPointer.new :char, (referenced_domain_name_size.read_long * 2)
use = FFI::Buffer.new(:long).write_long(0)
unless LookupAccountNameW(system_name, name.to_wstring, sid, sid_size, referenced_domain_name, referenced_domain_name_size, use)
Chef::ReservedNames::Win32::Error.raise!
@@ -406,8 +405,8 @@ class Chef
Chef::ReservedNames::Win32::Error.raise!
end
- name = FFI::MemoryPointer.new :char, (name_size.read_long*2)
- referenced_domain_name = FFI::MemoryPointer.new :char, (referenced_domain_name_size.read_long*2)
+ name = FFI::MemoryPointer.new :char, (name_size.read_long * 2)
+ referenced_domain_name = FFI::MemoryPointer.new :char, (referenced_domain_name_size.read_long * 2)
use = FFI::Buffer.new(:long).write_long(0)
unless LookupAccountSidW(system_name, sid, name, name_size, referenced_domain_name, referenced_domain_name_size, use)
Chef::ReservedNames::Win32::Error.raise!
@@ -425,7 +424,7 @@ class Chef
Chef::ReservedNames::Win32::Error.raise!
end
- name = FFI::MemoryPointer.new :char, (name_size.read_long*2)
+ name = FFI::MemoryPointer.new :char, (name_size.read_long * 2)
unless LookupPrivilegeNameW(system_name, luid, name, name_size)
Chef::ReservedNames::Win32::Error.raise!
end
@@ -443,7 +442,7 @@ class Chef
Chef::ReservedNames::Win32::Error.raise!
end
- display_name = FFI::MemoryPointer.new :char, (display_name_size.read_long*2)
+ display_name = FFI::MemoryPointer.new :char, (display_name_size.read_long * 2)
unless LookupPrivilegeDisplayNameW(system_name, name.to_wstring, display_name, display_name_size, language_id)
Chef::ReservedNames::Win32::Error.raise!
end
diff --git a/lib/chef/win32/security/acl.rb b/lib/chef/win32/security/acl.rb
index 86c6e05bd2..8a04987e44 100644
--- a/lib/chef/win32/security/acl.rb
+++ b/lib/chef/win32/security/acl.rb
@@ -34,7 +34,7 @@ class Chef
end
def self.create(aces)
- aces_size = aces.inject(0) { |sum,ace| sum + ace.size }
+ aces_size = aces.inject(0) { |sum, ace| sum + ace.size }
acl_size = align_dword(Chef::ReservedNames::Win32::API::Security::ACLStruct.size + aces_size) # What the heck is 94???
acl = Chef::ReservedNames::Win32::Security.initialize_acl(acl_size)
aces.each { |ace| Chef::ReservedNames::Win32::Security.add_ace(acl, ace) }
@@ -45,7 +45,7 @@ class Chef
def ==(other)
return false if length != other.length
- 0.upto(length-1) do |i|
+ 0.upto(length - 1) do |i|
return false if self[i] != other[i]
end
return true
@@ -64,7 +64,7 @@ class Chef
end
def each
- 0.upto(length-1) { |i| yield self[i] }
+ 0.upto(length - 1) { |i| yield self[i] }
end
def insert(index, *aces)
diff --git a/lib/chef/win32/security/sid.rb b/lib/chef/win32/security/sid.rb
index 0219aa6eb1..4d2d252dd3 100644
--- a/lib/chef/win32/security/sid.rb
+++ b/lib/chef/win32/security/sid.rb
@@ -80,111 +80,147 @@ class Chef
def self.Null
SID.from_string_sid("S-1-0")
end
+
def self.Nobody
SID.from_string_sid("S-1-0-0")
end
+
def self.World
SID.from_string_sid("S-1-1")
end
+
def self.Everyone
SID.from_string_sid("S-1-1-0")
end
+
def self.Local
SID.from_string_sid("S-1-2")
end
+
def self.Creator
SID.from_string_sid("S-1-3")
end
+
def self.CreatorOwner
SID.from_string_sid("S-1-3-0")
end
+
def self.CreatorGroup
SID.from_string_sid("S-1-3-1")
end
+
def self.CreatorOwnerServer
SID.from_string_sid("S-1-3-2")
end
+
def self.CreatorGroupServer
SID.from_string_sid("S-1-3-3")
end
+
def self.NonUnique
SID.from_string_sid("S-1-4")
end
+
def self.Nt
SID.from_string_sid("S-1-5")
end
+
def self.Dialup
SID.from_string_sid("S-1-5-1")
end
+
def self.Network
SID.from_string_sid("S-1-5-2")
end
+
def self.Batch
SID.from_string_sid("S-1-5-3")
end
+
def self.Interactive
SID.from_string_sid("S-1-5-4")
end
+
def self.Service
SID.from_string_sid("S-1-5-6")
end
+
def self.Anonymous
SID.from_string_sid("S-1-5-7")
end
+
def self.Proxy
SID.from_string_sid("S-1-5-8")
end
+
def self.EnterpriseDomainControllers
SID.from_string_sid("S-1-5-9")
end
+
def self.PrincipalSelf
SID.from_string_sid("S-1-5-10")
end
+
def self.AuthenticatedUsers
SID.from_string_sid("S-1-5-11")
end
+
def self.RestrictedCode
SID.from_string_sid("S-1-5-12")
end
+
def self.TerminalServerUsers
SID.from_string_sid("S-1-5-13")
end
+
def self.LocalSystem
SID.from_string_sid("S-1-5-18")
end
+
def self.NtLocal
SID.from_string_sid("S-1-5-19")
end
+
def self.NtNetwork
SID.from_string_sid("S-1-5-20")
end
+
def self.BuiltinAdministrators
SID.from_string_sid("S-1-5-32-544")
end
+
def self.BuiltinUsers
SID.from_string_sid("S-1-5-32-545")
end
+
def self.Guests
SID.from_string_sid("S-1-5-32-546")
end
+
def self.PowerUsers
SID.from_string_sid("S-1-5-32-547")
end
+
def self.AccountOperators
SID.from_string_sid("S-1-5-32-548")
end
+
def self.ServerOperators
SID.from_string_sid("S-1-5-32-549")
end
+
def self.PrintOperators
SID.from_string_sid("S-1-5-32-550")
end
+
def self.BackupOperators
SID.from_string_sid("S-1-5-32-551")
end
+
def self.Replicators
SID.from_string_sid("S-1-5-32-552")
end
+
def self.Administrators
SID.from_string_sid("S-1-5-32-544")
end
@@ -192,9 +228,11 @@ class Chef
def self.None
SID.from_account("#{::ENV['COMPUTERNAME']}\\None")
end
+
def self.Administrator
SID.from_account("#{::ENV['COMPUTERNAME']}\\#{SID.admin_account_name}")
end
+
def self.Guest
SID.from_account("#{::ENV['COMPUTERNAME']}\\Guest")
end
diff --git a/lib/chef/win32/unicode.rb b/lib/chef/win32/unicode.rb
index a7509115c0..b0fcf6492d 100644
--- a/lib/chef/win32/unicode.rb
+++ b/lib/chef/win32/unicode.rb
@@ -40,13 +40,13 @@ module FFI
last_char = nil
while last_char != "\000\000" do
length += 1
- last_char = self.get_bytes(0,length * 2)[-2..-1]
+ last_char = self.get_bytes(0, length * 2)[-2..-1]
end
num_wchars = length
end
- wide_to_utf8(self.get_bytes(0, num_wchars*2))
+ wide_to_utf8(self.get_bytes(0, num_wchars * 2))
end
end
end
diff --git a/lib/chef/win32/version.rb b/lib/chef/win32/version.rb
index abd9916b3a..a18211b8c6 100644
--- a/lib/chef/win32/version.rb
+++ b/lib/chef/win32/version.rb
@@ -48,21 +48,21 @@ class Chef
private_class_method :method_name_from_marketing_name
WIN_VERSIONS = {
- "Windows 10" => {:major => 10, :minor => 0, :callable => lambda{ |product_type, suite_mask| product_type == VER_NT_WORKSTATION }},
- "Windows Server 2016" => {:major => 10, :minor => 0, :callable => lambda {|product_type, suite_mask| product_type != VER_NT_WORKSTATION }},
- "Windows 8.1" => {:major => 6, :minor => 3, :callable => lambda{ |product_type, suite_mask| product_type == VER_NT_WORKSTATION }},
- "Windows Server 2012 R2" => {:major => 6, :minor => 3, :callable => lambda {|product_type, suite_mask| product_type != VER_NT_WORKSTATION }},
- "Windows 8" => {:major => 6, :minor => 2, :callable => lambda{ |product_type, suite_mask| product_type == VER_NT_WORKSTATION }},
- "Windows Server 2012" => {:major => 6, :minor => 2, :callable => lambda{ |product_type, suite_mask| product_type != VER_NT_WORKSTATION }},
- "Windows 7" => {:major => 6, :minor => 1, :callable => lambda{ |product_type, suite_mask| product_type == VER_NT_WORKSTATION }},
- "Windows Server 2008 R2" => {:major => 6, :minor => 1, :callable => lambda{ |product_type, suite_mask| product_type != VER_NT_WORKSTATION }},
- "Windows Server 2008" => {:major => 6, :minor => 0, :callable => lambda{ |product_type, suite_mask| product_type != VER_NT_WORKSTATION }},
- "Windows Vista" => {:major => 6, :minor => 0, :callable => lambda{ |product_type, suite_mask| product_type == VER_NT_WORKSTATION }},
- "Windows Server 2003 R2" => {:major => 5, :minor => 2, :callable => lambda{ |product_type, suite_mask| get_system_metrics(SM_SERVERR2) != 0 }},
- "Windows Home Server" => {:major => 5, :minor => 2, :callable => lambda{ |product_type, suite_mask| (suite_mask & VER_SUITE_WH_SERVER) == VER_SUITE_WH_SERVER }},
- "Windows Server 2003" => {:major => 5, :minor => 2, :callable => lambda{ |product_type, suite_mask| get_system_metrics(SM_SERVERR2) == 0 }},
- "Windows XP" => {:major => 5, :minor => 1},
- "Windows 2000" => {:major => 5, :minor => 0},
+ "Windows 10" => { :major => 10, :minor => 0, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
+ "Windows Server 2016" => { :major => 10, :minor => 0, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
+ "Windows 8.1" => { :major => 6, :minor => 3, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
+ "Windows Server 2012 R2" => { :major => 6, :minor => 3, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
+ "Windows 8" => { :major => 6, :minor => 2, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
+ "Windows Server 2012" => { :major => 6, :minor => 2, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
+ "Windows 7" => { :major => 6, :minor => 1, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
+ "Windows Server 2008 R2" => { :major => 6, :minor => 1, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
+ "Windows Server 2008" => { :major => 6, :minor => 0, :callable => lambda { |product_type, suite_mask| product_type != VER_NT_WORKSTATION } },
+ "Windows Vista" => { :major => 6, :minor => 0, :callable => lambda { |product_type, suite_mask| product_type == VER_NT_WORKSTATION } },
+ "Windows Server 2003 R2" => { :major => 5, :minor => 2, :callable => lambda { |product_type, suite_mask| get_system_metrics(SM_SERVERR2) != 0 } },
+ "Windows Home Server" => { :major => 5, :minor => 2, :callable => lambda { |product_type, suite_mask| (suite_mask & VER_SUITE_WH_SERVER) == VER_SUITE_WH_SERVER } },
+ "Windows Server 2003" => { :major => 5, :minor => 2, :callable => lambda { |product_type, suite_mask| get_system_metrics(SM_SERVERR2) == 0 } },
+ "Windows XP" => { :major => 5, :minor => 1 },
+ "Windows 2000" => { :major => 5, :minor => 0 },
}
def initialize
@@ -88,12 +88,12 @@ class Chef
marketing_names = Array.new
# General Windows checks
- WIN_VERSIONS.each do |k,v|
+ WIN_VERSIONS.each do |k, v|
method_name = method_name_from_marketing_name(k)
define_method(method_name) do
(@major_version == v[:major]) &&
- (@minor_version == v[:minor]) &&
- (v[:callable] ? v[:callable].call(@product_type, @suite_mask) : true)
+ (@minor_version == v[:minor]) &&
+ (v[:callable] ? v[:callable].call(@product_type, @suite_mask) : true)
end
marketing_names << [k, method_name]
end
@@ -129,7 +129,7 @@ class Chef
# The operating system version is a string in the following form
# that can be split into components based on the '.' delimiter:
# MajorVersionNumber.MinorVersionNumber.BuildNumber
- os_version.split(".").collect { | version_string | version_string.to_i }
+ os_version.split(".").collect { |version_string| version_string.to_i }
end
def get_version_ex