--------------------- PatchSet 536 Date: 2000/08/17 15:14:59 Author: kinkie Branch: ntlm Tag: (none) Log: Removed leftover code Added a few comments Sanitized a few warnings Members: auth_modules/SMB/smb_auth.c:1.1.1.2->1.1.1.2.10.1 ntlm_auth_modules/NTLMSSP/libntlmssp.c:1.1.2.8->1.1.2.9 Index: squid/auth_modules/SMB/smb_auth.c =================================================================== RCS file: /cvsroot/squid-sf//squid/auth_modules/SMB/Attic/smb_auth.c,v retrieving revision 1.1.1.2 retrieving revision 1.1.1.2.10.1 diff -u -r1.1.1.2 -r1.1.1.2.10.1 --- squid/auth_modules/SMB/smb_auth.c 26 Jan 2000 03:25:00 -0000 1.1.1.2 +++ squid/auth_modules/SMB/smb_auth.c 17 Aug 2000 15:14:59 -0000 1.1.1.2.10.1 @@ -73,7 +73,7 @@ } } -void main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int i; char buf[BUFSIZE]; @@ -88,7 +88,7 @@ /* make standard output line buffered */ if (setvbuf(stdout, NULL, _IOLBF, 0) != 0) - return; + return 1; /* parse command line arguments */ for (i = 1; i < argc; i++) @@ -106,7 +106,7 @@ if (strcmp(argv[i], "-W") == 0) { if ((dom = (struct SMBDOMAIN *) malloc(sizeof(struct SMBDOMAIN))) == NULL) - return; + return 1; dom->name = dom->sname = argv[++i]; dom->passthrough = ""; @@ -165,7 +165,7 @@ if (lastdom != NULL) { if ((lastdom->authshare = strdup(argv[++i])) == NULL) - return; + return 1; /* convert backslashes to forward slashes */ for (s = lastdom->authshare; *s != '\0'; s++) @@ -190,7 +190,7 @@ /* pass to helper script */ if (putenv("SAMBAPREFIX=" SAMBAPREFIX) != 0) - return; + return 1; while (1) { @@ -258,4 +258,5 @@ (void) printf("ERR\n"); } /* while (1) */ + return 0; } Index: squid/ntlm_auth_modules/NTLMSSP/libntlmssp.c =================================================================== RCS file: /cvsroot/squid-sf//squid/ntlm_auth_modules/NTLMSSP/Attic/libntlmssp.c,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -u -r1.1.2.8 -r1.1.2.9 --- squid/ntlm_auth_modules/NTLMSSP/libntlmssp.c 11 Aug 2000 13:57:49 -0000 1.1.2.8 +++ squid/ntlm_auth_modules/NTLMSSP/libntlmssp.c 17 Aug 2000 15:17:21 -0000 1.1.2.9 @@ -20,12 +20,10 @@ #if HAVE_STRING_H #include -#endif +#endif /* HAVE_STRING_H */ #if HAVE_STDLIB_H #include -#endif - -static ntlmssp *model; +#endif /* HAVE_STDLIB_H */ #include "smblib-priv.h" /* for SMB_Handle_Type */ @@ -64,95 +62,10 @@ (flags&REQUEST_NON_NT_SESSION_KEY?"Req_nonnt_sesskey ":"") ); } -#else +#else /* DEBUG */ #define debug_dump_ntlmssp_flags(X) /* empty */ #endif /* DEBUG */ -#if OLD -/* This code is not used anymore. It's left in as a reference to other - * Free Software products that might want to use NTLMSSP-based authentication. - */ - -/* instantiates an empty ntlmssp, with fields initalized to 0/NULL - * it will be left to user's care to free it - * Returns NULL in case of failure - */ -ntlmssp * create_ntlmssp () { - ntlmssp *rv; -/* debug("create_ntlmssp: entering\n"); */ - if (!model) { - debug("create_ntlmssp: building model\n"); - model=malloc(sizeof(ntlmssp)); - if (!model) { - fprintf(stderr,"ntlmssp: malloc failed for model\n"); - return NULL; - } - model->type=0; - model->flags=0; - lstring_zero(model->domain); - lstring_zero(model->workstation); - lstring_zero(model->user); - lstring_zero(model->sessionkey); - lstring_zero(model->challenge); - lstring_zero(model->target); - lstring_zero(model->lm); - lstring_zero(model->nt); - - } - rv=malloc(sizeof(ntlmssp)); - if (!rv) { - fprintf(stderr,"ntlmssp: malloc failed for result\n"); - return NULL; - } - memcpy(rv,model,sizeof(ntlmssp)); - return rv; -} - - -#ifdef DEBUG -void debug_dump_ntlmssp(ntlmssp *n) { - fprintf(stderr,"Request type %d\n",n->type); - debug_dump_ntlmssp_flags(n->flags); - if (n->domain.l>=0) - fprintf(stderr,"\tdomain: '%s'\n",n->domain.str); /* what about unicode? */ - if (n->workstation.l>=0) - fprintf(stderr,"\tworkstation:'%s'\n",n->workstation.str); - if (n->user.l>=0) - fprintf(stderr,"\tuser: '%s'\n",n->user.str); - if (n->sessionkey.l>=0) - fprintf(stderr,"\tsessionkey: '%s'\n",n->sessionkey.str); - if (n->challenge.l >= 0) - fprintf(stderr,"\tchallenge: '%s'\n",n->challenge.str); - if (n->target.l >= 0) - fprintf(stderr,"\ttarget: '%s'\n",n->target.str); - if (n->lm.l>=0) - fprintf(stderr,"\tntlm-auth: '%s'\n",n->lm.str); - if (n->nt.l>=0) - fprintf(stderr,"\tntnt-auth: '%s'\n",n->nt.str); -} -#else -#define debug_dump_ntlmssp(X) /**/ -#endif - -#define drop_lstring(X) if(X.l >= 0) free(X.str); -/* Frees the ntlmssp and all it references. */ -void drop_ntlmssp(ntlmssp *nt) { -/* debug("dropping ntlmssp\n"); */ - if (!nt) - return; - drop_lstring(nt->domain); - drop_lstring(nt->workstation); - drop_lstring(nt->user); - drop_lstring(nt->sessionkey); - drop_lstring(nt->challenge); - drop_lstring(nt->target); - drop_lstring(nt->lm); - drop_lstring(nt->nt); - free(nt); -} - -#endif /* 0 */ - /* fetches a string from the authentication packet. * The lstring data-part points to inside the packet itself. * It's up to the user to memcpy() that if the value needs to @@ -182,76 +95,6 @@ return rv; } -#if OLD -/* decodes a base64-encoded ntlm challenge. returns NULL upon failure, - * it's up to the user to free it when needed. - */ -ntlmssp *decode_ntlmssp_auth (char *encoded) { - ntlmssp *rv; - char *decoded; - int32_t length; - struct ntlmhdr *hdr; - struct ntlm_negotiate *n; - struct ntlm_challenge *c; - struct ntlm_authenticate *a; - - debug("decode_ntlmssp_auth(%s)\n",encoded); - decoded=base64_decode(encoded); /* base64_decode returns static storage! */ - length=strlen(encoded)/4*3; /* can be useful for bounds-checking */ - - if (!decoded) { - fprintf(stderr,"ntlmssp: base64-decode failed\n"); - return NULL; - } - hdr=(ntlmhdr *)decoded; - if (memcmp(hdr->signature, "NTLMSSP", 8) != 0) { - fprintf(stderr,"ntlmssp: not a NTLMSSP signature\n"); - return NULL; - } - - rv=create_ntlmssp(); - if (!rv) - return NULL; - - rv->type=WSWAP(hdr->type); - switch (rv->type) { - case NTLM_NEGOTIATE: - n=(struct ntlm_negotiate *) decoded; - rv->domain=fetch_string(decoded,length,&n->domain); - rv->workstation=fetch_string(decoded,length,&n->workstation); - rv->flags=n->flags; - debug_dump_ntlmssp(rv); - break; - case NTLM_CHALLENGE: - c=(struct ntlm_challenge *) decoded; - rv->target=fetch_string(decoded,length,&c->target); - rv->flags=c->flags; - rv->challenge.str=malloc(9); /* 8+1 */ - rv->challenge.l=8; - memcpy(rv->challenge.str,&c->challenge,8); - rv->challenge.str[8]='\0'; - debug_dump_ntlmssp(rv); - break; - case NTLM_AUTHENTICATE: - a=(struct ntlm_authenticate *) decoded; - rv->lm=fetch_string(decoded,length,&a->lmresponse); - rv->nt=fetch_string(decoded,length,&a->ntresponse); - rv->domain=fetch_string(decoded,length,&a->domain); - rv->user=fetch_string(decoded,length,&a->user); - rv->workstation=fetch_string(decoded,length,&a->workstation); - rv->sessionkey=fetch_string(decoded,length,&a->sessionkey); - rv->flags=a->flags; - debug_dump_ntlmssp(rv); - break; - default: - drop_ntlmssp(rv); - fprintf(stderr,"ntlmssp: garbled packet type\n"); - return NULL; - } - return rv; -} -#endif - /* Adds something to the payload. The caller must guarrantee that * there is enough space in the payload string to accommodate the * added value. @@ -291,7 +134,7 @@ return 0; #else /* one challenge - one connection */ SMB_Discon(handle,0); -#endif +#endif /* REUSE_SAME_CHALLENGE */ } debug("Connecting to server\n"); @@ -367,12 +210,12 @@ return 0; } - + /* Authenticating against the NT response doesn't seem to work... */ /* debug("fetching NT response\n"); */ /* tmp=fetch_string(auth,auth_length,&auth->ntresponse); */ /* if (tmp.str==NULL) { */ /* debug("No NT response, fetching LM response\n"); */ - tmp=fetch_string(auth,auth_length,&auth->lmresponse); + tmp=fetch_string((char *)auth,auth_length,&auth->lmresponse); /* } */ if (tmp.str==NULL) { fprintf(stderr,"No auth at all. Returning no-auth\n"); @@ -382,7 +225,7 @@ pass[25]='\0'; debug("fetching domain\n"); - tmp=fetch_string(auth,auth_length,&auth->domain); + tmp=fetch_string((char *)auth,auth_length,&auth->domain); if (tmp.str==NULL) { debug("No domain supplied. Returning no-auth\n"); return 0; @@ -392,7 +235,7 @@ *user++='\0'; debug("fetching user name\n"); - tmp=fetch_string(auth,auth_length,&auth->user); + tmp=fetch_string((char *)auth,auth_length,&auth->user); if (tmp.str==NULL) { debug("No username supplied. Returning no-auth\n"); return 0; @@ -407,7 +250,7 @@ #ifndef REUSE_SAME_CHALLENGE SMB_Discon(handle,0); handle=NULL; -#endif +#endif /* REUSE_SAME_CHALLENGE */ debug("\tresult is %d\n",rv);