зеркало из https://github.com/github/ruby.git
Use fiddle (win32/importer) instead of Win32API
- ext/win32/lib/win32/sspi.rb: Use fiddle (win32/importer) instead of Win32API
This commit is contained in:
Родитель
17e7a819f7
Коммит
9728cb730f
|
@ -11,7 +11,7 @@
|
|||
# Ruby Distribution License or GNU General Public License.
|
||||
#
|
||||
|
||||
require 'Win32API'
|
||||
require 'win32/importer'
|
||||
|
||||
# Implements bindings to Win32 SSPI functions, focused on authentication to a proxy server over HTTP.
|
||||
module Win32
|
||||
|
@ -36,14 +36,21 @@ module Win32
|
|||
|
||||
# Win32 API Functions. Uses Win32API to bind methods to constants contained in class.
|
||||
module API
|
||||
# Can be called with AcquireCredentialsHandle.call()
|
||||
AcquireCredentialsHandle = Win32API.new("secur32", "AcquireCredentialsHandle", 'ppLpppppp', 'L')
|
||||
# Can be called with InitializeSecurityContext.call()
|
||||
InitializeSecurityContext = Win32API.new("secur32", "InitializeSecurityContext", 'pppLLLpLpppp', 'L')
|
||||
extend Importer
|
||||
dlload "secur32.dll"
|
||||
[
|
||||
# Can be called with AcquireCredentialsHandleA.call()
|
||||
"unsigned long AcquireCredentialsHandleA(void *, void *, unsigned long, void *, void *, void *, void *, void *, void *)",
|
||||
# Can be called with InitializeSecurityContextA.call()
|
||||
"unsigned long InitializeSecurityContextA(void *, void *, void *, unsigned long, unsigned long, unsigned long, void *, unsigned long, void *, void *, void *, void *)",
|
||||
# Can be called with DeleteSecurityContext.call()
|
||||
DeleteSecurityContext = Win32API.new("secur32", "DeleteSecurityContext", 'P', 'L')
|
||||
"unsigned long DeleteSecurityContext(void *)",
|
||||
# Can be called with FreeCredentialsHandle.call()
|
||||
FreeCredentialsHandle = Win32API.new("secur32", "FreeCredentialsHandle", 'P', 'L')
|
||||
"unsigned long FreeCredentialsHandle(void *)"
|
||||
].each do |fn|
|
||||
cfunc = extern fn, :stdcall
|
||||
const_set cfunc.name.intern, cfunc
|
||||
end
|
||||
end
|
||||
|
||||
# SecHandle struct
|
||||
|
@ -254,7 +261,7 @@ module Win32
|
|||
@context = CtxtHandle.new
|
||||
@contextAttributes = "\0" * 4
|
||||
|
||||
result = SSPIResult.new(API::InitializeSecurityContext.call(@credentials.to_p, nil, nil,
|
||||
result = SSPIResult.new(API::InitializeSecurityContextA.call(@credentials.to_p, nil, nil,
|
||||
REQUEST_FLAGS,0, SECURITY_NETWORK_DREP, nil, 0, @context.to_p, outputBuffer.to_p, @contextAttributes, TimeStamp.new.to_p))
|
||||
|
||||
if result.ok? then
|
||||
|
@ -317,7 +324,7 @@ module Win32
|
|||
@credentials = CredHandle.new
|
||||
ts = TimeStamp.new
|
||||
@identity = Identity.new @user, @domain
|
||||
result = SSPIResult.new(API::AcquireCredentialsHandle.call(nil, "Negotiate", SECPKG_CRED_OUTBOUND, nil, @identity.to_p,
|
||||
result = SSPIResult.new(API::AcquireCredentialsHandleA.call(nil, "Negotiate", SECPKG_CRED_OUTBOUND, nil, @identity.to_p,
|
||||
nil, nil, @credentials.to_p, ts.to_p))
|
||||
raise "Error acquire credentials: #{result}" unless result.ok?
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче