Smol bugfixes

This commit is contained in:
Audrey 2024-04-24 00:51:23 -07:00
parent 6830c8af28
commit 4aa887573d
2 changed files with 6 additions and 5 deletions

View File

@ -674,8 +674,8 @@ impl TracerClient {
e => e?,
};
let syscallno = syscall_no_from_regs!(regs);
log::trace!("Got syscall {} from {}", syscallno, pid);
p.syscall = syscallno;
// log::trace!("pre syscall: {syscallno}");
match syscallno {
nix::libc::SYS_execveat => {
// int execveat(int dirfd, const char *pathname,
@ -858,7 +858,7 @@ impl TracerClient {
}
fn instrument_exec(&mut self, pid: Pid, filename: &str, regs: &user_regs_struct, prog_idx: usize) -> anyhow::Result<()> {
if let Some(new_args) = if filename.ends_with("/docker") {
if let Some(new_args) = if filename.ends_with("/docker") && std::fs::metadata(&filename).is_ok() {
let mut args = read_cstring_array(pid, syscall_arg(&regs, prog_idx + 1) as AddressType)?;
if args.get(1).is_some_and(|c| c.to_str() == Ok("run")) {
let new_machine = self.allocate_machine()?;

View File

@ -16,6 +16,7 @@ pub fn instrument_docker_run_execve(
}
#[derive(Default)]
struct ArgsParsed<'a> {
preamble: Vec<&'a str>,
args: Vec<Argument<'a>>,
image: Option<&'a str>,
cmd: Vec<&'a str>,
@ -49,7 +50,7 @@ pub fn instrument_docker_run_execve(
}
fn reserialize(self) -> Vec<CString> {
let mut result = vec![];
let mut result = self.preamble.into_iter().map(|x| CString::new(x).unwrap()).collect::<Vec<_>>();
for arg in self.args {
match arg {
Argument::Zero(a) => result.push(CString::new(a).unwrap()),
@ -91,8 +92,8 @@ pub fn instrument_docker_run_execve(
]);
let mut string_args = ArgsParsed::default();
let mut args_iter = args.iter();
assert_eq!(args_iter.next().map(|x| x.to_str().unwrap()), Some("docker"));
assert_eq!(args_iter.next().map(|x| x.to_str().unwrap()), Some("run"));
string_args.preamble.push(args_iter.next().unwrap().to_str().unwrap());
string_args.preamble.push(args_iter.next().unwrap().to_str().unwrap());
while let Some(arg) = args_iter.next() {
let arg = arg.to_str()?;