Shell: Add toggle to execute command as root
This commit is contained in:
@ -33,7 +33,7 @@ class Runner::Strategy
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
def attach_to_execution(_command, _event_loop, _starting_time)
|
||||
def attach_to_execution(_command, _event_loop, _starting_time, _privileged_execution:)
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
|
@ -104,7 +104,7 @@ class Runner::Strategy::DockerContainerPool < Runner::Strategy
|
||||
Rails.logger.debug { "#{Time.zone.now.getutc.inspect}: Finished copying files" }
|
||||
end
|
||||
|
||||
def attach_to_execution(command, event_loop, starting_time)
|
||||
def attach_to_execution(command, event_loop, starting_time, _privileged_execution: false)
|
||||
reset_inactivity_timer
|
||||
|
||||
@command = command
|
||||
|
@ -25,7 +25,7 @@ class Runner::Strategy::Null < Runner::Strategy
|
||||
|
||||
def copy_files(_files); end
|
||||
|
||||
def attach_to_execution(command, event_loop, starting_time)
|
||||
def attach_to_execution(command, event_loop, starting_time, _privileged_execution: false)
|
||||
socket = Connection.new(nil, self, event_loop)
|
||||
# We don't want to return an error if the execution environment is changed
|
||||
socket.status = :terminated_by_codeocean if command == ExecutionEnvironment::VALIDATION_COMMAND
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user