diff --git a/src/fop.rs b/src/fop.rs index 9f547b1..66b7e82 100644 --- a/src/fop.rs +++ b/src/fop.rs @@ -30,11 +30,23 @@ use getopt::GetOpt; use strerror::StrError; use sysexits::{ EX_DATAERR, EX_IOERR, EX_UNAVAILABLE, EX_USAGE }; +#[cfg(target_os="openbsd")] use sysexits::EX_OSERR; +#[cfg(target_os="openbsd")] extern crate openbsd; +#[cfg(target_os="openbsd")] use openbsd::{ Promises, pledge }; + fn main() { let argv = args().collect::>(); let mut d = '\u{1E}'.to_string(); /* ASCII record separator */ let mut optind = 1; + if cfg!(target_os="openbsd") { + let promises = Promises::new("stdio proc exec"); + if let Err(e) = pledge(Some(promises), None) { + eprintln!("{}: {}", argv[0], e.strerror()); + exit(EX_OSERR); + } + } + let usage = format!( "Usage: {} [-d delimiter] index command [args...]", argv[0],