[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS gsasl/lib/ntlm
From: |
gsasl-commit |
Subject: |
CVS gsasl/lib/ntlm |
Date: |
Sat, 18 Sep 2004 04:33:47 +0200 |
Update of /home/cvs/gsasl/lib/ntlm
In directory dopio:/tmp/cvs-serv28303/lib/ntlm
Modified Files:
ntlm.c x-ntlm.h
Log Message:
Make NTLM use new allocating API.
--- /home/cvs/gsasl/lib/ntlm/ntlm.c 2004/09/17 20:52:44 1.4
+++ /home/cvs/gsasl/lib/ntlm/ntlm.c 2004/09/18 02:33:47 1.5
@@ -32,7 +32,6 @@
struct _Gsasl_ntlm_state
{
int step;
- char *username;
};
typedef struct _Gsasl_ntlm_state _Gsasl_ntlm_state;
@@ -40,24 +39,12 @@
_gsasl_ntlm_client_start (Gsasl_session_ctx * sctx, void **mech_data)
{
_Gsasl_ntlm_state *state;
- Gsasl_ctx *ctx;
-
- ctx = gsasl_client_ctx_get (sctx);
- if (ctx == NULL)
- return GSASL_CANNOT_GET_CTX;
-
- if (gsasl_client_callback_authorization_id_get (ctx) == NULL)
- return GSASL_NEED_CLIENT_AUTHORIZATION_ID_CALLBACK;
-
- if (gsasl_client_callback_password_get (ctx) == NULL)
- return GSASL_NEED_CLIENT_PASSWORD_CALLBACK;
state = (_Gsasl_ntlm_state *) malloc (sizeof (*state));
if (state == NULL)
return GSASL_MALLOC_ERROR;
state->step = 0;
- state->username = NULL;
*mech_data = state;
@@ -67,34 +54,19 @@
int
_gsasl_ntlm_client_step (Gsasl_session_ctx * sctx,
void *mech_data,
- const char *input,
- size_t input_len, char *output, size_t * output_len)
+ const char *input, size_t input_len,
+ char **output, size_t * output_len)
{
_Gsasl_ntlm_state *state = mech_data;
tSmbNtlmAuthRequest request;
tSmbNtlmAuthChallenge challenge;
tSmbNtlmAuthResponse response;
- Gsasl_client_callback_authorization_id cb_authorization_id;
- Gsasl_client_callback_password cb_password;
- Gsasl_ctx *ctx;
/* XXX create callback for domain? Doesn't seem to be needed by servers */
char *domain = NULL;
- char *password;
+ const char *password, *authzid;
size_t len;
int res;
- ctx = gsasl_client_ctx_get (sctx);
- if (ctx == NULL)
- return GSASL_CANNOT_GET_CTX;
-
- cb_authorization_id = gsasl_client_callback_authorization_id_get (ctx);
- if (cb_authorization_id == NULL)
- return GSASL_NEED_CLIENT_AUTHORIZATION_ID_CALLBACK;
-
- cb_password = gsasl_client_callback_password_get (ctx);
- if (cb_password == NULL)
- return GSASL_NEED_CLIENT_PASSWORD_CALLBACK;
-
switch (state->step)
{
case 0:
@@ -102,23 +74,17 @@
if (input_len != 1 && *input != '+')
return GSASL_MECHANISM_PARSE_ERROR; */
- len = *output_len;
- res = cb_authorization_id (sctx, NULL, &len);
- if (res != GSASL_OK)
- return res;
- state->username = malloc (len + 1);
- res = cb_authorization_id (sctx, state->username, &len);
- if (res != GSASL_OK)
- return res;
- state->username[len] = '\0';
-
- buildSmbNtlmAuthRequest (&request, state->username, domain);
+ authzid = gsasl_property_get (sctx, GSASL_CLIENT_AUTHZID);
+ if (!authzid)
+ return GSASL_NO_AUTHZID;
- if (*output_len < SmbLength (&request))
- return GSASL_TOO_SMALL_BUFFER;
+ buildSmbNtlmAuthRequest (&request, authzid, domain);
*output_len = SmbLength (&request);
- memcpy (output, &request, *output_len);
+ *output = malloc (*output_len);
+ if (!*output)
+ return GSASL_MALLOC_ERROR;
+ memcpy (*output, &request, *output_len);
/* dumpSmbNtlmAuthRequest(stdout, &request); */
@@ -135,28 +101,21 @@
memcpy (&challenge, input, input_len);
- len = *output_len;
- res = cb_password (sctx, NULL, &len);
- if (res != GSASL_OK)
- return res;
- password = malloc (len + 1);
- res = cb_password (sctx, password, &len);
- if (res != GSASL_OK)
- {
- free (password);
- return res;
- }
- password[len] = '\0';
-
- buildSmbNtlmAuthResponse (&challenge, &response, state->username,
- password);
- free (password);
+ password = gsasl_property_get (sctx, GSASL_CLIENT_PASSWORD);
+ if (!password)
+ return GSASL_NO_PASSWORD;
+
+ authzid = gsasl_property_get (sctx, GSASL_CLIENT_AUTHZID);
+ if (!authzid)
+ return GSASL_NO_AUTHZID;
- if (*output_len < SmbLength (&response))
- return GSASL_TOO_SMALL_BUFFER;
+ buildSmbNtlmAuthResponse (&challenge, &response, authzid, password);
*output_len = SmbLength (&response);
- memcpy (output, &response, *output_len);
+ *output = malloc (*output_len);
+ if (!*output)
+ return GSASL_MALLOC_ERROR;
+ memcpy (*output, &response, *output_len);
/* dumpSmbNtlmAuthResponse(stdout, &response); */
@@ -177,9 +136,6 @@
{
_Gsasl_ntlm_state *state = mech_data;
- if (state->username)
- free (state->username);
-
free (state);
return GSASL_OK;
--- /home/cvs/gsasl/lib/ntlm/x-ntlm.h 2004/09/17 20:52:44 1.3
+++ /home/cvs/gsasl/lib/ntlm/x-ntlm.h 2004/09/18 02:33:47 1.4
@@ -34,9 +34,8 @@
void **mech_data);
extern int _gsasl_ntlm_client_step (Gsasl_session_ctx * sctx,
void *mech_data,
- const char *input,
- size_t input_len,
- char *output, size_t * output_len);
+ const char *input, size_t input_len,
+ char **output, size_t * output_len);
extern int _gsasl_ntlm_client_finish (Gsasl_session_ctx * sctx,
void *mech_data);
- CVS gsasl/lib/ntlm, gsasl-commit, 2004/09/17
- CVS gsasl/lib/ntlm,
gsasl-commit <=
- CVS gsasl/lib/ntlm, gsasl-commit, 2004/09/18
- CVS gsasl/lib/ntlm, gsasl-commit, 2004/09/18
- CVS gsasl/lib/ntlm, gsasl-commit, 2004/09/18
- CVS gsasl/lib/ntlm, gsasl-commit, 2004/09/20
- CVS gsasl/lib/ntlm, gsasl-commit, 2004/09/22
- CVS gsasl/lib/ntlm, gsasl-commit, 2004/09/22
- CVS gsasl/lib/ntlm, gsasl-commit, 2004/09/24
- CVS gsasl/lib/ntlm, gsasl-commit, 2004/09/24
- CVS gsasl/lib/ntlm, gsasl-commit, 2004/09/24
- CVS gsasl/lib/ntlm, gsasl-commit, 2004/09/26