swab(1): adds null unveil

This commit is contained in:
Emma Tebibyte 2024-08-28 00:15:15 -06:00
parent b946469da5
commit 8fd5bdf5a6
Signed by: emma
GPG Key ID: 06FA419A1698C270

View File

@ -33,7 +33,7 @@ use sysexits::{ EX_IOERR, EX_OK, EX_OSERR, EX_USAGE };
use strerror::StrError;
#[cfg(target_os="openbsd")] extern crate openbsd;
#[cfg(target_os="openbsd")] use openbsd::{ Promises, pledge };
#[cfg(target_os="openbsd")] use openbsd::{ Promises, pledge, unveil };
fn err(argv0: &str, e: Error, code: u8) -> ExitCode {
eprintln!("{}: {}", argv0, e.strerror());
@ -49,10 +49,14 @@ fn main() -> ExitCode {
let argv = args().collect::<Vec<String>>();
#[cfg(target_os="openbsd")] {
let promises = Promises::new("stdio");
let promises = Promises::new("stdio unveil");
if let Err(e) = pledge(Some(promises), None) {
return err(&argv[0], e, EX_OSERR);
}
if let Err(e) = unveil(None, None) {
return err(&argv[0], e, EX_OSERR);
}
}
let mut buf: Vec<u8> = Vec::new(); // holds the sequence getting swabbed