]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fixed smb_lm ntlm helper debugging
authorFrancesco Chemolli <kinkie@squid-cache.org>
Sat, 1 May 2010 19:18:36 +0000 (21:18 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Sat, 1 May 2010 19:18:36 +0000 (21:18 +0200)
helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.c
helpers/ntlm_auth/smb_lm/ntlm_smb_lm_auth.h

index 89379611c922c1159ffd6db7b8fb50392bcfebf2..e7db87b3588ce9d4307b80295024efcdd2c58ff8 100644 (file)
@@ -195,7 +195,7 @@ process_options(int argc, char *argv[])
          * it's going to live as long as the process anyways */
         d = malloc(strlen(argv[j]) + 1);
         strcpy(d, argv[j]);
-        debug("Adding domain-controller %s\n", d);
+        print_debug("Adding domain-controller %s\n", d);
         if (NULL == (c = strchr(d, '\\')) && NULL == (c = strchr(d, '/'))) {
             fprintf(stderr, "Couldn't grok domain-controller %s\n", d);
             free(d);
@@ -247,31 +247,31 @@ obtain_challenge()
     int j = 0;
     const char *ch = NULL;
     for (j = 0; j < numcontrollers; j++) {
-        debug("obtain_challenge: selecting %s\\%s (attempt #%d)\n",
+        print_debug("obtain_challenge: selecting %s\\%s (attempt #%d)\n",
               current_dc->domain, current_dc->controller, j + 1);
         if (current_dc->dead != 0) {
             if (time(NULL) - current_dc->dead >= DEAD_DC_RETRY_INTERVAL) {
                 /* mark helper as retry-worthy if it's so. */
-                debug("Reviving DC\n");
+                print_debug("Reviving DC\n");
                 current_dc->dead = 0;
             } else {           /* skip it */
-                debug("Skipping it\n");
+                print_debug("Skipping it\n");
                 continue;
             }
         }
         /* else branch. Here we KNOW that the DC is fine */
-        debug("attempting challenge retrieval\n");
+        print_debug("attempting challenge retrieval\n");
         ch = make_challenge(current_dc->domain, current_dc->controller);
-        debug("make_challenge retuned %p\n", ch);
+        print_debug("make_challenge retuned %p\n", ch);
         if (ch) {
-            debug("Got it\n");
+            print_debug("Got it\n");
             return ch;         /* All went OK, returning */
         }
         /* Huston, we've got a problem. Take this DC out of the loop */
-        debug("Marking DC as DEAD\n");
+        print_debug("Marking DC as DEAD\n");
         current_dc->dead = time(NULL);
         /* Try with the next */
-        debug("moving on to next controller\n");
+        print_debug("moving on to next controller\n");
         current_dc = current_dc->next;
     }
     /* all DCs failed. */
@@ -293,13 +293,13 @@ manage_request()
                 strerror(errno));
         exit(1);               /* BIIG buffer */
     }
-    debug("managing request\n");
+    print_debug("managing request\n");
     ch2 = memchr(buf, '\n', BUFFER_SIZE);      /* safer against overrun than strchr */
     if (ch2) {
         *ch2 = '\0';           /* terminate the string at newline. */
         ch = ch2;
     }
-    debug("ntlm authenticator. Got '%s' from Squid\n", buf);
+    print_debug("ntlm authenticator. Got '%s' from Squid\n", buf);
 
     if (memcmp(buf, "KK ", 3) == 0) {  /* authenticate-request */
         /* figure out what we got */
@@ -357,7 +357,7 @@ manage_request()
                 smb_errorclass = SMBlib_Error_Class(SMB_Get_Last_SMB_Err());
                 smb_errorcode = SMBlib_Error_Code(SMB_Get_Last_SMB_Err());
                 nb_error = RFCNB_Get_Last_Error();
-                debug("No creds. SMBlib error %d, SMB error class %d, SMB error code %d, NB error %d\n",
+                print_debug("No creds. SMBlib error %d, SMB error class %d, SMB error code %d, NB error %d\n",
                       smblib_err, smb_errorclass, smb_errorcode, nb_error);
                 /* Should I use smblib_err? Actually it seems I can do as well
                  * without it.. */
@@ -370,7 +370,7 @@ manage_request()
                 }
                 switch (smb_errorclass) {
                 case SMBC_SUCCESS:
-                    debug("Huh? Got a SMB success code but could check auth..");
+                    print_debug("Huh? Got a SMB success code but could check auth..");
                     SEND("NA Authentication failed");
                     /*
                      * send_bh_or_ld("SMB success, but no creds. Internal error?",
@@ -379,7 +379,7 @@ manage_request()
                     return;
                 case SMBC_ERRDOS:
                     /*this is the most important one for errors */
-                    debug("DOS error\n");
+                    print_debug("DOS error\n");
                     switch (smb_errorcode) {
                         /* two categories matter to us: those which could be
                          * server errors, and those which are auth errors */
@@ -401,7 +401,7 @@ manage_request()
                         return;
                     }
                 case SMBC_ERRSRV:      /* server errors */
-                    debug("Server error");
+                    print_debug("Server error");
                     switch (smb_errorcode) {
                         /* mostly same as above */
                     case SMBV_badpw:
@@ -460,11 +460,11 @@ manage_request()
 int
 main(int argc, char *argv[])
 {
-    debug("ntlm_auth build " __DATE__ ", " __TIME__ " starting up...\n");
+    print_debug("ntlm_auth build " __DATE__ ", " __TIME__ " starting up...\n");
 #if DEBUG
-    debug("changing dir to /tmp\n");
+    print_debug("changing dir to /tmp\n");
     if (chdir("/tmp") != 0) {
-        debug("ERROR: (%d) failed.\n",errno);
+        print_debug("ERROR: (%d) failed.\n",errno);
         return 2;
     }
 #endif
@@ -472,7 +472,7 @@ main(int argc, char *argv[])
     my_program_name = argv[0];
     process_options(argc, argv);
 
-    debug("options processed OK\n");
+    print_debug("options processed OK\n");
 
     /* initialize FDescs */
     setbuf(stdout, NULL);
@@ -484,7 +484,7 @@ main(int argc, char *argv[])
         int n;
         pid_t pid = getpid();
         n = pid % numcontrollers;
-        debug("load balancing. Selected controller #%d\n", n);
+        print_debug("load balancing. Selected controller #%d\n", n);
         while (n > 0) {
             current_dc = current_dc->next;
             n--;
index 3d96aaf456c833f4592c70687fa11f4bee0b6062..13ecfc3d247d559e0f758bfd5d4a2df3401520fb 100644 (file)
@@ -40,9 +40,9 @@
 
 
 /* A couple of harmless helper macros */
-#define SEND(X) debug("sending '%s' to squid\n",X); printf(X "\n");
+#define SEND(X) print_debug("sending '%s' to squid\n",X); printf(X "\n");
 #ifdef __GNUC__
-#define SEND2(X,Y...) debug("sending '" X "' to squid\n",Y); printf(X "\n",Y);
+#define SEND2(X,Y...) print_debug("sending '" X "' to squid\n",Y); printf(X "\n",Y);
 #else
 /* no gcc, no debugging. varargs macros are a gcc extension */
 #define SEND2 printf