Here's a patch that also handles recover.

As for where to put the variable: I see no obvious reason to put it
close to main() vs. putting it close to the actual setgid code.

(plus this means not needing yet another patch)

Index: Makefile
===================================================================
RCS file: /build/data/openbsd/cvs/ports/games/nethack/5.0/Makefile,v
diff -u -p -r1.2 Makefile
--- Makefile    12 Jul 2026 22:42:45 -0000      1.2
+++ Makefile    15 Oct 2026 09:04:03 -0000
@@ -7,6 +7,7 @@ PKGNAME =       ${DISTNAME}
 CATEGORIES =   games
 SITES =                https://www.nethack.org/download/$V/
 DISTFILES =    nethack-${V:S/.//g}-src.tgz
+REVISION =     0
 
 HOMEPAGE =     http://nethack.org/
 
Index: patches/patch-src_files_c
===================================================================
RCS file: 
/build/data/openbsd/cvs/ports/games/nethack/5.0/patches/patch-src_files_c,v
diff -u -p -r1.1.1.1 patch-src_files_c
--- patches/patch-src_files_c   30 Jun 2026 14:59:13 -0000      1.1.1.1
+++ patches/patch-src_files_c   21 Oct 2026 06:41:17 -0000
@@ -1,7 +1,19 @@
 Index: src/files.c
 --- src/files.c.orig
 +++ src/files.c
-@@ -1691,8 +1691,10 @@ docompress_file(const char *filename, boolean uncomp)
+@@ -194,6 +194,11 @@ staticfn FILE *fopen_sym_file(void);
+ staticfn NHFILE *viable_nhfile(NHFILE *);
+ #endif /* !SFCTOOL */
+ 
++#ifdef __OpenBSD__
++#include <sys/stat.h>
++mode_t _permit_setuigid = S_ISGID;
++#endif
++
+ /* return a file's name without its path and optionally trailing 'type' */
+ const char *
+ nh_basename(const char *fname, boolean keep_suffix)
+@@ -1691,8 +1696,10 @@ docompress_file(const char *filename, boolean uncomp)
              redirect(filename, RDBMODE, stdin, uncomp);
              redirect(cfn, WRBMODE, stdout, uncomp);
          }
Index: patches/patch-util_recover_c
===================================================================
RCS file: patches/patch-util_recover_c
diff -N patches/patch-util_recover_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-util_recover_c        21 Oct 2026 06:41:17 -0000
@@ -0,0 +1,15 @@
+Index: util/recover.c
+--- util/recover.c.orig
++++ util/recover.c
+@@ -62,6 +62,11 @@ char *exepath(char *);
+ extern unsigned _stklen = STKSIZ;
+ #endif
+ 
++#ifdef __OpenBSD__
++#include <sys/stat.h>
++mode_t _permit_setugid = S_ISGID;
++#endif
++
+ /* SAVESIZE is defined in "fnamesiz.h" */
+ char savename[SAVESIZE]; /* holds relative path of save file from playground 
*/
+ 

Reply via email to