summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-02 12:16:30 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-02 12:18:23 +0000
commit6de3968f2bafb84777d546887eae7d391d573594 (patch)
tree36d24c9868a9dfabf12cb6a0986d934a0015895c /util
parent9c23eac148f382552acc0595a0c1734dd9b7cec0 (diff)
util/nvmutil: split unveil code to new function
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util')
-rw-r--r--util/nvmutil/nvmutil.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index d28b0dca..d39d9dbd 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -23,6 +23,10 @@ void cmd_setchecksum(void), cmd_brick(void), swap(int partnum), writeGbe(void),
int goodChecksum(int partnum);
uint8_t hextonum(char chs), rhex(void);
+#ifdef __OpenBSD__
+void block_unveil(void);
+#endif
+
#define COMMAND argv[2]
#define MAC_ADDRESS argv[3]
#define PARTN argv[3]
@@ -97,17 +101,7 @@ main(int argc, char *argv[])
checkdir(fname);
#ifdef __OpenBSD__
- err_if(unveil("/dev/urandom", "r") == -1);
-
- 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);
- }
+ block_unveil();
#endif
openFiles(fname);
@@ -442,6 +436,24 @@ swap(int partnum)
}
}
+#ifdef __OpenBSD__
+void
+block_unveil(void)
+{
+ err_if(unveil("/dev/urandom", "r") == -1);
+
+ 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)
{