Compare commits
2 Commits
e2c03842a3
...
e9058803d3
Author | SHA1 | Date | |
---|---|---|---|
e9058803d3 | |||
a4a556a5b6 |
39
src/mm.rs
39
src/mm.rs
@ -52,7 +52,7 @@ fn main() -> ExitCode {
|
||||
let usage = format!("Usage: {} [-aetu] [-i input] [-o output]", argv[0]);
|
||||
|
||||
if cfg!(target_os="openbsd") {
|
||||
let promises = Promises::new("rpath stdio unveil");
|
||||
let promises = Promises::new("cpath rpath stdio unveil wpath");
|
||||
if let Err(e) = pledge(Some(promises), None) {
|
||||
eprintln!("{}: {}", argv[0], e.strerror());
|
||||
return ExitCode::from(EX_OSERR as u8);
|
||||
@ -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);
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2024 E$(NAME)a Tebibyte <e$(NAME)a@tebibyte.media>
|
||||
# Copyright (c) 2024 Emma Tebibyte <emma@tebibyte.media>
|
||||
# SPDX-License-Identifier: FSFAP
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
@ -6,7 +6,7 @@
|
||||
# notice are preserved. This file is offered as-is, without any warranty.
|
||||
|
||||
.PHONY: mm_tests
|
||||
mm_tests: mm_args mm_help mm_stderr
|
||||
mm_tests: mm_args mm_help mm_stderr mm_remaining
|
||||
|
||||
.PHONY: mm_none
|
||||
mm_none: $(BIN)/mm
|
||||
@ -25,3 +25,10 @@ mm_help: $(BIN)/mm
|
||||
# check if stderr is empty upon specifying -e
|
||||
mm_stderr: $(BIN)/mm
|
||||
test "$$(printf 'test\n' | $(BIN)/mm -e 2>&1 >/dev/null )" = "test"
|
||||
|
||||
.PHONY: mm_remaining
|
||||
# check to make sure remaining arguments are used
|
||||
mm_remaining: $(BIN)/mm
|
||||
test "$$($(BIN)/mm -i README COPYING)" = "$$(cat README COPYING)"
|
||||
$(BIN)/mm -i README -o /tmp/mm_test0 /tmp/mm_test1
|
||||
diff /tmp/mm_test0 /tmp/mm_test1
|
||||
|
Loading…
Reference in New Issue
Block a user