--------------------- PatchSet 3607 Date: 2002/01/20 23:30:05 Author: kinkie Branch: ntlm Tag: (none) Log: Added command line options management function. Debug is now disabled by default, use -d to enable Added request for target authentication domain, will have to do until we can ask winbindd for it. Fixed buglet in the squid-helper protocol engine. Fixed buglet in the debugging output stuff. Members: src/auth/ntlm/helpers/winbind/wb_ntlm_auth.c:1.1.2.11->1.1.2.12 Index: squid/src/auth/ntlm/helpers/winbind/wb_ntlm_auth.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/auth/ntlm/helpers/winbind/Attic/wb_ntlm_auth.c,v retrieving revision 1.1.2.11 retrieving revision 1.1.2.12 diff -u -r1.1.2.11 -r1.1.2.12 --- squid/src/auth/ntlm/helpers/winbind/wb_ntlm_auth.c 13 Jan 2002 10:28:13 -0000 1.1.2.11 +++ squid/src/auth/ntlm/helpers/winbind/wb_ntlm_auth.c 20 Jan 2002 23:30:05 -0000 1.1.2.12 @@ -38,6 +38,13 @@ #include #endif +#ifdef HAVE_UNISTD_H +#include +#endif +#if HAVE_GETOPT_H +#include +#endif + #include "winbind_nss_config.h" #include "winbindd_nss.h" @@ -64,9 +71,10 @@ SEND2("BH %s",reason); } -char debug_enabled=1; +char debug_enabled=0; char *myname; pid_t mypid; +char *target_domain; static void lc(char *string) @@ -240,13 +248,14 @@ debug("Got '%s' from squid.\n",buf); if (memcmp(buf, "YR", 2) == 0) { /* refresh-request */ - sendchallenge(ntlm_make_challenge(DOMAIN,NULL,build_challenge(), + sendchallenge(ntlm_make_challenge(target_domain,NULL,build_challenge(), CHALLENGE_LEN)); return; } - if (memcmp(buf,"KK ",3) != 0 ) { /* not an auth-request */ + if (strncmp(buf,"KK ",3) != 0 ) { /* not an auth-request */ helperfail("illegal request received"); warn("Illegal request received\n"); + return; } /* At this point I'm sure it's a KK */ decoded=base64_decode(buf+3); @@ -278,8 +287,32 @@ } /* notreached */ return; - +} +void +process_options(int argc, char *argv[]) +{ + int opt; + + while (-1 != (opt = getopt(argc,argv,"d"))) { + switch (opt) { + case 'd': + debug_enabled=1; + break; + default: + warn("Unknown option: -%c. Exiting\n",opt); + exit(1); + break; /* not reached */ + } + if (optind < argc-1) { + warn("I need a domain name to set as auth-target. Exiting\n"); + exit(1); + return; /* not reached */ + } + target_domain=argv[optind]; + warn("target domain is %s\n",target_domain); + } + return; } int main (int argc, char ** argv) { @@ -287,10 +320,13 @@ myname=strrchr(argv[0],'/'); if (myname==NULL) myname=argv[0]; + else + myname++; } else { myname="(unknown)"; } mypid=getpid(); + process_options(argc,argv); debug("ntlm winbindd auth helper build " __DATE__ ", " __TIME__ " starting up...\n"); /* initialize FDescs */