summaryrefslogtreecommitdiff
path: root/source3/utils/ntlm_auth.c
diff options
context:
space:
mode:
authorKai Blin <kai@samba.org>2008-01-16 14:45:22 +0100
committerKai Blin <kai@samba.org>2008-01-19 13:16:24 +0100
commit83f30d72e02829fc0304fbeb9751e71e6aaf6c84 (patch)
tree72f5aca5a4804fa7d5161e3e1b3f8368789898f4 /source3/utils/ntlm_auth.c
parentf22a29e1bd0c59710b1f6ab56e903fa6e1e51a46 (diff)
downloadsamba-83f30d72e02829fc0304fbeb9751e71e6aaf6c84.tar.gz
samba-83f30d72e02829fc0304fbeb9751e71e6aaf6c84.tar.bz2
samba-83f30d72e02829fc0304fbeb9751e71e6aaf6c84.zip
ntlm_auth: Prepare for a deeper rewrite of the helper functions
(This used to be commit f8243d1913cd19401ce6a13f53c6b84a36fc9dd6)
Diffstat (limited to 'source3/utils/ntlm_auth.c')
-rw-r--r--source3/utils/ntlm_auth.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c
index b0c79571d2..24a49afadd 100644
--- a/source3/utils/ntlm_auth.c
+++ b/source3/utils/ntlm_auth.c
@@ -43,6 +43,23 @@ enum stdio_helper_mode {
NUM_HELPER_MODES
};
+enum ntlm_auth_con_state {
+ CLIENT_INITIAL,
+ CLIENT_RESPONSE,
+ CLIENT_FINISHED,
+ CLIENT_ERROR,
+ SERVER_INITIAL,
+ SERVER_CHALLENGE,
+ SERVER_FINISHED,
+ SERVER_ERROR
+};
+
+struct ntlm_auth_state {
+ TALLOC_CTX *mem_ctx;
+ enum stdio_helper_mode helper_mode;
+ enum ntlm_auth_con_state con_state;
+};
+
typedef void (*stdio_helper_function)(enum stdio_helper_mode stdio_helper_mode,
char *buf, int length);
@@ -2069,14 +2086,15 @@ static void manage_ntlm_change_password_1_request(enum stdio_helper_mode helper_
}
}
-static void manage_squid_request(enum stdio_helper_mode helper_mode, stdio_helper_function fn)
+static void manage_squid_request(struct ntlm_auth_state *state,
+ stdio_helper_function fn)
{
char *buf;
char tmp[INITIAL_BUFFER_SIZE+1];
int length, buf_size = 0;
char *c;
- buf = talloc_strdup(NULL, "");
+ buf = talloc_strdup(state->mem_ctx, "");
if (!buf) {
DEBUG(0, ("Failed to allocate input buffer.\n"));
x_fprintf(x_stderr, "ERR\n");
@@ -2123,17 +2141,38 @@ static void manage_squid_request(enum stdio_helper_mode helper_mode, stdio_helpe
return;
}
- fn(helper_mode, buf, length);
+ fn(state->helper_mode, buf, length);
talloc_free(buf);
}
static void squid_stream(enum stdio_helper_mode stdio_mode, stdio_helper_function fn) {
+ TALLOC_CTX *mem_ctx;
+ struct ntlm_auth_state *state;
+
/* initialize FDescs */
x_setbuf(x_stdout, NULL);
x_setbuf(x_stderr, NULL);
+
+ mem_ctx = talloc_init("ntlm_auth");
+ if (!mem_ctx) {
+ DEBUG(0, ("squid_stream: Failed to create talloc context\n"));
+ x_fprintf(x_stderr, "ERR\n");
+ exit(1);
+ }
+
+ state = talloc(mem_ctx, struct ntlm_auth_state);
+ if (!state) {
+ DEBUG(0, ("squid_stream: Failed to talloc ntlm_auth_state\n"));
+ x_fprintf(x_stderr, "ERR\n");
+ exit(1);
+ }
+
+ state->mem_ctx = mem_ctx;
+ state->helper_mode = stdio_mode;
+
while(1) {
- manage_squid_request(stdio_mode, fn);
+ manage_squid_request(state, fn);
}
}