]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Markus Moeller <huaraz@moeller.plus.com>
authorHenrik Nordstrom <henrik@henriknordstrom.net>
Tue, 9 Feb 2010 20:07:00 +0000 (21:07 +0100)
committerHenrik Nordstrom <henrik@henriknordstrom.net>
Tue, 9 Feb 2010 20:07:00 +0000 (21:07 +0100)
squid_kerb_auth logging clarification

add ERROR, WARNING, etc to the logging messages.

helpers/negotiate_auth/squid_kerb_auth/squid_kerb_auth.c

index e889caa84591c73a20f0fe6aac37c48bf38e1f93..f9e84c27d1efdec6d07252d1a45d02bf68ee9cd4 100644 (file)
@@ -115,12 +115,12 @@ char *gethost_name(void)
 
     rc = gethostname(hostname,sysconf(_SC_HOST_NAME_MAX));
     if (rc) {
-        fprintf(stderr, "%s| %s: error while resolving hostname '%s'\n", LogTime(), PROGRAM, hostname);
+        fprintf(stderr, "%s| %s: ERROR: resolving hostname '%s' failed\n", LogTime(), PROGRAM, hostname);
         return NULL;
     }
     rc = xgetaddrinfo(hostname,NULL,NULL,&hres);
     if (rc != 0) {
-        fprintf(stderr, "%s| %s: error while resolving hostname with getaddrinfo: %s\n", LogTime(), PROGRAM, xgai_strerror(rc));
+        fprintf(stderr, "%s| %s: ERROR: resolving hostname with getaddrinfo: %s failed\n", LogTime(), PROGRAM, xgai_strerror(rc));
         return NULL;
     }
     hres_list=hres;
@@ -131,7 +131,7 @@ char *gethost_name(void)
     }
     rc = xgetnameinfo (hres->ai_addr, hres->ai_addrlen,hostname, sizeof (hostname), NULL, 0, 0);
     if (rc != 0) {
-        fprintf(stderr, "%s| %s: error while resolving ip address with getnameinfo: %s\n", LogTime(), PROGRAM, xgai_strerror(rc));
+        fprintf(stderr, "%s| %s: ERROR: resolving ip address with getnameinfo: %s failed\n", LogTime(), PROGRAM, xgai_strerror(rc));
         xfreeaddrinfo(hres);
         return NULL ;
     }
@@ -190,10 +190,10 @@ int check_gss_err(OM_uint32 major_status, OM_uint32 minor_status, const char* fu
             gss_release_buffer(&min_stat, &status_string);
         }
         if (debug)
-            fprintf(stderr, "%s| %s: %s failed: %s\n", LogTime(), PROGRAM, function, buf);
+            fprintf(stderr, "%s| %s: ERROR: %s failed: %s\n", LogTime(), PROGRAM, function, buf);
         fprintf(stdout, "BH %s failed: %s\n",function, buf);
         if (log)
-            fprintf(stderr, "%s| %s: User not authenticated\n", LogTime(), PROGRAM);
+            fprintf(stderr, "%s| %s: INFO: User not authenticated\n", LogTime(), PROGRAM);
         return(1);
     }
     return(0);
@@ -250,19 +250,19 @@ int main(int argc, char * const argv[])
             fprintf(stderr, "default SPN is HTTP/fqdn@DEFAULT_REALM\n");
             exit(0);
         default:
-            fprintf(stderr, "%s| %s: unknown option: -%c.\n", LogTime(), PROGRAM, opt);
+            fprintf(stderr, "%s| %s: WARNING: unknown option: -%c.\n", LogTime(), PROGRAM, opt);
         }
     }
 
     if (debug)
