Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn main() {
trace!("Configuration:\n{:#?}", settings);

// Collect command line arguments to pass through
let args: Vec<OsString> = env::args_os().skip(1).collect();
let mut args: Vec<OsString> = env::args_os().skip(1).collect();
trace!("Args:\n{:#?}", args);
if args.is_empty() {
abort("No arguments passed, re-run with --help to learn more.");
Expand All @@ -60,13 +60,6 @@ fn main() {
}
}

// File descriptor 3 is where binfmt_misc typically passes the executable
let binary: PathBuf = read_link("/proc/self/fd/3").unwrap_or_else(|e| {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: unused import: `read_link`
  --> src/main.rs:12:29
   |
12 | use std::fs::{canonicalize, read_link};
   |                             ^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: unused import: `PathBuf`
  --> src/main.rs:15:23
   |
15 | use std::path::{Path, PathBuf};
   |                       ^^^^^^^

warning: `binfmt-dispatcher` (bin "binfmt-dispatcher") generated 2 warnings (run `cargo fix --bin "binfmt-dispatcher"` to apply 2 suggestions)

error!("Failed to read the executable from fd#3: {}", e);
exit(1);
});
trace!("Binary: {:#?}", binary);

let mut interpreter_id = &settings.defaults.interpreter;
for binary in settings.binaries.values() {
if Path::new(&binary.path) == canonicalize(&args[0]).unwrap() {
Expand Down Expand Up @@ -156,8 +149,9 @@ fn main() {
command = Command::new(interpreter_path);
}

command.arg(binary);

let new_binary = args.remove(0);
args.remove(0);
command.arg(new_binary);
// Pass through all the arguments
command.args(&args);

Expand Down