On Wed, Nov 04, 2026 at 02:40:12AM -0700, Anthony J. Bentley wrote:
> Hi,
>
> $ xkobo
> /usr/local/bin/xkobo: not supposed to be setgid, aborting
> Abort trap
>
> One way to get xkobo running again would be to add the _permit_setugid
> symbol. On the other hand, there's this approach: switch to writing a
> scorefile at ./xkobo-scores instead of /var/games/xkobo.scores/$uid, so
> setgid is no longer necessary.
>
> This means there is no longer a systemwide shared scorefile. I think
> that for a number of reasons, that's a thing of the past.
>
> The code in the patch is not great, but I would rather not rewrite the
> whole program...
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.
Index: Makefile
===================================================================
RCS file: /vide/cvs/ports/games/xkobo/Makefile,v
diff -u -p -r1.40 Makefile
--- Makefile 26 Sep 2023 09:41:44 -0000 1.40
+++ Makefile 5 Nov 2026 10:47:03 -0000
@@ -2,7 +2,7 @@ COMMENT = multi-way scrolling shoot'em u
#'
DISTNAME = xkobo-1.11
-REVISION = 9
+REVISION = 10
CATEGORIES = games
SITES = ${SITE_XCONTRIB:=games/} \
Index: patches/patch-score_C
===================================================================
RCS file: patches/patch-score_C
diff -N patches/patch-score_C
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-score_C 5 Nov 2026 10:46:56 -0000
@@ -0,0 +1,81 @@
+Index: score.C
+--- score.C.orig
++++ score.C
+@@ -29,6 +29,12 @@ extern "C"{
+ #include <sys/stat.h>
+ #include <sys/types.h>
+ #include <pwd.h>
++#include <sys/stat.h>
++#include <fcntl.h>
++#include <string.h>
++#include <errno.h>
++/* OpenBSD: set[ug]id binary MUST say so in this var */
++mode_t _permit_setugid = S_ISGID;
+ }
+ #include "xkobo.h"
+ #include "score.h"
+@@ -37,6 +43,7 @@ extern "C"{
+ int _scorefile::highscore = 0;
+ char _scorefile::save_path[1024];
+ char _scorefile::login_name[64];
++int _scorefile::fd = -1;
+
+ class uint_little_endian {
+ unsigned char byte[4];
+@@ -74,22 +81,29 @@ int s_table_cmp(s_table *a, s_table *b)
+ return 0;
+ }
+
+-void _scorefile::init(int *highscorep, int *stagep)
++
++void _scorefile::usesetgid()
+ {
+- s_table tbl;
+- tbl.score = 0;
+- tbl.scene = 0;
+- strcpy(tbl.name, "foo");
+- int i;
+ struct passwd *pw = getpwuid(getuid());
+ if (pw == NULL){
+ fprintf(stderr, "xkobo : getpwuid() failed\n");
+- sprintf(login_name, "%u", getuid());
++ snprintf(login_name, sizeof login_name, "%u", getuid());
+ }
+ else {
+- strcpy(login_name, pw->pw_name);
++ strlcpy(login_name, pw->pw_name, sizeof login_name);
+ }
+- sprintf(save_path, "%s/%u", XKOBO_SCORE_DIR, getuid());
++ snprintf(save_path, sizeof save_path, "%s/%u", XKOBO_SCORE_DIR, getuid());
++ fd = open(save_path, O_CREAT|O_RDWR, 0644);
++ setgid(getgid());
++}
++
++void _scorefile::init(int *highscorep, int *stagep)
++{
++ s_table tbl;
++ tbl.score = 0;
++ tbl.scene = 0;
++ strcpy(tbl.name, "foo");
++ int i;
+ if ((i=load_block(save_path, &tbl, sizeof(tbl))) < 0){
+ fprintf(stderr, "xkobo : (warning) can't read the score-file\n");
+ }
+@@ -117,10 +131,13 @@ void _scorefile::record(int new_score, int stage)
+ write = 1;
+ }
+ if (write){
+- if (save_block(save_path, &tbl, sizeof(tbl)) < 0){
+- fprintf(stderr, "xkobo : (warning) "
+- "can't update the score-file\n");
+- }
++ if (lseek(fd, 0, SEEK_SET) == -1)
++ fprintf(stderr, "SEEK_SET failure %s\n", strerror(errno));
++ if (::write(fd, &tbl, sizeof(tbl)) != sizeof(tbl)) {
++ fprintf(stderr, "xkobo: (warning) "
++ "can't update the score-file %s\n",
++ strerror(errno));
++ }
+ }
+ _scorefile::show_high_scores(0);
+ }
Index: patches/patch-score_h
===================================================================
RCS file: patches/patch-score_h
diff -N patches/patch-score_h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-score_h 5 Nov 2026 10:22:48 -0000
@@ -0,0 +1,16 @@
+Index: score.h
+--- score.h.orig
++++ score.h
+@@ -32,10 +32,12 @@ class _scorefile{
+ static int highscore;
+ static char save_path[1024];
+ static char login_name[64];
++ static int fd;
+ public:
+ static void init(int *highscorep, int *stagep);
+ static void record(int new_score, int stage);
+ static void show_high_scores(int to_stdout);
++ static void usesetgid();
+ };
+
+ extern _scorefile scorefile;
Index: patches/patch-xkobo_C
===================================================================
RCS file: /vide/cvs/ports/games/xkobo/patches/patch-xkobo_C,v
diff -u -p -r1.2 patch-xkobo_C
--- patches/patch-xkobo_C 11 Mar 2022 19:05:19 -0000 1.2
+++ patches/patch-xkobo_C 5 Nov 2026 10:22:48 -0000
@@ -1,5 +1,6 @@
---- xkobo.C.orig Fri Jun 14 19:27:27 1996
-+++ xkobo.C Sun Oct 6 01:00:38 2002
+Index: xkobo.C
+--- xkobo.C.orig
++++ xkobo.C
@@ -33,6 +33,7 @@ extern "C"{
#include "xkobo.h"
#include "config.h"
@@ -17,7 +18,15 @@
{
signal_delivered = 1;
}
-@@ -228,6 +229,7 @@ int main(int argc, char *argv[])
+@@ -149,6 +150,7 @@ int main(int argc, char *argv[])
+ struct sigaction sig_act;
+ int i;
+
++ scorefile.usesetgid();
+ scale_log2 = 0;
+ cheat_mode = 0;
+ for (i=1; i<argc; i++){
+@@ -228,6 +230,7 @@ int main(int argc, char *argv[])
rand_num.init();
manage.init();