summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornimisha <nimisha.sharad@msystechnologies.com>2018-01-24 13:23:02 +0530
committernimisha <nimisha.sharad@msystechnologies.com>2018-01-24 15:00:41 +0530
commitb07a4f4b8da44bf35d9dbe879e1cf4fd2f040644 (patch)
tree74b0f71c5cd33b28d461c87cf7fd2f5ca1870022
parent7381679100ca96c63751cadff8b54722aefed5f4 (diff)
downloadchef-b07a4f4b8da44bf35d9dbe879e1cf4fd2f040644.tar.gz
Fixed review comments
Signed-off-by: nimisha <nimisha.sharad@msystechnologies.com>
-rw-r--r--lib/chef/util/windows/logon_session.rb7
-rw-r--r--lib/chef/win32/security.rb3
2 files changed, 4 insertions, 6 deletions
diff --git a/lib/chef/util/windows/logon_session.rb b/lib/chef/util/windows/logon_session.rb
index 912a603865..afe58ae4f9 100644
--- a/lib/chef/util/windows/logon_session.rb
+++ b/lib/chef/util/windows/logon_session.rb
@@ -48,11 +48,8 @@ class Chef
password = wstring(original_password)
domain = wstring(original_domain)
- if authentication == :remote
- status = Chef::ReservedNames::Win32::API::Security.LogonUserW(username, domain, password, Chef::ReservedNames::Win32::API::Security::LOGON32_LOGON_NEW_CREDENTIALS, Chef::ReservedNames::Win32::API::Security::LOGON32_PROVIDER_DEFAULT, token)
- elsif authentication == :local
- status = Chef::ReservedNames::Win32::API::Security.LogonUserW(username, domain, password, Chef::ReservedNames::Win32::API::Security::LOGON32_LOGON_NETWORK, Chef::ReservedNames::Win32::API::Security::LOGON32_PROVIDER_DEFAULT, token)
- end
+ logon_type = (authentication == :local) ? (Chef::ReservedNames::Win32::API::Security::LOGON32_LOGON_NETWORK) : (Chef::ReservedNames::Win32::API::Security::LOGON32_LOGON_NEW_CREDENTIALS)
+ status = Chef::ReservedNames::Win32::API::Security.LogonUserW(username, domain, password, logon_type, Chef::ReservedNames::Win32::API::Security::LOGON32_PROVIDER_DEFAULT, token)
if !status
last_error = FFI::LastError.error
diff --git a/lib/chef/win32/security.rb b/lib/chef/win32/security.rb
index c658c8f70f..63b626b1d7 100644
--- a/lib/chef/win32/security.rb
+++ b/lib/chef/win32/security.rb
@@ -350,7 +350,8 @@ class Chef
end
info_ptr = FFI::MemoryPointer.new(:pointer)
token_info_pointer = TOKEN_ELEVATION_TYPE.new info_ptr
- unless GetTokenInformation(token.handle.handle, :TokenElevationType, token_info_pointer, 4, token_result_size)
+ token_info_length = 4
+ unless GetTokenInformation(token.handle.handle, :TokenElevationType, token_info_pointer, token_info_length, token_result_size)
Chef::ReservedNames::Win32::Error.raise!
end
token_info_pointer[:ElevationType]