diff options
author | June McEnroe <june@causal.agency> | 2018-12-31 22:51:29 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2018-12-31 22:51:29 -0500 |
commit | 715f2cdf2f880b64cb453d353574a7e45de6e1b5 (patch) | |
tree | 3954deba2a28f992b857a66a443c76ea2b3cc419 | |
parent | Handle ERR from getch (diff) | |
download | play-715f2cdf2f880b64cb453d353574a7e45de6e1b5.tar.gz play-715f2cdf2f880b64cb453d353574a7e45de6e1b5.zip |
Use capsicum on FreeBSD
Diffstat (limited to '')
-rw-r--r-- | play.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/play.c b/play.c index 23011f6..3814d0f 100644 --- a/play.c +++ b/play.c @@ -25,6 +25,10 @@ #include <sysexits.h> #include <time.h> +#ifdef __FreeBSD__ +#include <sys/capsicum.h> +#endif + typedef unsigned uint; uint play2048(void); @@ -152,10 +156,25 @@ static void draw(size_t new) { } int main(void) { - struct Score new = { .date = time(NULL) }; - new.score = play2048(); - + curse(); FILE *file = scoresOpen("2048.scores"); + +#ifdef __FreeBSD__ + int error = cap_enter(); + if (error) err(EX_OSERR, "cap_enter"); + + cap_rights_t rights; + cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_SEEK, CAP_FLOCK); + + error = cap_rights_limit(fileno(file), &rights); + if (error) err(EX_OSERR, "cap_rights_limit"); +#endif + + struct Score new = { + .date = time(NULL), + .score = play2048(), + }; + scoresRead(file); size_t index = scoresInsert(new); |