mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-20 05:36:23 +02:00
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>
This commit is contained in:
+9
-21
@@ -25,10 +25,6 @@ int goodChecksum(int partnum);
|
|||||||
uint8_t hextonum(char chs), rhex(void);
|
uint8_t hextonum(char chs), rhex(void);
|
||||||
uint16_t word(int, int);
|
uint16_t word(int, int);
|
||||||
|
|
||||||
#ifdef __OpenBSD__
|
|
||||||
void block_unveil(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define COMMAND argv[2]
|
#define COMMAND argv[2]
|
||||||
#define MAC_ADDRESS argv[3]
|
#define MAC_ADDRESS argv[3]
|
||||||
#define PARTN argv[3]
|
#define PARTN argv[3]
|
||||||
@@ -86,7 +82,15 @@ main(int argc, char *argv[])
|
|||||||
fname = argv[1];
|
fname = argv[1];
|
||||||
set_io_flags(argc, argv);
|
set_io_flags(argc, argv);
|
||||||
#ifdef __OpenBSD__
|
#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
|
#endif
|
||||||
openFiles(fname);
|
openFiles(fname);
|
||||||
#ifdef __OpenBSD__
|
#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
|
void
|
||||||
usage(char *util)
|
usage(char *util)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user