Launcher: Allow setting a distinct stderr redirect (#1329)

Co-authored-by: Dominik Maier <domenukk@gmail.com>
This commit is contained in:
s1341 2023-07-13 23:50:01 +03:00 committed by GitHub
parent f76331eac7
commit 11fc57a5d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,6 +78,10 @@ where
/// A file name to write all client output to
#[builder(default = None)]
stdout_file: Option<&'a str>,
/// A file name to write all client stderr output to. If not specified, output is sent to
/// `stdout_file`.
#[builder(default = None)]
stderr_file: Option<&'a str>,
/// The `ip:port` address of another broker to connect our new broker to for multi-machine
/// clusters.
#[builder(default = None)]
@ -110,6 +114,7 @@ where
.field("spawn_broker", &self.spawn_broker)
.field("remote_broker_addr", &self.remote_broker_addr)
.field("stdout_file", &self.stdout_file)
.field("stderr_file", &self.stderr_file)
.finish_non_exhaustive()
}
}
@ -148,6 +153,10 @@ where
let stdout_file = self
.stdout_file
.map(|filename| File::create(filename).unwrap());
#[cfg(feature = "std")]
let stderr_file = self
.stderr_file
.map(|filename| File::create(filename).unwrap());
#[cfg(feature = "std")]
let debug_output = std::env::var("LIBAFL_DEBUG_OUTPUT").is_ok();
@ -176,9 +185,13 @@ where
if !debug_output {
if let Some(file) = stdout_file {
dup2(file.as_raw_fd(), libc::STDOUT_FILENO)?;
if let Some(stderr) = stderr_file {
dup2(stderr.as_raw_fd(), libc::STDERR_FILENO)?;
} else {
dup2(file.as_raw_fd(), libc::STDERR_FILENO)?;
}
}
}
// Fuzzer client. keeps retrying the connection to broker till the broker starts
let (state, mgr) = RestartingMgr::<MT, S, SP>::builder()