Marc Espie writes:
> Let's keep it setgid.
>
> It's rather simple to call a new function first thing in main,
> open the user scorefile in RDWR mode, then drop the setgid bit, and just
> lseek/write directly when we need to update the user's score.
Thanks, I've committed it.
I'd feel more comfortable with some pledge and unveil. ok for the below?
blob - a1bcdbdbc635bb599f3b8be595dea5096b46cf51
blob + c4f4b87b8097bb1c9cd54de3614710c9f2f228eb
--- games/xkobo/Makefile
+++ games/xkobo/Makefile
@@ -2,7 +2,7 @@ COMMENT = multi-way scrolling shoot'em up for X11, add
#'
DISTNAME = xkobo-1.11
-REVISION = 10
+REVISION = 11
CATEGORIES = games
SITES = ${SITE_XCONTRIB:=games/} \
@@ -19,16 +19,22 @@ MAINTAINER = Marc Espie <[email protected]>
# GPL
PERMIT_PACKAGE = Yes
-
+
+# uses pledge() and unveil()
WANTLIB = X11 Xau Xdmcp Xext c m xcb ${COMPILER_LIBCXX}
COMPILER = base-clang ports-gcc base-gcc
CONFIGURE_STYLE = imake
+MAKE_FLAGS = CDEBUGFLAGS="${CFLAGS}" \
+ CXXDEBUGFLAGS="${CXXFLAGS}"
+
ALL_TARGET = xkobo
NO_TEST = Yes
+DEBUG_PACKAGES = ${BUILD_PACKAGES}
+
post-install:
${INSTALL_MAN} ${WRKSRC}/xkobo.man ${PREFIX}/man/man1/xkobo.1
blob - b70c66d9ef3738cbbefe146df7c9dc6d00a8f301
blob + d2210d73eb80154e0782f8e62365ea568d543912
--- games/xkobo/patches/patch-xkobo_C
+++ games/xkobo/patches/patch-xkobo_C
@@ -18,7 +18,18 @@ Index: xkobo.C
{
signal_delivered = 1;
}
-@@ -149,6 +150,7 @@ int main(int argc, char *argv[])
+@@ -142,6 +143,10 @@ void put_score()
+
+ int main(int argc, char *argv[])
+ {
++ if (pledge("stdio rpath wpath cpath inet unix prot_exec id unveil", NULL)
== -1){
++ fprintf(stderr, "pledge\n");
++ return 1;
++ }
+ int sprite_policy = 1;
+ int cmap_policy = 1;
+ int wait_msec = WAIT_MSEC;
+@@ -149,6 +154,7 @@ int main(int argc, char *argv[])
struct sigaction sig_act;
int i;
@@ -26,7 +37,39 @@ Index: xkobo.C
scale_log2 = 0;
cheat_mode = 0;
for (i=1; i<argc; i++){
-@@ -228,6 +230,7 @@ int main(int argc, char *argv[])
+@@ -168,8 +174,13 @@ int main(int argc, char *argv[])
+ win::set_disp_string(argv[++i]);
+ else if (!strcmp("-wait", argv[i]))
+ wait_msec = atoi(argv[++i]);
+- else if (!strcmp("-hiscores", argv[i]))
++ else if (!strcmp("-hiscores", argv[i])){
++ if (pledge("stdio rpath", NULL) == -1){
++ fprintf(stderr, "pledge\n");
++ return 1;
++ }
+ put_score();
++ }
+ else put_usage();
+ }
+
+@@ -187,6 +198,16 @@ int main(int argc, char *argv[])
+ wbase.make(NULL, 0, 0,
+ MARGIN * 3 + ((WSIZE + MAP_SIZEX) << scale_log2),
+ MARGIN * 2 + (WSIZE << scale_log2), cmap_policy);
++
++ if (unveil("/var/games/xkobo.scores", "rwc") == -1){
++ fprintf(stderr, "unveil\n");
++ return 1;
++ }
++ if (unveil(NULL, NULL) == -1){
++ fprintf(stderr, "unveil\n");
++ return 1;
++ }
++
+ wchip.make(&wbase, MARGIN, MARGIN,
+ WSIZE << scale_log2, WSIZE << scale_log2,
+ (SCREEN_SIZEX + WSIZE) << scale_log2,
+@@ -228,6 +249,7 @@ int main(int argc, char *argv[])
rand_num.init();
manage.init();
@@ -34,3 +77,15 @@ Index: xkobo.C
memset(&sig_act, 0, sizeof(sig_act));
sig_act.sa_handler = sig_handle;
+@@ -237,6 +259,11 @@ int main(int argc, char *argv[])
+ value.it_value.tv_sec = 0;
+ value.it_value.tv_usec = wait_msec * 1000;
+ setitimer(ITIMER_REAL, &value, &ovalue);
++
++ if (pledge("stdio rpath wpath cpath", NULL) == -1){
++ fprintf(stderr, "pledge\n");
++ return 1;
++ }
+
+ for (;;){
+ if (wait_msec && (signal_delivered == 0)) pause();
blob - ecdb02e98b7eb8323096de4163a5d4e42bd1d0b9
blob + d654bad75d70f340d0b5aa0e5fc68f2844bee2b3
--- games/xkobo/pkg/PLIST
+++ games/xkobo/pkg/PLIST
@@ -1,7 +1,7 @@
@extraunexec rm -rf /var/games/xkobo.scores/*
@mode 2755
@group games
-bin/xkobo
+@bin bin/xkobo
@mode 575
@sample /var/games/xkobo.scores/
@mode