fop(1): adds pledge support
This commit is contained in:
parent
cf96a13419
commit
6c882f54cb
12
src/fop.rs
12
src/fop.rs
@ -30,11 +30,23 @@ use getopt::GetOpt;
|
|||||||
use strerror::StrError;
|
use strerror::StrError;
|
||||||
use sysexits::{ EX_DATAERR, EX_IOERR, EX_UNAVAILABLE, EX_USAGE };
|
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() {
|
fn main() {
|
||||||
let argv = args().collect::<Vec<String>>();
|
let argv = args().collect::<Vec<String>>();
|
||||||
let mut d = '\u{1E}'.to_string(); /* ASCII record separator */
|
let mut d = '\u{1E}'.to_string(); /* ASCII record separator */
|
||||||
let mut optind = 1;
|
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!(
|
let usage = format!(
|
||||||
"Usage: {} [-d delimiter] index command [args...]",
|
"Usage: {} [-d delimiter] index command [args...]",
|
||||||
argv[0],
|
argv[0],
|
||||||
|
Loading…
Reference in New Issue
Block a user