--------------------- PatchSet 511 Date: 2000/08/08 13:20:40 Author: kinkie Branch: ntlm Tag: (none) Log: Removed state management code. Cleaned up. Members: ntlm_auth_modules/NTLMSSP/ntlm_auth.c:1.1.2.2->1.1.2.3 Index: squid/ntlm_auth_modules/NTLMSSP/ntlm_auth.c =================================================================== RCS file: /cvsroot/squid-sf//squid/ntlm_auth_modules/NTLMSSP/Attic/ntlm_auth.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid/ntlm_auth_modules/NTLMSSP/ntlm_auth.c 6 Aug 2000 01:17:36 -0000 1.1.2.2 +++ squid/ntlm_auth_modules/NTLMSSP/ntlm_auth.c 8 Aug 2000 13:20:40 -0000 1.1.2.3 @@ -35,13 +35,11 @@ char buf[10240]; ntlmssp *got; char *ch; - int state=0; /* 0 start 1 negotiate 2 authenticate */ setbuf(stdout,NULL); setbuf(stderr,NULL); while (1) { - if(state==2)state=0; if(fgets(buf, 10240, stdin) == NULL) exit(0); ch=strchr(buf,'\n'); if (ch) @@ -50,55 +48,36 @@ if (strncmp(buf,"RESET",5)==0) { debug("ntlm authenticator resetting, sending OK\n"); printf("RESET OK\n"); /* This should read "RESET OK" */ - state=0; continue; } got=decode_ntlmssp_auth(buf); if (!got) { debug("couldn't decode request type. Just returning ERR\n"); printf("ERR\n"); - }else - { + continue; + } + /* we got something intelligible */ debug("reqest type is %d\n",got->type); switch(got->type) { case NTLM_NEGOTIATE: - if(state!=0) - { - fprintf(stderr,"Unexpected Negotiate request, state=%d\n",state); - printf("ERR Unexpected negotiate request\n"); - state=0; - continue; - } - state=1; - if (got->flags & FLAGS_UNICODE)debug("Unicode\n"); ch=make_challenge(got); - debug("got challenge ('%s')\n",ch); - if (ch==NULL) - { + if (ch==NULL) { fprintf(stderr,"Couldn't get a valid challenge!\n"); printf("ERR\n"); - state=0; continue; } + debug("sending challenge: %s\n",ch); +#ifdef debug drop_ntlmssp(decode_ntlmssp_auth(ch)); - debug("sending: 'CH %s'\n",ch); +#endif printf ("CH %s\n",ch); break; case NTLM_CHALLENGE: - /* huh? we shouldn't be getting those */ fprintf(stderr,"Huh? We should be issuing challenges, " "not getting them. Returning ERR\n"); printf("ERR\n"); break; case NTLM_AUTHENTICATE: - if (state!=1) - { - fprintf(stderr,"Unexpected Authenticate request, state=%d\n",state); - printf("ERR Unexpected authenticate request\n"); - state=0; - continue; - } - state=2; debug("Got an authentication request\n"); if (ntlm_check_auth(got)) { debug("Returning 'OK %s\\%s'\n",got->domain.str, got->user.str); @@ -109,7 +88,6 @@ } break; } - } drop_ntlmssp(got); } return 0;