summaryrefslogtreecommitdiff
path: root/util/nvmutil
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-02 22:29:11 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-02 22:30:19 +0000
commit761968e3c43dd0f94da52985ed5ad4dcd41f1a17 (patch)
treedf395b7532a074f9f8ea0fb2d9bc314113c8a2ce /util/nvmutil
parent589ac92781ab62cc265e32568b7b33c5f281cbe8 (diff)
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 <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil')
-rw-r--r--util/nvmutil/nvmutil.c30
1 files changed, 9 insertions, 21 deletions
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)
{