mm(1): fixes extra file arguments not being unveil(2)ed
This commit is contained in:
parent
e2c03842a3
commit
a4a556a5b6
37
src/mm.rs
37
src/mm.rs
|
@ -76,29 +76,11 @@ fn main() -> ExitCode {
|
|||
Ok("t") => t = false,
|
||||
Ok("i") => { /* add inputs */
|
||||
let input = opt.arg().unwrap();
|
||||
|
||||
if cfg!(target_os="openbsd") {
|
||||
let perms = UnveilPerms::new(vec!['r']);
|
||||
if let Err(e) = unveil(Some(&input), Some(perms)) {
|
||||
eprintln!("{}: {}", argv[0], e.strerror());
|
||||
return ExitCode::from(EX_OSERR as u8);
|
||||
}
|
||||
}
|
||||
|
||||
ins.push(input);
|
||||
mode = Some(In); /* latest argument == -i */
|
||||
},
|
||||
Ok("o") => { /* add output */
|
||||
let output = opt.arg().unwrap();
|
||||
|
||||
if cfg!(target_os="openbsd") {
|
||||
let perms = UnveilPerms::new(vec!['w', 'c']);
|
||||
if let Err(e) = unveil(Some(&output), Some(perms)) {
|
||||
eprintln!("{}: {}", argv[0], e.strerror());
|
||||
return ExitCode::from(EX_OSERR as u8);
|
||||
}
|
||||
}
|
||||
|
||||
outs.push(output);
|
||||
mode = Some(Out); /* latest argument == -o */
|
||||
},
|
||||
|
@ -125,6 +107,25 @@ fn main() -> ExitCode {
|
|||
}
|
||||
|
||||
if cfg!(target_os="openbsd") {
|
||||
|
||||
for input in &ins {
|
||||
let perms = UnveilPerms::new(vec!['r']);
|
||||
|
||||
if let Err(e) = unveil(Some(&input), Some(perms)) {
|
||||
eprintln!("{}: {}", argv[0], e.strerror());
|
||||
return ExitCode::from(EX_OSERR as u8);
|
||||
}
|
||||
}
|
||||
|
||||
for output in &outs {
|
||||
let perms = UnveilPerms::new(vec!['c', 'w']);
|
||||
|
||||
if let Err(e) = unveil(Some(&output), Some(perms)) {
|
||||
eprintln!("{}: {}", argv[0], e.strerror());
|
||||
return ExitCode::from(EX_OSERR as u8);
|
||||
}
|
||||
}
|
||||
|
||||
if let Err(e) = unveil(None, None) {
|
||||
eprintln!("{}: {}", argv[0], e.strerror());
|
||||
return ExitCode::from(EX_OSERR as u8);
|
||||
|
|
Loading…
Reference in New Issue
Block a user