fix bug #22879, log client IP on failure
authorAleš Křenek <ljocha@ics.muni.cz>
Sun, 11 Feb 2007 16:26:17 +0000 (16:26 +0000)
committerAleš Křenek <ljocha@ics.muni.cz>
Sun, 11 Feb 2007 16:26:17 +0000 (16:26 +0000)
org.glite.lb.logger/src/logd.c

index 6c253b1..1a1941d 100644 (file)
@@ -6,6 +6,7 @@
 #include <sys/wait.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <arpa/inet.h>
 #include <signal.h>
 #include <unistd.h> 
 #include <string.h>
@@ -154,12 +155,16 @@ doit(int socket, gss_cred_id_t cred_handle, char *file_name_prefix, int noipc, i
     OM_uint32  min_stat;
     gss_OID    name_type = GSS_C_NO_OID;
 
+    struct sockaddr_in peer;
+    socklen_t  alen = sizeof peer;
+
+    getpeername(socket,(struct sockaddr *) &peer,&alen);
     /* authentication */
-    edg_wll_ll_log(LOG_INFO,"Processing authentication:\n");
+    edg_wll_ll_log(LOG_INFO,"%s: Processing authentication:\n",inet_ntoa(peer.sin_addr));
 // FIXME - put here some meaningfull value of timeout + do somthing if timeouted
     ret = edg_wll_gss_accept(cred_handle,socket,&timeout,&con, &gss_stat);
     if (ret) {
-           edg_wll_ll_log(LOG_ERR,"edg_wll_gss_accept() failed\n");
+           edg_wll_ll_log(LOG_ERR,"%s: edg_wll_gss_accept() failed\n",inet_ntoa(peer.sin_addr));
            return(-1);
     }
 
@@ -169,7 +174,7 @@ doit(int socket, gss_cred_id_t cred_handle, char *file_name_prefix, int noipc, i
     if (GSS_ERROR(gss_stat.major_status)) {
        char *gss_err;
        edg_wll_gss_get_error(&gss_stat, "Cannot read client identification", &gss_err);
-       edg_wll_ll_log(LOG_WARNING, "%s\n", gss_err);
+       edg_wll_ll_log(LOG_WARNING, "%s: %s\n", inet_ntoa(peer.sin_addr),gss_err);
        free(gss_err);
     } else {
        gss_stat.major_status = gss_display_name(&gss_stat.minor_status, client_name,
@@ -177,7 +182,7 @@ doit(int socket, gss_cred_id_t cred_handle, char *file_name_prefix, int noipc, i
        if (GSS_ERROR(gss_stat.major_status)) {
          char *gss_err;
          edg_wll_gss_get_error(&gss_stat, "Cannot process client identification", &gss_err);
-         edg_wll_ll_log(LOG_WARNING, "%s\n", gss_err);
+         edg_wll_ll_log(LOG_WARNING, "%s: %s\n",inet_ntoa(peer.sin_addr),gss_err);
          free(gss_err);
        }
     }