mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
@@ -22,6 +22,10 @@
|
|||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __OpenBSD__ /* for pledge */
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define items(x) (sizeof((x)) / sizeof((x)[0]))
|
#define items(x) (sizeof((x)) / sizeof((x)[0]))
|
||||||
|
|
||||||
/* system prototypes
|
/* system prototypes
|
||||||
@@ -369,6 +373,8 @@ void write_mac_part(size_t partnum);
|
|||||||
/* string functions
|
/* 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,
|
int slen(const char *scmp, size_t maxlen,
|
||||||
size_t *rval);
|
size_t *rval);
|
||||||
int scmp(const char *a, const char *b,
|
int scmp(const char *a, const char *b,
|
||||||
|
|||||||
@@ -321,15 +321,28 @@ lbgetprogname(char *argv0)
|
|||||||
return progname;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,30 +1,20 @@
|
|||||||
/* SPDX-License-Identifier: MIT
|
/* SPDX-License-Identifier: MIT ( >:3 )
|
||||||
* Copyright (c) 2026 Leah Rowe <leah@libreboot.org>
|
* Copyright (c) 2026 Leah Rowe <leah@libreboot.org> /| |\
|
||||||
*/
|
/ \*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h> /* (^.>) - are u lucky? */
|
||||||
#include "include/common.h"
|
#include "include/common.h" /* \| /= */
|
||||||
static int rigged(char **s);
|
static int rigged(char **s, int spew) { /* l \ */
|
||||||
|
|
||||||
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? */
|
|
||||||
{
|
|
||||||
size_t size[2] = { rsize(1 << 17), rsize(1 << 17) };
|
size_t size[2] = { rsize(1 << 17), rsize(1 << 17) };
|
||||||
|
spew &= size[1] = !(size[0] && size[0] == size[1] && size[0] <=1<<18 &&
|
||||||
return !(size[0] && size[0] == size[1] && size[0] <= 1 << 18 &&
|
|
||||||
s != NULL) || memcmp(*s = mkrbuf(size[0] << 1), *s + size[0],
|
s != NULL) || memcmp(*s = mkrbuf(size[0] << 1), *s + size[0],
|
||||||
size[0]);
|
size[0]);
|
||||||
}/* ( >:3 )
|
if (spew && !size[1]) printf("%s\n\n", *s);
|
||||||
/| |\ it could be you!
|
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! */
|
||||||
|
} /* /| |
|
||||||
|
/ \ */
|
||||||
|
|||||||
Reference in New Issue
Block a user