diff options
author | sersut <serdar@opscode.com> | 2013-01-18 11:52:45 -0800 |
---|---|---|
committer | sersut <serdar@opscode.com> | 2013-01-22 10:53:11 -0800 |
commit | 7c647b1c3ab1f820fdfad6c054370b2dc84816a1 (patch) | |
tree | 035a75b8ca492e205bf581486a7b762e9ecafb0e /lib/chef/win32/security.rb | |
parent | ef5c0a96d2ac015d98f270570a04630239bf3d43 (diff) | |
download | chef-7c647b1c3ab1f820fdfad6c054370b2dc84816a1.tar.gz |
Do the windows admin privilege check only on the windows versions that it is possible.
Diffstat (limited to 'lib/chef/win32/security.rb')
-rw-r--r-- | lib/chef/win32/security.rb | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/chef/win32/security.rb b/lib/chef/win32/security.rb index f42078bc51..c0e6479106 100644 --- a/lib/chef/win32/security.rb +++ b/lib/chef/win32/security.rb @@ -482,14 +482,20 @@ class Chef # Checks if the caller has the admin privilages in their # security token def self.has_admin_privilages? - process_token = open_process_token(Chef::ReservedNames::Win32::Process.get_current_process, TOKEN_READ) - elevation_result = FFI::Buffer.new(:ulong) - elevation_result_size = FFI::MemoryPointer.new(:uint32) - success = GetTokenInformation(process_token.handle.handle, :TokenElevation, elevation_result, 4, elevation_result_size) - - # Assume process is not elevated if the call fails. - # Process is elevated if the result is different than 0. - success && (elevation_result.read_ulong != 0) + if Chef::Platform.windows_server_2003? + # Admin privilages do not exist on Windows Server 2003 + + true + else + process_token = open_process_token(Chef::ReservedNames::Win32::Process.get_current_process, TOKEN_READ) + elevation_result = FFI::Buffer.new(:ulong) + elevation_result_size = FFI::MemoryPointer.new(:uint32) + success = GetTokenInformation(process_token.handle.handle, :TokenElevation, elevation_result, 4, elevation_result_size) + + # Assume process is not elevated if the call fails. + # Process is elevated if the result is different than 0. + success && (elevation_result.read_ulong != 0) + end end end end |