Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
pub use fehler::throws;
pub use structopt::StructOpt;
+pub use std::env;
+pub use std::io::Write;
+pub use std::os::unix::process::CommandExt;
+pub use std::process::Command;
+
pub type AE = anyhow::Error;
#[derive(StructOpt)]
struct Opts {
-
+ #[structopt(long="--no-bwrap")]
+ no_bwrap: bool,
}
#[throws(AE)]
fn main(){
-
+ let opts = Opts::from_args();
+
+ if !opts.no_bwrap {
+ println!("running bwrap");
+
+ let mut bcmd = Command::new("bwrap");
+ bcmd.args("--unshare-net \
+ --dev-bind / / \
+ --tmpfs /tmp \
+ --die-with-parent".split(" "))
+ .arg(env::current_exe().expect("failed to find current executable"))
+ .arg("--no-bwrap")
+ .args(env::args_os().skip(1));
+
+ std::io::stdout().flush().unwrap();
+ Err(bcmd.exec()).unwrap()
+ }
+
+ println!("hi!");
}