Hello,

Here is a small patch that will fix the *callerIp* in the frontend API logfiles.

Cheers,
Johannes

-- 
SUSE LINUX Products GmbH, HRB 16746 (AG Nürnberg)
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer
>From 7ad200f4f86789397eb43877b012a2a0f2e2d39d Mon Sep 17 00:00:00 2001
From: Johannes Renner <jren...@suse.de>
Date: Fri, 4 Nov 2011 11:57:13 +0100
Subject: [PATCH] Fix the *callerIp* in API logfile

---
 .../xmlrpc/LoggingInvocationProcessor.java         |    4 ++--
 .../rhn/frontend/xmlrpc/RhnXmlRpcServer.java       |   15 ++++++++++++---
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/LoggingInvocationProcessor.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/LoggingInvocationProcessor.java
index b930e42..d5d13c7 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/LoggingInvocationProcessor.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/LoggingInvocationProcessor.java
@@ -77,7 +77,7 @@ public class LoggingInvocationProcessor implements XmlRpcInvocationInterceptor {
         StringBuffer buf = new StringBuffer();
         try {
             buf.append("REQUESTED FROM: ");
-            buf.append("*callerIp*"); // TODO: what happened to the caller's IP
+            buf.append(RhnXmlRpcServer.getCallerIp());
             buf.append(" CALL: ");
             buf.append(invocation.getHandlerName());
             buf.append(".");
@@ -114,7 +114,7 @@ public class LoggingInvocationProcessor implements XmlRpcInvocationInterceptor {
         StringBuffer buf = new StringBuffer();
         try {
             buf.append("REQUESTED FROM: ");
-            buf.append("*callerIp*"); // TODO: what happened to the caller's IP
+            buf.append(RhnXmlRpcServer.getCallerIp());
             buf.append(" CALL: ");
             buf.append(invocation.getHandlerName());
             buf.append(".");
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/RhnXmlRpcServer.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/RhnXmlRpcServer.java
index 41d12c5..7e45dab 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/RhnXmlRpcServer.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/RhnXmlRpcServer.java
@@ -26,9 +26,9 @@ import redstone.xmlrpc.XmlRpcServer;
  */
 public class RhnXmlRpcServer extends XmlRpcServer {
 
-    private static ThreadLocal server = new ThreadLocal();
-
-    private static ThreadLocal proto = new ThreadLocal();
+    private static ThreadLocal<String> server = new ThreadLocal<String>();
+    private static ThreadLocal<String> proto = new ThreadLocal<String>();
+    private static ThreadLocal<String> caller = new ThreadLocal<String>();
 
     /**
      * Adding a method to get the callerIp into the XmlRpc for logging.
@@ -49,6 +49,7 @@ public class RhnXmlRpcServer extends XmlRpcServer {
         throws Throwable {
         server.set(serverHost);
         proto.set(protoc);
+        caller.set(callerIp);
         XmlRpcDispatcher dispatcher = new XmlRpcDispatcher(this, callerIp);
         dispatcher.dispatch(xmlInput, output);
     }
@@ -68,4 +69,12 @@ public class RhnXmlRpcServer extends XmlRpcServer {
     public static String getProtocol() {
         return (String) proto.get();
     }
+
+    /**
+     * Retrieve the IP of the current xmlrpc call's caller.
+     * @return the IP of the caller
+     */
+    public static String getCallerIp() {
+        return (String) caller.get();
+    }
 }
-- 
1.7.3.4

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to