intcmp(1): adds null unveil
This commit is contained in:
parent
9aeadd8f8f
commit
06384c72fb
@ -26,27 +26,35 @@ extern crate getopt;
|
|||||||
extern crate sysexits;
|
extern crate sysexits;
|
||||||
|
|
||||||
use getopt::GetOpt;
|
use getopt::GetOpt;
|
||||||
use sysexits::EX_USAGE;
|
use sysexits::{ EX_DATAERR, EX_USAGE };
|
||||||
|
|
||||||
#[cfg(target_os="openbsd")] use sysexits::EX_OSERR;
|
#[cfg(target_os="openbsd")] use sysexits::EX_OSERR;
|
||||||
#[cfg(target_os="openbsd")] extern crate openbsd;
|
#[cfg(target_os="openbsd")] extern crate openbsd;
|
||||||
#[cfg(target_os="openbsd")] extern crate strerror;
|
#[cfg(target_os="openbsd")] extern crate strerror;
|
||||||
#[cfg(target_os="openbsd")] use openbsd::{ Promises, pledge };
|
#[cfg(target_os="openbsd")] use openbsd::{ Promises, pledge, unveil };
|
||||||
#[cfg(target_os="openbsd")] use strerror::StrError;
|
#[cfg(target_os="openbsd")] use strerror::StrError;
|
||||||
|
|
||||||
fn usage(s: &str) -> ExitCode {
|
fn err(argv0: &String, e: String, code: u8) -> ExitCode {
|
||||||
eprintln!("Usage: {} [-egl] integer integer...", s);
|
eprintln!("{}: {}", argv0, e);
|
||||||
ExitCode::from(EX_USAGE as u8)
|
ExitCode::from(code)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn usage(argv0: &str) -> ExitCode {
|
||||||
|
eprintln!("Usage: {} [-egl] integer integer...", argv0);
|
||||||
|
ExitCode::from(EX_USAGE)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> ExitCode {
|
fn main() -> ExitCode {
|
||||||
let argv = args().collect::<Vec<String>>();
|
let argv = args().collect::<Vec<String>>();
|
||||||
|
|
||||||
#[cfg(target_os="openbsd")] {
|
#[cfg(target_os="openbsd")] {
|
||||||
let promises = Promises::new("stdio");
|
let promises = Promises::new("stdio unveil");
|
||||||
if let Err(e) = pledge(Some(promises), None) {
|
if let Err(e) = pledge(Some(promises), None) {
|
||||||
eprintln!("{}: {}", argv[0], e.strerror());
|
return err(&argv[0], e.strerror(), EX_OSERR);
|
||||||
return ExitCode::from(EX_OSERR as u8);
|
}
|
||||||
|
|
||||||
|
if let Err(e) = unveil(None, None) {
|
||||||
|
return err(&argv[0], e.strerror(), EX_OSERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,8 +86,8 @@ fn main() -> ExitCode {
|
|||||||
match arg.parse::<usize>() { /* parse current operand */
|
match arg.parse::<usize>() { /* parse current operand */
|
||||||
Ok(n) => currn = n,
|
Ok(n) => currn = n,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("{}: {}: {}", &argv[0], arg, e);
|
let error = arg.to_owned() + ": " + &e.to_string();
|
||||||
return ExitCode::from(EX_USAGE as u8);
|
return err(&argv[0], error, EX_DATAERR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user