aboutsummaryrefslogtreecommitdiff
path: root/vendor/gopkg.in/mgo.v2/internal/sasl
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gopkg.in/mgo.v2/internal/sasl')
-rw-r--r--vendor/gopkg.in/mgo.v2/internal/sasl/sasl_windows.c20
-rw-r--r--vendor/gopkg.in/mgo.v2/internal/sasl/sasl_windows.go12
-rw-r--r--vendor/gopkg.in/mgo.v2/internal/sasl/sasl_windows.h2
3 files changed, 20 insertions, 14 deletions
diff --git a/vendor/gopkg.in/mgo.v2/internal/sasl/sasl_windows.c b/vendor/gopkg.in/mgo.v2/internal/sasl/sasl_windows.c
index dd6a88a..c359fd6 100644
--- a/vendor/gopkg.in/mgo.v2/internal/sasl/sasl_windows.c
+++ b/vendor/gopkg.in/mgo.v2/internal/sasl/sasl_windows.c
@@ -10,14 +10,18 @@ SECURITY_STATUS SEC_ENTRY sspi_acquire_credentials_handle(CredHandle *cred_handl
auth_identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
auth_identity.User = (LPSTR) username;
auth_identity.UserLength = strlen(username);
- auth_identity.Password = (LPSTR) password;
- auth_identity.PasswordLength = strlen(password);
+ auth_identity.Password = NULL;
+ auth_identity.PasswordLength = 0;
+ if(password){
+ auth_identity.Password = (LPSTR) password;
+ auth_identity.PasswordLength = strlen(password);
+ }
auth_identity.Domain = (LPSTR) domain;
auth_identity.DomainLength = strlen(domain);
return call_sspi_acquire_credentials_handle(NULL, SSPI_PACKAGE_NAME, SECPKG_CRED_OUTBOUND, NULL, &auth_identity, NULL, NULL, cred_handle, &ignored);
}
-int sspi_step(CredHandle *cred_handle, int has_context, CtxtHandle *context, PVOID *buffer, ULONG *buffer_length, char *target)
+int sspi_step(CredHandle *cred_handle, int has_context, CtxtHandle *context, PVOID buffer, ULONG buffer_length, PVOID *out_buffer, ULONG *out_buffer_length, char *target)
{
SecBufferDesc inbuf;
SecBuffer in_bufs[1];
@@ -30,8 +34,8 @@ int sspi_step(CredHandle *cred_handle, int has_context, CtxtHandle *context, PVO
inbuf.ulVersion = SECBUFFER_VERSION;
inbuf.cBuffers = 1;
inbuf.pBuffers = in_bufs;
- in_bufs[0].pvBuffer = *buffer;
- in_bufs[0].cbBuffer = *buffer_length;
+ in_bufs[0].pvBuffer = buffer;
+ in_bufs[0].cbBuffer = buffer_length;
in_bufs[0].BufferType = SECBUFFER_TOKEN;
}
@@ -57,9 +61,9 @@ int sspi_step(CredHandle *cred_handle, int has_context, CtxtHandle *context, PVO
&context_attr,
NULL);
- *buffer = malloc(out_bufs[0].cbBuffer);
- *buffer_length = out_bufs[0].cbBuffer;
- memcpy(*buffer, out_bufs[0].pvBuffer, *buffer_length);
+ *out_buffer = malloc(out_bufs[0].cbBuffer);
+ *out_buffer_length = out_bufs[0].cbBuffer;
+ memcpy(*out_buffer, out_bufs[0].pvBuffer, *out_buffer_length);
return ret;
}
diff --git a/vendor/gopkg.in/mgo.v2/internal/sasl/sasl_windows.go b/vendor/gopkg.in/mgo.v2/internal/sasl/sasl_windows.go
index 3302cfe..d8ec001 100644
--- a/vendor/gopkg.in/mgo.v2/internal/sasl/sasl_windows.go
+++ b/vendor/gopkg.in/mgo.v2/internal/sasl/sasl_windows.go
@@ -101,6 +101,8 @@ func (ss *saslSession) Step(serverData []byte) (clientData []byte, done bool, er
}
var buffer C.PVOID
var bufferLength C.ULONG
+ var outBuffer C.PVOID
+ var outBufferLength C.ULONG
if len(serverData) > 0 {
buffer = (C.PVOID)(unsafe.Pointer(&serverData[0]))
bufferLength = C.ULONG(len(serverData))
@@ -108,20 +110,20 @@ func (ss *saslSession) Step(serverData []byte) (clientData []byte, done bool, er
var status C.int
if ss.authComplete {
// Step 3: last bit of magic to use the correct server credentials
- status = C.sspi_send_client_authz_id(&ss.context, &buffer, &bufferLength, ss.cstr(ss.userPlusRealm))
+ status = C.sspi_send_client_authz_id(&ss.context, &outBuffer, &outBufferLength, ss.cstr(ss.userPlusRealm))
} else {
// Step 1 + Step 2: set up security context with the server and TGT
- status = C.sspi_step(&ss.credHandle, ss.hasContext, &ss.context, &buffer, &bufferLength, ss.cstr(ss.target))
+ status = C.sspi_step(&ss.credHandle, ss.hasContext, &ss.context, buffer, bufferLength, &outBuffer, &outBufferLength, ss.cstr(ss.target))
}
- if buffer != C.PVOID(nil) {
- defer C.free(unsafe.Pointer(buffer))
+ if outBuffer != C.PVOID(nil) {
+ defer C.free(unsafe.Pointer(outBuffer))
}
if status != C.SEC_E_OK && status != C.SEC_I_CONTINUE_NEEDED {
ss.errored = true
return nil, false, ss.handleSSPIErrorCode(status)
}
- clientData = C.GoBytes(unsafe.Pointer(buffer), C.int(bufferLength))
+ clientData = C.GoBytes(unsafe.Pointer(outBuffer), C.int(outBufferLength))
if status == C.SEC_E_OK {
ss.authComplete = true
return clientData, true, nil
diff --git a/vendor/gopkg.in/mgo.v2/internal/sasl/sasl_windows.h b/vendor/gopkg.in/mgo.v2/internal/sasl/sasl_windows.h
index 94321b2..a6b0395 100644
--- a/vendor/gopkg.in/mgo.v2/internal/sasl/sasl_windows.h
+++ b/vendor/gopkg.in/mgo.v2/internal/sasl/sasl_windows.h
@@ -3,5 +3,5 @@
#include "sspi_windows.h"
SECURITY_STATUS SEC_ENTRY sspi_acquire_credentials_handle(CredHandle* cred_handle, char* username, char* password, char* domain);
-int sspi_step(CredHandle* cred_handle, int has_context, CtxtHandle* context, PVOID* buffer, ULONG* buffer_length, char* target);
+int sspi_step(CredHandle* cred_handle, int has_context, CtxtHandle* context, PVOID buffer, ULONG buffer_length, PVOID* out_buffer, ULONG* out_buffer_length, char* target);
int sspi_send_client_authz_id(CtxtHandle* context, PVOID* buffer, ULONG* buffer_length, char* user_plus_realm);