Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "system.provisionSystem" xmlrpc endpoint to calculate kickstart host properly (bsc#1215209) #7716

Merged
merged 3 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading