Compare commits
No commits in common. "e9058803d32629ecc5de2ad96c078a1a8dbdbf3a" and "e2c03842a30a8a338131e7952cf5287d6588a640" have entirely different histories.
e9058803d3
...
e2c03842a3
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("cpath rpath stdio unveil wpath");
|
||||
let promises = Promises::new("rpath stdio unveil");
|
||||
if let Err(e) = pledge(Some(promises), None) {
|
||||
eprintln!("{}: {}", argv[0], e.strerror());
|
||||
return ExitCode::from(EX_OSERR as u8);
|
||||
@ -76,11 +76,29 @@ 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 */
|
||||
},
|
||||
@ -107,25 +125,6 @@ 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 Emma Tebibyte <emma@tebibyte.media>
|
||||
# Copyright (c) 2024 E$(NAME)a Tebibyte <e$(NAME)a@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_remaining
|
||||
mm_tests: mm_args mm_help mm_stderr
|
||||
|
||||
.PHONY: mm_none
|
||||
mm_none: $(BIN)/mm
|
||||
@ -25,10 +25,3 @@ 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