Shell: Add toggle to execute command as root

This commit is contained in:
Sebastian Serth
2022-10-04 14:42:15 +02:00
parent f22e3b56f1
commit f53c6cb3ee
8 changed files with 26 additions and 15 deletions

View File

@ -134,8 +134,8 @@ class Runner::Strategy::Poseidon < Runner::Strategy
Rails.logger.debug { "#{Time.zone.now.getutc.inspect}: Finished copying files" }
end
def attach_to_execution(command, event_loop, starting_time)
websocket_url = execute_command(command)
def attach_to_execution(command, event_loop, starting_time, privileged_execution: false)
websocket_url = execute_command(command, privileged_execution: privileged_execution)
socket = Connection.new(websocket_url, self, event_loop)
yield(socket, starting_time)
socket
@ -243,12 +243,12 @@ class Runner::Strategy::Poseidon < Runner::Strategy
private
def execute_command(command)
def execute_command(command, privileged_execution: false)
url = "#{runner_url}/execute"
body = {
command: command,
timeLimit: @execution_environment.permitted_execution_time,
privilegedExecution: @execution_environment.privileged_execution,
privilegedExecution: privileged_execution || @execution_environment.privileged_execution,
}
Rails.logger.debug { "#{Time.zone.now.getutc.inspect}: Preparing command execution at #{url}: #{command}" }
response = self.class.http_connection.post url, body.to_json