Skip to content

Commit

Permalink
Merge pull request #7716 from uyuni-project/master-fix-xmlrpc-provisi…
Browse files Browse the repository at this point in the history
…on-server-endpoint

Fix "system.provisionSystem" xmlrpc endpoint to calculate kickstart host properly (bsc#1215209)
  • Loading branch information
meaksh authored Oct 25, 2023
2 parents f4dbac8 + 455b21c commit 1219fb4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
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 +30,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 @@ -39,15 +42,21 @@ public class RhnXmlRpcServer extends XmlRpcServer {
* @param serverHost the hostname/ipaddress that the client used in
* reference to the server
* @param protoc the protocol the client used in connection to the server
* @param rawRequest the raw request representing the client connection to the server
* 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);
server.remove();
proto.remove();
caller.remove();
request.remove();
}

/**
Expand All @@ -73,4 +82,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 1219fb4

Please sign in to comment.