summary refs log tree commit diff homepage
path: root/play.c
diff options
context:
space:
mode:
Diffstat (limited to 'play.c')
-rw-r--r--play.c25
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);