-        fprintf(stderr, "%s| %s: Starting version %s\n", LogTime(), PROGRAM, VERSION);
+        fprintf(stderr, "%s| %s: INFO: Starting version %s\n", LogTime(), PROGRAM, VERSION);
     if (service_principal && strcasecmp(service_principal,"GSS_C_NO_NAME") ) {
         service.value = service_principal;
         service.length = strlen((char *)service.value);
     } else {
         host_name=gethost_name();
         if ( !host_name ) {
-            fprintf(stderr, "%s| %s: Local hostname could not be determined. Please specify the service principal\n", LogTime(), PROGRAM);
+            fprintf(stderr, "%s| %s: FATAL: Local hostname could not be determined. Please specify the service principal\n", LogTime(), PROGRAM);
             fprintf(stdout, "BH hostname error\n");
             exit(-1);
         }
@@ -275,7 +275,7 @@ int main(int argc, char * const argv[])
         if (fgets(buf, sizeof(buf)-1, stdin) == NULL) {
             if (ferror(stdin)) {
                 if (debug)
-                    fprintf(stderr, "%s| %s: fgets() failed! dying..... errno=%d (%s)\n", LogTime(), PROGRAM, ferror(stdin),
+                    fprintf(stderr, "%s| %s: FATAL: fgets() failed! dying..... errno=%d (%s)\n", LogTime(), PROGRAM, ferror(stdin),
                             strerror(ferror(stdin)));
 
                 fprintf(stdout, "BH input error\n");
@@ -294,25 +294,25 @@ int main(int argc, char * const argv[])
         }
         if (err) {
             if (debug)
-                fprintf(stderr, "%s| %s: Oversized message\n", LogTime(), PROGRAM);
+                fprintf(stderr, "%s| %s: ERROR: Oversized message\n", LogTime(), PROGRAM);
             fprintf(stdout, "BH Oversized message\n");
             err = 0;
             continue;
         }
 
         if (debug)
-            fprintf(stderr, "%s| %s: Got '%s' from squid (length: %d).\n", LogTime(), PROGRAM, buf,length);
+            fprintf(stderr, "%s| %s: DEBUG: Got '%s' from squid (length: %d).\n", LogTime(), PROGRAM, buf,length);
 
         if (buf[0] == '\0') {
             if (debug)
-                fprintf(stderr, "%s| %s: Invalid request\n", LogTime(), PROGRAM);
+                fprintf(stderr, "%s| %s: ERROR: Invalid request\n", LogTime(), PROGRAM);
             fprintf(stdout, "BH Invalid request\n");
             continue;
         }
 
         if (strlen(buf) < 2) {
             if (debug)
-                fprintf(stderr, "%s| %s: Invalid request [%s]\n", LogTime(), PROGRAM, buf);
+                fprintf(stderr, "%s| %s: ERROR: Invalid request [%s]\n", LogTime(), PROGRAM, buf);
             fprintf(stdout, "BH Invalid request\n");
             continue;
         }
@@ -354,7 +354,7 @@ int main(int argc, char * const argv[])
 
         if ( strncmp(buf, "YR", 2) && strncmp(buf, "KK", 2) ) {
             if (debug)
-                fprintf(stderr, "%s| %s: Invalid request [%s]\n", LogTime(), PROGRAM, buf);
+                fprintf(stderr, "%s| %s: ERROR: Invalid request [%s]\n", LogTime(), PROGRAM, buf);
             fprintf(stdout, "BH Invalid request\n");
             continue;
         }
@@ -366,14 +366,14 @@ int main(int argc, char * const argv[])
 
         if (strlen(buf) <= 3) {
             if (debug)
-                fprintf(stderr, "%s| %s: Invalid negotiate request [%s]\n", LogTime(), PROGRAM, buf);
+                fprintf(stderr, "%s| %s: ERROR: Invalid negotiate request [%s]\n", LogTime(), PROGRAM, buf);
             fprintf(stdout, "BH Invalid negotiate request\n");
             continue;
         }
 
         input_token.length = ska_base64_decode_len(buf+3);
         if (debug)
-            fprintf(stderr, "%s| %s: Decode '%s' (decoded length: %d).\n", LogTime(), PROGRAM, buf+3,(int)input_token.length);
+            fprintf(stderr, "%s| %s: DEBUG: Decode '%s' (decoded length: %d).\n", LogTime(), PROGRAM, buf+3,(int)input_token.length);
         input_token.value = xmalloc(input_token.length);
 
         ska_base64_decode(input_token.value,buf+3,input_token.length);
@@ -382,7 +382,7 @@ int main(int argc, char * const argv[])
         if ((input_token.length >= sizeof ntlmProtocol + 1) &&
                 (!memcmp (input_token.value, ntlmProtocol, sizeof ntlmProtocol))) {
             if (debug)
-                fprintf(stderr, "%s| %s: received type %d NTLM token\n", LogTime(), PROGRAM, (int) *((unsigned char *)input_token.value + sizeof ntlmProtocol));
+                fprintf(stderr, "%s| %s: WARNING: received type %d NTLM token\n", LogTime(), PROGRAM, (int) *((unsigned char *)input_token.value + sizeof ntlmProtocol));
             fprintf(stdout, "BH received type %d NTLM token\n",(int) *((unsigned char *)input_token.value + sizeof ntlmProtocol));
             goto cleanup;
         }
@@ -429,7 +429,7 @@ int main(int argc, char * const argv[])
             token = xmalloc(ska_base64_encode_len(spnegoTokenLength));
             if (token == NULL) {
                 if (debug)
-                    fprintf(stderr, "%s| %s: Not enough memory\n", LogTime(), PROGRAM);
+                    fprintf(stderr, "%s| %s: ERROT: Not enough memory\n", LogTime(), PROGRAM);
                 fprintf(stdout, "BH Not enough memory\n");
                 goto cleanup;
             }
@@ -440,7 +440,7 @@ int main(int argc, char * const argv[])
                 goto cleanup;
             if (major_status & GSS_S_CONTINUE_NEEDED) {
                 if (debug)
-                    fprintf(stderr, "%s| %s: continuation needed\n", LogTime(), PROGRAM);
+                    fprintf(stderr, "%s| %s: INFO: continuation needed\n", LogTime(), PROGRAM);
                 fprintf(stdout, "TT %s\n",token);
                 goto cleanup;
             }
@@ -453,7 +453,7 @@ int main(int argc, char * const argv[])
             user=xmalloc(output_token.length+1);
             if (user == NULL) {
                 if (debug)
-                    fprintf(stderr, "%s| %s: Not enough memory\n", LogTime(), PROGRAM);
+                    fprintf(stderr, "%s| %s: ERROR: Not enough memory\n", LogTime(), PROGRAM);
                 fprintf(stdout, "BH Not enough memory\n");
                 goto cleanup;
             }
@@ -461,16 +461,16 @@ int main(int argc, char * const argv[])
             user[output_token.length]='\0';
             fprintf(stdout, "AF %s %s\n",token,user);
             if (debug)
-                fprintf(stderr, "%s| %s: AF %s %s\n", LogTime(), PROGRAM, token,user);
+                fprintf(stderr, "%s| %s: DEBUG: AF %s %s\n", LogTime(), PROGRAM, token,user);
             if (log)
-                fprintf(stderr, "%s| %s: User %s authenticated\n", LogTime(), PROGRAM, user);
+                fprintf(stderr, "%s| %s: INFO: User %s authenticated\n", LogTime(), PROGRAM, user);
             goto cleanup;
         } else {
             if (check_gss_err(major_status,minor_status,"gss_accept_sec_context()",debug,log) )
                 goto cleanup;
             if (major_status & GSS_S_CONTINUE_NEEDED) {
                 if (debug)
-                    fprintf(stderr, "%s| %s: continuation needed\n", LogTime(), PROGRAM);
+                    fprintf(stderr, "%s| %s: INFO: continuation needed\n", LogTime(), PROGRAM);
                 fprintf(stdout, "NA %s\n",token);
                 goto cleanup;
             }
@@ -486,7 +486,7 @@ int main(int argc, char * const argv[])
             user=xmalloc(output_token.length+1);
             if (user == NULL) {
                 if (debug)
-                    fprintf(stderr, "%s| %s: Not enough memory\n", LogTime(), PROGRAM);
+                    fprintf(stderr, "%s| %s: ERROR: Not enough memory\n", LogTime(), PROGRAM);
                 fprintf(stdout, "BH Not enough memory\n");
                 goto cleanup;
             }
@@ -494,9 +494,9 @@ int main(int argc, char * const argv[])
             user[output_token.length]='\0';
             fprintf(stdout, "AF %s %s\n","AA==",user);
             if (debug)
-                fprintf(stderr, "%s| %s: AF %s %s\n", LogTime(), PROGRAM, "AA==", user);
+                fprintf(stderr, "%s| %s: DEBUG: AF %s %s\n", LogTime(), PROGRAM, "AA==", user);
             if (log)
-                fprintf(stderr, "%s| %s: User %s authenticated\n", LogTime(), PROGRAM, user);
+                fprintf(stderr, "%s| %s: INFO: User %s authenticated\n", LogTime(), PROGRAM, user);
 
 cleanup:
             gss_release_buffer(&minor_status, &input_token);