From 715f2cdf2f880b64cb453d353574a7e45de6e1b5 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Mon, 31 Dec 2018 22:51:29 -0500 Subject: Use capsicum on FreeBSD --- play.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'play.c') diff --git a/play.c b/play.c index 23011f6..3814d0f 100644 --- a/play.c +++ b/play.c @@ -25,6 +25,10 @@ #include #include +#ifdef __FreeBSD__ +#include +#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); -- cgit 1.4.1