mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-21 00:27:09 +02:00
libreboot-utils: simplified pledge/unveil usage
i no longer care about openbsd 5.9. we assume unveil is available, as has been the case for the past 12 years. i use wrappers for unveil and pledge, which means that i call them on every os. on OSes that don't have these, i just return. it's somewhat inelegant, but also means that i see errors more easily, e.g. misnamed variables inside previous ifdef OpenBSD blocks. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -19,10 +19,6 @@
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
|
||||
#ifdef __OpenBSD__
|
||||
#include <sys/param.h> /* pledge(2) */
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -66,13 +62,8 @@ main(int argc, char *argv[])
|
||||
if (lbgetprogname(argv[0]) == NULL)
|
||||
err_no_cleanup(stfu, errno, "could not set progname");
|
||||
|
||||
/* https://man.openbsd.org/pledge.2 */
|
||||
#if defined(__OpenBSD__) && defined(OpenBSD)
|
||||
#if (OpenBSD) >= 509
|
||||
if (pledge("stdio flock rpath wpath cpath", NULL) == -1)
|
||||
goto err_usage;
|
||||
#endif
|
||||
#endif
|
||||
/* https://man.openbsd.org/pledge.2 */
|
||||
xpledgex("stdio flock rpath wpath cpath", NULL);
|
||||
|
||||
while ((c =
|
||||
getopt(argc, argv, "qdp:")) != -1) {
|
||||
@@ -134,12 +125,7 @@ main(int argc, char *argv[])
|
||||
tmpdir, template) < 0)
|
||||
err_no_cleanup(stfu, errno, "%s", s);
|
||||
|
||||
#if defined(__OpenBSD__) && defined(OpenBSD)
|
||||
#if (OpenBSD) >= 509
|
||||
if (pledge("stdio", NULL) == -1)
|
||||
err_no_cleanup(stfu, errno, "pledge, exit");
|
||||
#endif
|
||||
#endif
|
||||
xpledgex("stdio", NULL);
|
||||
|
||||
if (s == NULL)
|
||||
err_no_cleanup(stfu, EFAULT, "bad string initialisation");
|
||||
|
||||
Reference in New Issue
Block a user