summaryrefslogtreecommitdiff
path: root/util/libreboot-utils
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-26 22:36:44 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-26 23:02:00 +0000
commita29a3ac6f6bdfc2823462450edd28aa6cbbc5a9c (patch)
tree6ff68942bd6f3df01f9d38096ccaafb8eb5b765a /util/libreboot-utils
parent1a09efbbbeda9caca912f4d07edc7b309c1dc6f4 (diff)
cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/libreboot-utils')
-rw-r--r--util/libreboot-utils/include/common.h6
-rw-r--r--util/libreboot-utils/lib/string.c35
-rw-r--r--util/libreboot-utils/lottery.c42
3 files changed, 46 insertions, 37 deletions
diff --git a/util/libreboot-utils/include/common.h b/util/libreboot-utils/include/common.h
index 7f063a8c..1bef0d50 100644
--- a/util/libreboot-utils/include/common.h
+++ b/util/libreboot-utils/include/common.h
@@ -22,6 +22,10 @@
#include <sys/syscall.h>
#endif
+#ifdef __OpenBSD__ /* for pledge */
+#include <unistd.h>
+#endif
+
#define items(x) (sizeof((x)) / sizeof((x)[0]))
/* system prototypes
@@ -369,6 +373,8 @@ void write_mac_part(size_t partnum);
/* string functions
*/
+int xunveilx(const char *path, const char *permissions);
+int xpledgex(const char *promises, const char *execpromises);
int slen(const char *scmp, size_t maxlen,
size_t *rval);
int scmp(const char *a, const char *b,
diff --git a/util/libreboot-utils/lib/string.c b/util/libreboot-utils/lib/string.c
index b639f0a4..c6e09752 100644
--- a/util/libreboot-utils/lib/string.c
+++ b/util/libreboot-utils/lib/string.c
@@ -321,15 +321,28 @@ lbgetprogname(char *argv0)
return progname;
}
+int
+xpledgex(const char *promises, const char *execpromises)
+{
+ int saved_errno = errno;
+ (void) promises, (void) execpromises, (void) saved_errno;
+#ifdef __OpenBSD__
+ if (pledge(promises, execpromises) == -1)
+ err_no_cleanup(0, errno, "pledge");
+#endif
+ errno = saved_errno;
+ return 0;
+}
-
-
-
-
-
-
-
-
-
-
-
+int
+xunveilx(const char *path, const char *permissions)
+{
+ int saved_errno = errno;
+ (void) path, (void) permissions, (void) saved_errno;
+#ifdef __OpenBSD__
+ if (pledge(promises, execpromises) == -1)
+ err_no_cleanup(0, errno, "pledge");
+#endif
+ errno = saved_errno;
+ return 0;
+}
diff --git a/util/libreboot-utils/lottery.c b/util/libreboot-utils/lottery.c
index 9f84d043..9e396d1d 100644
--- a/util/libreboot-utils/lottery.c
+++ b/util/libreboot-utils/lottery.c
@@ -1,30 +1,20 @@
-/* SPDX-License-Identifier: MIT
- * Copyright (c) 2026 Leah Rowe <leah@libreboot.org>
- */
+/* SPDX-License-Identifier: MIT ( >:3 )
+ * Copyright (c) 2026 Leah Rowe <leah@libreboot.org> /| |\
+ / \*/
#include <stdio.h>
-#include <string.h>
-#include "include/common.h"
-static int rigged(char **s);
-
-int
-main(int argc, char *argv[])
-{
-#ifdef __OpenBSD__
- if (pledge("stdio", NULL) == -1)
- err_no_cleanup(0, errno, "openbsd wins");
-#endif
- printf("%s\n", (argc = rigged(argv)) ? "You lose!" : "You win!");
- return argc;
-}
-
-static int
-rigged(char **s) /* are u lucky? */
-{
+#include <string.h> /* (^.>) - are u lucky? */
+#include "include/common.h" /* \| /= */
+static int rigged(char **s, int spew) { /* l \ */
size_t size[2] = { rsize(1 << 17), rsize(1 << 17) };
-
- return !(size[0] && size[0] == size[1] && size[0] <= 1 << 18 &&
+ spew &= size[1] = !(size[0] && size[0] == size[1] && size[0] <=1<<18 &&
s != NULL) || memcmp(*s = mkrbuf(size[0] << 1), *s + size[0],
size[0]);
-}/* ( >:3 )
- /| |\ it could be you!
- / \ */ \ No newline at end of file
+ if (spew && !size[1]) printf("%s\n\n", *s);
+ return size[1];
+} /* (^:3) - it could be you! */
+int main(int argc, char **argv) { /* /| |l */
+ xpledgex("stdio", NULL); /* / \ */
+ printf("%s\n", (argc = rigged(argv, argc > 1))?"You lose!":"You win!");
+ return argc; /* (^.^)/ - come again soon! */
+} /* /| |
+ / \ */