From 761968e3c43dd0f94da52985ed5ad4dcd41f1a17 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 2 Mar 2026 22:29:11 +0000 Subject: util/nvmutil: merge block_unveil back with main we always want unveil/pledge calls to be in main, when possible, so that they are more transparent and easier to understand when re-factoring, because it's extremely important that these syscalls be done correctly. main is small enough now, from other re-factoring changes, that i'm happy to have this back in main now. Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'util/nvmutil/nvmutil.c') diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 0d9020ee..642f4c30 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -25,10 +25,6 @@ int goodChecksum(int partnum); uint8_t hextonum(char chs), rhex(void); uint16_t word(int, int); -#ifdef __OpenBSD__ -void block_unveil(void); -#endif - #define COMMAND argv[2] #define MAC_ADDRESS argv[3] #define PARTN argv[3] @@ -86,7 +82,15 @@ main(int argc, char *argv[]) fname = argv[1]; set_io_flags(argc, argv); #ifdef __OpenBSD__ - block_unveil(); + if (flags == O_RDONLY) { + err_if(unveil(fname, "r") == -1); + err_if(unveil(NULL, NULL) == -1); + err_if(pledge("stdio rpath", NULL) == -1); + } else { + err_if(unveil(fname, "rw") == -1); + err_if(unveil(NULL, NULL) == -1); + err_if(pledge("stdio rpath wpath", NULL) == -1); + } #endif openFiles(fname); #ifdef __OpenBSD__ @@ -461,22 +465,6 @@ swap(int partnum) } } -#ifdef __OpenBSD__ -void -block_unveil(void) -{ - if (flags == O_RDONLY) { - err_if(unveil(fname, "r") == -1); - err_if(unveil(NULL, NULL) == -1); - err_if(pledge("stdio rpath", NULL) == -1); - } else { - err_if(unveil(fname, "rw") == -1); - err_if(unveil(NULL, NULL) == -1); - err_if(pledge("stdio rpath wpath", NULL) == -1); - } -} -#endif - void usage(char *util) { -- cgit v1.2.1