Skip to content

Commit

Permalink
Fix system.provisionSystem xmlrpc endpoint to calculate host properly…
Browse files Browse the repository at this point in the history
… (bsc#1215209)
  • Loading branch information
meaksh committed Oct 19, 2023
1 parent 77c90b6 commit 2701974
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import java.io.InputStream;
import java.io.Writer;
import javax.servlet.http.HttpServletRequest;

import redstone.xmlrpc.XmlRpcDispatcher;
import redstone.xmlrpc.XmlRpcServer;
Expand All @@ -28,6 +29,7 @@ public class RhnXmlRpcServer extends XmlRpcServer {
private static ThreadLocal<String> server = new ThreadLocal<>();
private static ThreadLocal<String> proto = new ThreadLocal<>();
private static ThreadLocal<String> caller = new ThreadLocal<>();
private static ThreadLocal<HttpServletRequest> request = new ThreadLocal<>();

/**
* Adding a method to get the callerIp into the XmlRpc for logging.
Expand All @@ -42,10 +44,11 @@ public class RhnXmlRpcServer extends XmlRpcServer {
* available to custom processors.
*/
public void execute(InputStream xmlInput, Writer output, String callerIp,
String serverHost, String protoc) {
String serverHost, String protoc, HttpServletRequest rawRequest) {
server.set(serverHost);
proto.set(protoc);
caller.set(callerIp);
request.set(rawRequest);
XmlRpcDispatcher dispatcher = new XmlRpcDispatcher(this, callerIp);
dispatcher.dispatch(xmlInput, output);
}
Expand Down Expand Up @@ -73,4 +76,12 @@ public static String getProtocol() {
public static String getCallerIp() {
return caller.get();
}

/**
* Retrieve the the raw request of the current xmlrpc call.
* @return HttpServletRequest object
*/
public static HttpServletRequest getRequest() {
return request.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) {
response.getWriter(),
request.getRemoteAddr(),
request.getLocalName(),
request.getProtocol());
request.getProtocol(),
request);

/*
* jesusr - 2007.09.14
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
import com.redhat.rhn.domain.token.ActivationKey;
import com.redhat.rhn.domain.token.ActivationKeyFactory;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.frontend.action.kickstart.KickstartHelper;
import com.redhat.rhn.frontend.context.Context;
import com.redhat.rhn.frontend.dto.ActivationKeyDto;
import com.redhat.rhn.frontend.dto.ErrataOverview;
Expand Down Expand Up @@ -2928,7 +2929,8 @@ public int provisionSystem(User loggedInUser, Integer sid, String profileName)
"No Kickstart Profile found with label: " + profileName);
}

String host = RhnXmlRpcServer.getServerName();
KickstartHelper helper = new KickstartHelper(RhnXmlRpcServer.getRequest());
String host = helper.getKickstartHost();


KickstartScheduleCommand cmd = new KickstartScheduleCommand(
Expand Down Expand Up @@ -2981,7 +2983,8 @@ public int provisionSystem(User loggedInUser, Integer sid,
"No Kickstart Profile found with label: " + profileName);
}

String host = RhnXmlRpcServer.getServerName();
KickstartHelper helper = new KickstartHelper(RhnXmlRpcServer.getRequest());
String host = helper.getKickstartHost();

KickstartScheduleCommand cmd = new KickstartScheduleCommand(
Long.valueOf(sid),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix system.provisionSystem xmlrpc endpoint to calculate host properly (bsc#1215209)

0 comments on commit 2701974

Please sign in to comment.