MCPcopy Create free account
hub / github.com/evilsocket/medusa / exec

Function exec

src/shell/docker.rs:115–137  ·  view source on GitHub ↗
(container_id: &str, command: &str)

Source from the content-addressed store, hash-verified

113}
114
115pub fn exec(container_id: &str, command: &str) -> Result<Vec<u8>, String> {
116 // HACK: since wget and curl don't have any timeout by default, force it.
117 let command = if command.contains("wget ") {
118 debug!("patching wget command with timeout");
119 command.replace("wget ", "wget --timeout 10 ")
120 } else if command.contains("curl ") {
121 debug!("patching curl command with timeout");
122 command.replace("curl ", "curl --connect-timeout 10 ")
123 } else {
124 command.to_owned()
125 };
126
127 debug!(
128 "running command '{}' inside container '{}'",
129 &command, container_id
130 );
131
132 // create exec operation
133 let exec_id = create_exec(container_id, &command)?;
134
135 // start exec operation by id
136 do_exec(&exec_id)
137}

Callers 1

parseMethod · 0.85

Calls 2

create_execFunction · 0.85
do_execFunction · 0.85

Tested by

no test coverage detected