summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/platform.rb9
-rw-r--r--lib/chef/win32/security.rb22
2 files changed, 23 insertions, 8 deletions
diff --git a/lib/chef/platform.rb b/lib/chef/platform.rb
index 807eeafa6d..6e6de6004e 100644
--- a/lib/chef/platform.rb
+++ b/lib/chef/platform.rb
@@ -476,6 +476,15 @@ class Chef
end
end
+ def windows_server_2003?
+ return false unless windows?
+
+ require 'ruby-wmi'
+
+ host = WMI::Win32_OperatingSystem.find(:first)
+ (host.version && host.version.start_with?("5.2"))
+ end
+
private
def explicit_provider(platform, version, resource_type)
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