Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] nethack: fix SYSCF_FILE location
@ 2020-12-08 17:54 ashpooljh
  2020-12-08 18:51 ` [PR PATCH] [Updated] " ashpooljh
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: ashpooljh @ 2020-12-08 17:54 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 832 bytes --]

There is a new pull request by ashpooljh against master on the void-packages repository

https://github.com/ashpooljh/void-packages nethack
https://github.com/void-linux/void-packages/pull/27036

nethack: fix SYSCF_FILE location
I wasn't able to enter the wizard mode, even as root, e.g. `sudo nethack -D -u wizard` just printed 
```
Entering explore/discovery mode instead
```
Then I found out that `SYSCF_FILE` in the template was pointing to the directory `/usr/lib/nethack` instead of the file itself `/usr/lib/nethack/sysconf`, and used `gdb` to verify that this had lead to `src/files.c:parse_conf_file` silently failing. Updating the value fixed the issue, and now the sysconf file is read and I'm able to access the wizard mode.

A patch file from https://github.com/void-linux/void-packages/pull/27036.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-nethack-27036.patch --]
[-- Type: text/x-diff, Size: 993 bytes --]

From b11df05a9057c1a8c7b1b10591ac13b11170c087 Mon Sep 17 00:00:00 2001
From: Artem Zhurikhin <ashpool@xecut.net>
Date: Tue, 8 Dec 2020 20:45:29 +0300
Subject: [PATCH] nethack: fix SYSCF_FILE location

---
 srcpkgs/nethack/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nethack/template b/srcpkgs/nethack/template
index b7ec4c30753..9a982e41ce6 100644
--- a/srcpkgs/nethack/template
+++ b/srcpkgs/nethack/template
@@ -1,7 +1,7 @@
 # Template file for 'nethack'
 pkgname=nethack
 version=3.6.6
-revision=1
+revision=2
 make_dirs="/var/games/nethack/save 0775 nethack nethack"
 hostmakedepends="ncurses-devel flex"
 depends="gzip"
@@ -29,7 +29,7 @@ do_build() {
 		CC="$CC" LINK="$CC" LFLAGS="$LDFLAGS" \
 		LEX=flex WINTTYLIB=-lncurses \
 		CFLAGS="$CFLAGS -DLINUX -DTIMED_DELAY -DDLB \
-			-DSYSCF -DSYSCF_FILE='\"/usr/lib/nethack\"' \
+			-DSYSCF -DSYSCF_FILE='\"/usr/lib/nethack/sysconf\"' \
 			-DHACKDIR='\"/var/games/nethack\"' -I../include"
 }
 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PR PATCH] [Updated] nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
@ 2020-12-08 18:51 ` ashpooljh
  2020-12-08 18:52 ` ashpooljh
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: ashpooljh @ 2020-12-08 18:51 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 837 bytes --]

There is an updated pull request by ashpooljh against master on the void-packages repository

https://github.com/ashpooljh/void-packages nethack
https://github.com/void-linux/void-packages/pull/27036

nethack: fix SYSCF_FILE location
I wasn't able to enter the wizard mode, even as root, e.g. `sudo nethack -D -u wizard` just printed 
```
Entering explore/discovery mode instead
```
Then I found out that `SYSCF_FILE` in the template was pointing to the directory `/usr/lib/nethack` instead of the file itself `/usr/lib/nethack/sysconf`, and used `gdb` to verify that this had lead to `src/files.c:parse_conf_file` silently failing. Updating the value fixed the issue, and now the sysconf file is read and I'm able to access the wizard mode.

A patch file from https://github.com/void-linux/void-packages/pull/27036.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-nethack-27036.patch --]
[-- Type: text/x-diff, Size: 1004 bytes --]

From 7e8b9db594b1c1833e80f430933a950d22ac5938 Mon Sep 17 00:00:00 2001
From: Artem Zhurikhin <ashpool@xecut.net>
Date: Tue, 8 Dec 2020 20:45:29 +0300
Subject: [PATCH] nethack: fix SYSCF_FILE location, fix xlint

---
 srcpkgs/nethack/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/nethack/template b/srcpkgs/nethack/template
index b7ec4c30753..9a982e41ce6 100644
--- a/srcpkgs/nethack/template
+++ b/srcpkgs/nethack/template
@@ -1,7 +1,7 @@
 # Template file for 'nethack'
 pkgname=nethack
 version=3.6.6
-revision=1
+revision=2
 make_dirs="/var/games/nethack/save 0775 nethack nethack"
 hostmakedepends="ncurses-devel flex"
 depends="gzip"
@@ -29,7 +29,7 @@ do_build() {
 		CC="$CC" LINK="$CC" LFLAGS="$LDFLAGS" \
 		LEX=flex WINTTYLIB=-lncurses \
 		CFLAGS="$CFLAGS -DLINUX -DTIMED_DELAY -DDLB \
-			-DSYSCF -DSYSCF_FILE='\"/usr/lib/nethack\"' \
+			-DSYSCF -DSYSCF_FILE='\"/usr/lib/nethack/sysconf\"' \
 			-DHACKDIR='\"/var/games/nethack\"' -I../include"
 }
 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PR PATCH] [Updated] nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
  2020-12-08 18:51 ` [PR PATCH] [Updated] " ashpooljh
@ 2020-12-08 18:52 ` ashpooljh
  2020-12-08 19:08 ` ashpooljh
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: ashpooljh @ 2020-12-08 18:52 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 837 bytes --]

There is an updated pull request by ashpooljh against master on the void-packages repository

https://github.com/ashpooljh/void-packages nethack
https://github.com/void-linux/void-packages/pull/27036

nethack: fix SYSCF_FILE location
I wasn't able to enter the wizard mode, even as root, e.g. `sudo nethack -D -u wizard` just printed 
```
Entering explore/discovery mode instead
```
Then I found out that `SYSCF_FILE` in the template was pointing to the directory `/usr/lib/nethack` instead of the file itself `/usr/lib/nethack/sysconf`, and used `gdb` to verify that this had lead to `src/files.c:parse_conf_file` silently failing. Updating the value fixed the issue, and now the sysconf file is read and I'm able to access the wizard mode.

A patch file from https://github.com/void-linux/void-packages/pull/27036.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-nethack-27036.patch --]
[-- Type: text/x-diff, Size: 1377 bytes --]

From 0e42d6d17607a60111023620901e8d92a15a2269 Mon Sep 17 00:00:00 2001
From: Artem Zhurikhin <ashpool@xecut.net>
Date: Tue, 8 Dec 2020 20:45:29 +0300
Subject: [PATCH] nethack: fix SYSCF_FILE location, fix xlint

---
 srcpkgs/nethack/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/nethack/template b/srcpkgs/nethack/template
index b7ec4c30753..ad86ceb288e 100644
--- a/srcpkgs/nethack/template
+++ b/srcpkgs/nethack/template
@@ -1,7 +1,8 @@
 # Template file for 'nethack'
 pkgname=nethack
 version=3.6.6
-revision=1
+revision=2
+wrksrc="NetHack-NetHack-${version}_Released"
 make_dirs="/var/games/nethack/save 0775 nethack nethack"
 hostmakedepends="ncurses-devel flex"
 depends="gzip"
@@ -13,7 +14,6 @@ distfiles="https://www.nethack.org/download/${version}/nethack-${version//./}-sr
 checksum=cfde0c3ab6dd7c22ae82e1e5a59ab80152304eb23fb06e3129439271e5643ed2
 nocross=yes
 system_accounts="$pkgname"
-wrksrc="NetHack-NetHack-${version}_Released"
 
 post_extract() {
 	sed -i	-e '/COMPRESS/s/compress/gzip/g' \
@@ -29,7 +29,7 @@ do_build() {
 		CC="$CC" LINK="$CC" LFLAGS="$LDFLAGS" \
 		LEX=flex WINTTYLIB=-lncurses \
 		CFLAGS="$CFLAGS -DLINUX -DTIMED_DELAY -DDLB \
-			-DSYSCF -DSYSCF_FILE='\"/usr/lib/nethack\"' \
+			-DSYSCF -DSYSCF_FILE='\"/usr/lib/nethack/sysconf\"' \
 			-DHACKDIR='\"/var/games/nethack\"' -I../include"
 }
 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
  2020-12-08 18:51 ` [PR PATCH] [Updated] " ashpooljh
  2020-12-08 18:52 ` ashpooljh
@ 2020-12-08 19:08 ` ashpooljh
  2020-12-08 19:10 ` ashpooljh
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: ashpooljh @ 2020-12-08 19:08 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 301 bytes --]

New comment by ashpooljh on void-packages repository

https://github.com/void-linux/void-packages/pull/27036#issuecomment-740869865

Comment:
I had been thinking about moving the sysconf file to `/etc` as well. It's clearly intended to be edited by root, and we do move it to another location anyway.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (2 preceding siblings ...)
  2020-12-08 19:08 ` ashpooljh
@ 2020-12-08 19:10 ` ashpooljh
  2020-12-08 19:13 ` leahneukirchen
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: ashpooljh @ 2020-12-08 19:10 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 255 bytes --]

New comment by ashpooljh on void-packages repository

https://github.com/void-linux/void-packages/pull/27036#issuecomment-740869865

Comment:
I had been thinking about moving the sysconf file to `/etc` as well. It's clearly intended to be edited by root.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (3 preceding siblings ...)
  2020-12-08 19:10 ` ashpooljh
@ 2020-12-08 19:13 ` leahneukirchen
  2020-12-08 19:16 ` leahneukirchen
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: leahneukirchen @ 2020-12-08 19:13 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 191 bytes --]

New comment by leahneukirchen on void-packages repository

https://github.com/void-linux/void-packages/pull/27036#issuecomment-740877832

Comment:
Fine by me, then add to conf_files as well.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (4 preceding siblings ...)
  2020-12-08 19:13 ` leahneukirchen
@ 2020-12-08 19:16 ` leahneukirchen
  2020-12-10  9:55 ` [PR PATCH] [Updated] " ashpooljh
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: leahneukirchen @ 2020-12-08 19:16 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 198 bytes --]

New comment by leahneukirchen on void-packages repository

https://github.com/void-linux/void-packages/pull/27036#issuecomment-740883224

Comment:
 I packaged this in 2015, feel free to improve. :)

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PR PATCH] [Updated] nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (5 preceding siblings ...)
  2020-12-08 19:16 ` leahneukirchen
@ 2020-12-10  9:55 ` ashpooljh
  2020-12-10 10:02 ` ashpooljh
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: ashpooljh @ 2020-12-10  9:55 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 909 bytes --]

There is an updated pull request by ashpooljh against master on the void-packages repository

https://github.com/ashpooljh/void-packages nethack
https://github.com/void-linux/void-packages/pull/27036

nethack: fix SYSCF_FILE location
I wasn't able to enter the wizard mode, not even as root, e.g. `sudo nethack -D -u wizard` just printed 
```
Entering explore/discovery mode instead
```
Then I found out that `SYSCF_FILE` in the template was pointing to the directory `/usr/lib/nethack` instead of the file itself `/usr/lib/nethack/sysconf`, and used `gdb` to verify that this had lead to `src/files.c:parse_conf_file` silently failing (parsing nothing) and `sysopt.wizards` ending up empty. Updating the `SYSCF_FILE` value fixed the issue, and now the sysconf file is read and I'm able to access the wizard mode.

A patch file from https://github.com/void-linux/void-packages/pull/27036.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-nethack-27036.patch --]
[-- Type: text/x-diff, Size: 4327 bytes --]

From 939df8c698bce83e38b90406b31619515f7ec9eb Mon Sep 17 00:00:00 2001
From: Artem Zhurikhin <ashpool@xecut.net>
Date: Tue, 8 Dec 2020 20:45:29 +0300
Subject: [PATCH] nethack: fix SYSCF_FILE, misc. improvements

- fix xlint
- move *-devel depends to makedepends
- don't override CFLAGS in template, patch
  sys/unix/hints/linux instead
- remove post_extract(), since this is already done
  in sys/unix/hints/linux
- move /usr/lib/nethack/sysconf to /etc/nethack/sysconf,
  add it to conf_files
---
 srcpkgs/nethack/INSTALL                     |  1 +
 srcpkgs/nethack/patches/1-linux-hints.patch | 19 +++++++++++++++++
 srcpkgs/nethack/template                    | 23 +++++++++------------
 3 files changed, 30 insertions(+), 13 deletions(-)
 create mode 100644 srcpkgs/nethack/patches/1-linux-hints.patch

diff --git a/srcpkgs/nethack/INSTALL b/srcpkgs/nethack/INSTALL
index c1b32c35262..78fe24f15ad 100644
--- a/srcpkgs/nethack/INSTALL
+++ b/srcpkgs/nethack/INSTALL
@@ -2,6 +2,7 @@ case "${ACTION}" in
 post)
 	chown nethack:nethack usr/lib/nethack/nethack
 	chmod 02755 usr/lib/nethack/nethack
+	chmod 0644 etc/nethack/sysconf
 	touch var/games/nethack/logfile var/games/nethack/perm var/games/nethack/record var/games/nethack/xlogfile
 	chown nethack:nethack var/games/nethack var/games/nethack/*
 	chmod 0775 var/games/nethack
diff --git a/srcpkgs/nethack/patches/1-linux-hints.patch b/srcpkgs/nethack/patches/1-linux-hints.patch
new file mode 100644
index 00000000000..e6b5e499e42
--- /dev/null
+++ b/srcpkgs/nethack/patches/1-linux-hints.patch
@@ -0,0 +1,19 @@
+Undefining SECURE is needed so that the nethack binary does not
+drop privileges when run with the SUID bit.
+
+We move /usr/lib/nethack/sysconf to /etc/nethack/sysconf since
+this file is intended to be editable by root.
+
+diff --git sys/unix/hints/linux sys/unix/hints/linux
+index 8629150..9a4d722 100644
+--- sys/unix/hints/linux
++++ sys/unix/hints/linux
+@@ -23,7 +23,7 @@ POSTINSTALL=cp -n sys/unix/sysconf $(INSTDIR)/sysconf; $(CHOWN) $(GAMEUID) $(INS
+ CFLAGS=-g -O -I../include -DNOTPARMDECL
+ CFLAGS+=-DDLB
+ CFLAGS+=-DCOMPRESS=\"/bin/gzip\" -DCOMPRESS_EXTENSION=\".gz\"
+-CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE
++CFLAGS+=-DSYSCF -DSYSCF_FILE=\"/etc/nethack/sysconf\"
+ CFLAGS+=-DTIMED_DELAY
+ CFLAGS+=-DHACKDIR=\"$(HACKDIR)\"
+ CFLAGS+=-DDUMPLOG
diff --git a/srcpkgs/nethack/template b/srcpkgs/nethack/template
index b7ec4c30753..1294e52c48f 100644
--- a/srcpkgs/nethack/template
+++ b/srcpkgs/nethack/template
@@ -1,9 +1,12 @@
 # Template file for 'nethack'
 pkgname=nethack
 version=3.6.6
-revision=1
+revision=2
+wrksrc="NetHack-NetHack-${version}_Released"
+conf_files="/etc/nethack/sysconf"
 make_dirs="/var/games/nethack/save 0775 nethack nethack"
-hostmakedepends="ncurses-devel flex"
+hostmakedepends="flex"
+makedepends="ncurses-devel ncurses-libtinfo-devel"
 depends="gzip"
 short_desc="Exploring The Mazes of Menace"
 maintainer="Leah Neukirchen <leah@vuxu.org>"
@@ -13,12 +16,6 @@ distfiles="https://www.nethack.org/download/${version}/nethack-${version//./}-sr
 checksum=cfde0c3ab6dd7c22ae82e1e5a59ab80152304eb23fb06e3129439271e5643ed2
 nocross=yes
 system_accounts="$pkgname"
-wrksrc="NetHack-NetHack-${version}_Released"
-
-post_extract() {
-	sed -i	-e '/COMPRESS/s/compress/gzip/g' \
-		-e '/COMPRESS_EXTENSION/s/\.Z/.gz/g' include/config.h
-}
 
 do_configure() {
 	sh sys/unix/setup.sh sys/unix/hints/linux
@@ -26,16 +23,15 @@ do_configure() {
 
 do_build() {
 	make all dungeon \
-		CC="$CC" LINK="$CC" LFLAGS="$LDFLAGS" \
-		LEX=flex WINTTYLIB=-lncurses \
-		CFLAGS="$CFLAGS -DLINUX -DTIMED_DELAY -DDLB \
-			-DSYSCF -DSYSCF_FILE='\"/usr/lib/nethack\"' \
-			-DHACKDIR='\"/var/games/nethack\"' -I../include"
+		CC="$CC" LINK="$CC" LFLAGS="$LDFLAGS" LEX=flex \
+		HACKDIR="/usr/lib/nethack"
 }
 
 do_install() {
 	vmkdir usr/share/man/man6
 	vmkdir var/games
+	vmkdir etc/nethack
+
 	make install manpages \
 		PREFIX=$DESTDIR \
 		SHELLDIR=$DESTDIR/usr/bin \
@@ -51,6 +47,7 @@ do_install() {
 
 	mv $DESTDIR/usr/lib/nethack/nhdat $DESTDIR/var/games/nethack
 	mv $DESTDIR/usr/lib/nethack/symbols $DESTDIR/var/games/nethack
+	mv $DESTDIR/usr/lib/nethack/sysconf $DESTDIR/etc/nethack
 	rm $DESTDIR/var/games/nethack/{logfile,perm,record,xlogfile}
 
 	sed -i	-e 's,^HACKDIR=.*,HACKDIR=/var/games/nethack,' \

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (6 preceding siblings ...)
  2020-12-10  9:55 ` [PR PATCH] [Updated] " ashpooljh
@ 2020-12-10 10:02 ` ashpooljh
  2020-12-10 10:04 ` ashpooljh
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: ashpooljh @ 2020-12-10 10:02 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 219 bytes --]

New comment by ashpooljh on void-packages repository

https://github.com/void-linux/void-packages/pull/27036#issuecomment-742416888

Comment:
I wonder if we should further patch the hints file to respect `XBPS_CFLAGS`.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (7 preceding siblings ...)
  2020-12-10 10:02 ` ashpooljh
@ 2020-12-10 10:04 ` ashpooljh
  2020-12-11 15:10 ` [PR REVIEW] " ericonr
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: ashpooljh @ 2020-12-10 10:04 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 231 bytes --]

New comment by ashpooljh on void-packages repository

https://github.com/void-linux/void-packages/pull/27036#issuecomment-742416888

Comment:
I wonder if we should further patch the hints file with `vsed` to respect `XBPS_CFLAGS`.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PR REVIEW] nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (8 preceding siblings ...)
  2020-12-10 10:04 ` ashpooljh
@ 2020-12-11 15:10 ` ericonr
  2020-12-11 16:05 ` ashpooljh
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: ericonr @ 2020-12-11 15:10 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 391 bytes --]

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/27036#discussion_r541015220

Comment:
I don't understand exactly what you mean by this. Why do you want it to not drop privileges when run with SUID? (Is it installed as SUID?)

For a change like this, I think it's important to explain why you're making it, not only what it does.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PR REVIEW] nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (9 preceding siblings ...)
  2020-12-11 15:10 ` [PR REVIEW] " ericonr
@ 2020-12-11 16:05 ` ashpooljh
  2020-12-11 16:06 ` ashpooljh
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: ashpooljh @ 2020-12-11 16:05 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 777 bytes --]

New review comment by ashpooljh on void-packages repository

https://github.com/void-linux/void-packages/pull/27036#discussion_r541054340

Comment:
Yes, it took me a while to find and understand why this is needed. I will try to explain this in a separate message, but for now let me just point out that by applying this patch we are not actually _changing_ anything, but maintaining the previous behavior. 

Revision 3.6.6_1 of the package does not define `SECURE`, in fact, it overrides all `CFLAGS` set in `sys/unix/hints/linux` and re-defines only a subset of them as an argument to `make all`. When moving away from this approach (and thus applying all the `CFLAGS` from the hints file) I discovered that defining `SECURE` in our setup would break the package entirely.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PR REVIEW] nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (10 preceding siblings ...)
  2020-12-11 16:05 ` ashpooljh
@ 2020-12-11 16:06 ` ashpooljh
  2020-12-11 16:16 ` ericonr
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: ashpooljh @ 2020-12-11 16:06 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 804 bytes --]

New review comment by ashpooljh on void-packages repository

https://github.com/void-linux/void-packages/pull/27036#discussion_r541054340

Comment:
Yes, it took me a while to find and understand why this is needed. I will try to explain this in a separate message, but for now let me just point out that by applying this patch we are not actually _changing_ anything, but maintaining the previous behavior. 

Revision 3.6.6_1 of the package does not define `SECURE`, in fact, it overrides all `CFLAGS` set in `sys/unix/hints/linux` and re-defines only a subset of them as an argument to `make all`, and `SECURE` is not there. When moving away from this approach (and thus applying all the `CFLAGS` from the hints file) I discovered that defining `SECURE` in our setup would break the package entirely.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PR REVIEW] nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (11 preceding siblings ...)
  2020-12-11 16:06 ` ashpooljh
@ 2020-12-11 16:16 ` ericonr
  2020-12-11 23:26 ` [PR PATCH] [Updated] " ashpooljh
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: ericonr @ 2020-12-11 16:16 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 250 bytes --]

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/27036#discussion_r541061400

Comment:
Ah! Indeed, I had forgotten that we completely overrode the CFLAGS. Thanks for reminding me about it :)

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PR PATCH] [Updated] nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (12 preceding siblings ...)
  2020-12-11 16:16 ` ericonr
@ 2020-12-11 23:26 ` ashpooljh
  2020-12-11 23:40 ` ashpooljh
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: ashpooljh @ 2020-12-11 23:26 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 909 bytes --]

There is an updated pull request by ashpooljh against master on the void-packages repository

https://github.com/ashpooljh/void-packages nethack
https://github.com/void-linux/void-packages/pull/27036

nethack: fix SYSCF_FILE location
I wasn't able to enter the wizard mode, not even as root, e.g. `sudo nethack -D -u wizard` just printed 
```
Entering explore/discovery mode instead
```
Then I found out that `SYSCF_FILE` in the template was pointing to the directory `/usr/lib/nethack` instead of the file itself `/usr/lib/nethack/sysconf`, and used `gdb` to verify that this had lead to `src/files.c:parse_conf_file` silently failing (parsing nothing) and `sysopt.wizards` ending up empty. Updating the `SYSCF_FILE` value fixed the issue, and now the sysconf file is read and I'm able to access the wizard mode.

A patch file from https://github.com/void-linux/void-packages/pull/27036.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-nethack-27036.patch --]
[-- Type: text/x-diff, Size: 4223 bytes --]

From 5e2aeaf109893de40c007cf19a9b6b403f6631a0 Mon Sep 17 00:00:00 2001
From: Artem Zhurikhin <ashpool@xecut.net>
Date: Tue, 8 Dec 2020 20:45:29 +0300
Subject: [PATCH] nethack: fix SYSCF_FILE, misc. improvements

- fix xlint
- move *-devel depends to makedepends
- don't override CFLAGS in template, patch
  sys/unix/hints/linux instead
- remove post_extract(), since this is already done
  in sys/unix/hints/linux
- move /usr/lib/nethack/sysconf to /etc/nethack/sysconf,
  add it to conf_files
---
 srcpkgs/nethack/INSTALL                     |  1 +
 srcpkgs/nethack/patches/1-linux-hints.patch | 16 ++++++++++++++
 srcpkgs/nethack/template                    | 23 +++++++++------------
 3 files changed, 27 insertions(+), 13 deletions(-)
 create mode 100644 srcpkgs/nethack/patches/1-linux-hints.patch

diff --git a/srcpkgs/nethack/INSTALL b/srcpkgs/nethack/INSTALL
index c1b32c35262..78fe24f15ad 100644
--- a/srcpkgs/nethack/INSTALL
+++ b/srcpkgs/nethack/INSTALL
@@ -2,6 +2,7 @@ case "${ACTION}" in
 post)
 	chown nethack:nethack usr/lib/nethack/nethack
 	chmod 02755 usr/lib/nethack/nethack
+	chmod 0644 etc/nethack/sysconf
 	touch var/games/nethack/logfile var/games/nethack/perm var/games/nethack/record var/games/nethack/xlogfile
 	chown nethack:nethack var/games/nethack var/games/nethack/*
 	chmod 0775 var/games/nethack
diff --git a/srcpkgs/nethack/patches/1-linux-hints.patch b/srcpkgs/nethack/patches/1-linux-hints.patch
new file mode 100644
index 00000000000..caaef540295
--- /dev/null
+++ b/srcpkgs/nethack/patches/1-linux-hints.patch
@@ -0,0 +1,16 @@
+We move /usr/lib/nethack/sysconf to /etc/nethack/sysconf since
+this file is intended to be editable by root.
+
+diff --git sys/unix/hints/linux sys/unix/hints/linux
+index 8629150..9a4d722 100644
+--- sys/unix/hints/linux
++++ sys/unix/hints/linux
+@@ -23,7 +23,7 @@ POSTINSTALL=cp -n sys/unix/sysconf $(INSTDIR)/sysconf; $(CHOWN) $(GAMEUID) $(INS
+ CFLAGS=-g -O -I../include -DNOTPARMDECL
+ CFLAGS+=-DDLB
+ CFLAGS+=-DCOMPRESS=\"/bin/gzip\" -DCOMPRESS_EXTENSION=\".gz\"
+-CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE
++CFLAGS+=-DSYSCF -DSYSCF_FILE=\"/etc/nethack/sysconf\" -DSECURE
+ CFLAGS+=-DTIMED_DELAY
+ CFLAGS+=-DHACKDIR=\"$(HACKDIR)\"
+ CFLAGS+=-DDUMPLOG
diff --git a/srcpkgs/nethack/template b/srcpkgs/nethack/template
index b7ec4c30753..e39eafb0b5c 100644
--- a/srcpkgs/nethack/template
+++ b/srcpkgs/nethack/template
@@ -1,9 +1,12 @@
 # Template file for 'nethack'
 pkgname=nethack
 version=3.6.6
-revision=1
+revision=2
+wrksrc="NetHack-NetHack-${version}_Released"
+conf_files="/etc/nethack/sysconf"
 make_dirs="/var/games/nethack/save 0775 nethack nethack"
-hostmakedepends="ncurses-devel flex"
+hostmakedepends="flex"
+makedepends="ncurses-devel ncurses-libtinfo-devel"
 depends="gzip"
 short_desc="Exploring The Mazes of Menace"
 maintainer="Leah Neukirchen <leah@vuxu.org>"
@@ -13,12 +16,6 @@ distfiles="https://www.nethack.org/download/${version}/nethack-${version//./}-sr
 checksum=cfde0c3ab6dd7c22ae82e1e5a59ab80152304eb23fb06e3129439271e5643ed2
 nocross=yes
 system_accounts="$pkgname"
-wrksrc="NetHack-NetHack-${version}_Released"
-
-post_extract() {
-	sed -i	-e '/COMPRESS/s/compress/gzip/g' \
-		-e '/COMPRESS_EXTENSION/s/\.Z/.gz/g' include/config.h
-}
 
 do_configure() {
 	sh sys/unix/setup.sh sys/unix/hints/linux
@@ -26,16 +23,15 @@ do_configure() {
 
 do_build() {
 	make all dungeon \
-		CC="$CC" LINK="$CC" LFLAGS="$LDFLAGS" \
-		LEX=flex WINTTYLIB=-lncurses \
-		CFLAGS="$CFLAGS -DLINUX -DTIMED_DELAY -DDLB \
-			-DSYSCF -DSYSCF_FILE='\"/usr/lib/nethack\"' \
-			-DHACKDIR='\"/var/games/nethack\"' -I../include"
+		CC="$CC" LINK="$CC" LFLAGS="$LDFLAGS" LEX=flex \
+		HACKDIR="/var/games/nethack"
 }
 
 do_install() {
 	vmkdir usr/share/man/man6
 	vmkdir var/games
+	vmkdir etc/nethack
+
 	make install manpages \
 		PREFIX=$DESTDIR \
 		SHELLDIR=$DESTDIR/usr/bin \
@@ -51,6 +47,7 @@ do_install() {
 
 	mv $DESTDIR/usr/lib/nethack/nhdat $DESTDIR/var/games/nethack
 	mv $DESTDIR/usr/lib/nethack/symbols $DESTDIR/var/games/nethack
+	mv $DESTDIR/usr/lib/nethack/sysconf $DESTDIR/etc/nethack
 	rm $DESTDIR/var/games/nethack/{logfile,perm,record,xlogfile}
 
 	sed -i	-e 's,^HACKDIR=.*,HACKDIR=/var/games/nethack,' \

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (13 preceding siblings ...)
  2020-12-11 23:26 ` [PR PATCH] [Updated] " ashpooljh
@ 2020-12-11 23:40 ` ashpooljh
  2020-12-11 23:41 ` ashpooljh
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: ashpooljh @ 2020-12-11 23:40 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2055 bytes --]

New comment by ashpooljh on void-packages repository

https://github.com/void-linux/void-packages/pull/27036#issuecomment-743483318

Comment:
As of `nethack-3.6.6_1`, the `nethack` binary is installed with the SGID bit (not SUID as I have written in the comment, sorry) and is owned by `nethack:nethack`. This is needed on multi-user systems so that the playground files (e.g. `/var/games/nethack/record`) are writable no matter what user runs the game.

To access these files, the game needs to chdir into the playground. The default path to the playground can be supplied using the `HACKDIR` macro at compile time, and the value can be overridden at runtime using a command line flag or an environment variable. This is where the `SECURE` macro comes in: if a path supplied during runtime is different from the default one (`HACKDIR`) and the `SECURE` macro is defined, the game sets `uid` and `gid` to those of the actual user running the binary. Without this, any user would be able to write into any directory as `:nethack`, which is somewhat of a security oopsie.

Except for the two occasions where this happens on the `unix` target ([1], [2]), I couldn't find any functional checks involving `SECURE`.

I was originally planning to make compile-time `HACKDIR` consistent with the install-time `HACKDIR` and keep `SECURE` undefined, because defining it would break the game: it would drop privs upon chdir into the non-`HACKDIR` playground, be unable to open `record` and exit. However, now I recognize the clever hack behind making `HACKDIR` different during compile-time: this allows to set a different directory as the _default_ playground, even if it's not where the binary is installed. I have therefore opted to leave this hack in place and define `SECURE` to mitigate the slight security risk of rogue `:nethack`.

[1]: https://github.com/NetHack/NetHack/blob/5c291bc54022f74a17985b6a54ac2174bba18700/sys/unix/unixmain.c#L477
[2]: https://github.com/NetHack/NetHack/blob/ac9ba384497879dd935bdf2aa86714dc2a35edd1/util/recover.c#L102

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (14 preceding siblings ...)
  2020-12-11 23:40 ` ashpooljh
@ 2020-12-11 23:41 ` ashpooljh
  2020-12-11 23:43 ` ashpooljh
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: ashpooljh @ 2020-12-11 23:41 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2057 bytes --]

New comment by ashpooljh on void-packages repository

https://github.com/void-linux/void-packages/pull/27036#issuecomment-743483318

Comment:
As of `nethack-3.6.6_1`, the `nethack` binary is installed with the SGID bit (not SUID as I have written in the comment, sorry) and is owned by `nethack:nethack`. This is needed on multi-user systems so that the playground files (e.g. `/var/games/nethack/record`) are writable no matter what user runs the game.

To access these files, the game needs to chdir into the playground. The default path to the playground can be supplied using the `HACKDIR` macro at compile time, and the value can be overridden at runtime using a command line flag or an environment variable. This is where the `SECURE` macro comes in: if the path supplied during runtime is different from the default one (`HACKDIR`) and the `SECURE` macro is defined, the game sets `uid` and `gid` to those of the actual user running the binary. Without this, any user would be able to write into any directory as `:nethack`, which is somewhat of a security oopsie.

Except for the two occasions where this happens on the `unix` target ([1], [2]), I couldn't find any functional checks involving `SECURE`.

I was originally planning to make compile-time `HACKDIR` consistent with the install-time `HACKDIR` and keep `SECURE` undefined, because defining it would break the game: it would drop privs upon chdir into the non-`HACKDIR` playground, be unable to open `record` and exit. However, now I recognize the clever hack behind making `HACKDIR` different during compile-time: this allows to set a different directory as the _default_ playground, even if it's not where the binary is installed. I have therefore opted to leave this hack in place and define `SECURE` to mitigate the slight security risk of rogue `:nethack`.

[1]: https://github.com/NetHack/NetHack/blob/5c291bc54022f74a17985b6a54ac2174bba18700/sys/unix/unixmain.c#L477
[2]: https://github.com/NetHack/NetHack/blob/ac9ba384497879dd935bdf2aa86714dc2a35edd1/util/recover.c#L102

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (15 preceding siblings ...)
  2020-12-11 23:41 ` ashpooljh
@ 2020-12-11 23:43 ` ashpooljh
  2020-12-11 23:49 ` ashpooljh
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: ashpooljh @ 2020-12-11 23:43 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2077 bytes --]

New comment by ashpooljh on void-packages repository

https://github.com/void-linux/void-packages/pull/27036#issuecomment-743483318

Comment:
As of `nethack-3.6.6_1`, the `nethack` binary is installed with the SGID bit (not SUID as I have written in the comment, sorry) and is owned by `nethack:nethack`. This is needed on multi-user systems so that the playground files (e.g. `/var/games/nethack/record`) are writable no matter what user runs the game.

To access these files, the game needs to chdir into the playground. The default path to the playground can be supplied using the `HACKDIR` macro at compile time, and the value can be overridden at runtime using a command line flag or an environment variable. This is where the `SECURE` macro comes in: if the path supplied during runtime is different from the default one (`HACKDIR`) and the `SECURE` macro is defined, the game sets `uid` and `gid` to those of the actual user running the binary. Without this, any user would be able to write into any directory as `:nethack`, which is somewhat of a security oopsie.

Except for the two occasions where this happens on the `unix` target ([1], [2]), I couldn't find any functional checks involving `SECURE`.

I was originally planning to make compile-time `HACKDIR` consistent with the install-time `HACKDIR` and keep `SECURE` undefined, because defining it would break the game: it would drop privs upon chdir into the non-`HACKDIR` playground, be unable to open `record` and exit. However, now I recognize the clever hack behind making `HACKDIR` different during compile-time: this allows to set a different directory as the _default_ playground, even if it's not where the binary is installed. I have therefore opted to leave this hack in place and define `SECURE` to mitigate the slight security risk of rogue-like `:nethack` (pun intended).

[1]: https://github.com/NetHack/NetHack/blob/5c291bc54022f74a17985b6a54ac2174bba18700/sys/unix/unixmain.c#L477
[2]: https://github.com/NetHack/NetHack/blob/ac9ba384497879dd935bdf2aa86714dc2a35edd1/util/recover.c#L102

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (16 preceding siblings ...)
  2020-12-11 23:43 ` ashpooljh
@ 2020-12-11 23:49 ` ashpooljh
  2020-12-12  1:44 ` ericonr
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: ashpooljh @ 2020-12-11 23:49 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2075 bytes --]

New comment by ashpooljh on void-packages repository

https://github.com/void-linux/void-packages/pull/27036#issuecomment-743483318

Comment:
As of `nethack-3.6.6_1`, the `nethack` binary is installed with the SGID bit (not SUID as I have written in the comment, sorry) and is owned by `nethack:nethack`. This is needed on multi-user systems so that the playground files (e.g. `/var/games/nethack/record`) are writable no matter what user runs the game.

To access these files, the game needs to chdir into the playground. A default path to the playground can be supplied using the `HACKDIR` macro at compile time, and the value can be overridden at runtime using a command line flag or an environment variable. This is where the `SECURE` macro comes in: if the path supplied during runtime is different from the default one (`HACKDIR`) and the `SECURE` macro is defined, the game sets `uid` and `gid` to those of the actual user running the binary. Without this, any user would be able to write into any directory as `:nethack`, which is somewhat of a security oopsie.

Except for the two occasions where this happens on the `unix` target ([1], [2]), I couldn't find any functional checks involving `SECURE`.

I was originally planning to make compile-time `HACKDIR` consistent with the install-time `HACKDIR` and keep `SECURE` undefined, because defining it would break the game: it would drop privs upon chdir into the non-`HACKDIR` playground, be unable to open `record` and exit. However, now I recognize the clever hack behind making `HACKDIR` different during compile-time: this allows to set a different directory as the _default_ playground, even if it's not where the binary is installed. I have therefore opted to leave this hack in place and define `SECURE` to mitigate the slight security risk of rogue-like `:nethack` (pun intended).

[1]: https://github.com/NetHack/NetHack/blob/5c291bc54022f74a17985b6a54ac2174bba18700/sys/unix/unixmain.c#L477
[2]: https://github.com/NetHack/NetHack/blob/ac9ba384497879dd935bdf2aa86714dc2a35edd1/util/recover.c#L102

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (17 preceding siblings ...)
  2020-12-11 23:49 ` ashpooljh
@ 2020-12-12  1:44 ` ericonr
  2020-12-12  9:32 ` [PR PATCH] [Updated] " ashpooljh
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: ericonr @ 2020-12-12  1:44 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 289 bytes --]

New comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/27036#issuecomment-743615731

Comment:
Nice, thanks for the thorough investigation!!

If you want to include some of that in the commit message, so it isn't lost to the sands of time :)

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PR PATCH] [Updated] nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (18 preceding siblings ...)
  2020-12-12  1:44 ` ericonr
@ 2020-12-12  9:32 ` ashpooljh
  2020-12-12  9:48 ` ashpooljh
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 24+ messages in thread
From: ashpooljh @ 2020-12-12  9:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 909 bytes --]

There is an updated pull request by ashpooljh against master on the void-packages repository

https://github.com/ashpooljh/void-packages nethack
https://github.com/void-linux/void-packages/pull/27036

nethack: fix SYSCF_FILE location
I wasn't able to enter the wizard mode, not even as root, e.g. `sudo nethack -D -u wizard` just printed 
```
Entering explore/discovery mode instead
```
Then I found out that `SYSCF_FILE` in the template was pointing to the directory `/usr/lib/nethack` instead of the file itself `/usr/lib/nethack/sysconf`, and used `gdb` to verify that this had lead to `src/files.c:parse_conf_file` silently failing (parsing nothing) and `sysopt.wizards` ending up empty. Updating the `SYSCF_FILE` value fixed the issue, and now the sysconf file is read and I'm able to access the wizard mode.

A patch file from https://github.com/void-linux/void-packages/pull/27036.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-nethack-27036.patch --]
[-- Type: text/x-diff, Size: 4448 bytes --]

From 2c6f211eed12e903018659e9bd0232341da79310 Mon Sep 17 00:00:00 2001
From: Artem Zhurikhin <ashpool@xecut.net>
Date: Tue, 8 Dec 2020 20:45:29 +0300
Subject: [PATCH] nethack: fix SYSCF_FILE, misc. improvements

- fix xlint
- move *-devel depends to makedepends
- stop overriding CFLAGS in template, patch sys/unix/hints/linux instead
- in particular, stop overriding the SECURE macro defined in hints to
  prevent unauthorized writes as :nethack. rely on build-time HACKDIR
  definition to make /var/games/nethack/ the default playground.
- remove post_extract() since this is already done in hints
- move /usr/lib/nethack/sysconf (SYSCF_FILE) to /etc/nethack/sysconf,
  add it conf_files. fix SYSCF_FILE permissions.
---
 srcpkgs/nethack/INSTALL                     |  1 +
 srcpkgs/nethack/patches/1-linux-hints.patch | 16 ++++++++++++++
 srcpkgs/nethack/template                    | 23 +++++++++------------
 3 files changed, 27 insertions(+), 13 deletions(-)
 create mode 100644 srcpkgs/nethack/patches/1-linux-hints.patch

diff --git a/srcpkgs/nethack/INSTALL b/srcpkgs/nethack/INSTALL
index c1b32c35262..78fe24f15ad 100644
--- a/srcpkgs/nethack/INSTALL
+++ b/srcpkgs/nethack/INSTALL
@@ -2,6 +2,7 @@ case "${ACTION}" in
 post)
 	chown nethack:nethack usr/lib/nethack/nethack
 	chmod 02755 usr/lib/nethack/nethack
+	chmod 0644 etc/nethack/sysconf
 	touch var/games/nethack/logfile var/games/nethack/perm var/games/nethack/record var/games/nethack/xlogfile
 	chown nethack:nethack var/games/nethack var/games/nethack/*
 	chmod 0775 var/games/nethack
diff --git a/srcpkgs/nethack/patches/1-linux-hints.patch b/srcpkgs/nethack/patches/1-linux-hints.patch
new file mode 100644
index 00000000000..caaef540295
--- /dev/null
+++ b/srcpkgs/nethack/patches/1-linux-hints.patch
@@ -0,0 +1,16 @@
+We move /usr/lib/nethack/sysconf to /etc/nethack/sysconf since
+this file is intended to be editable by root.
+
+diff --git sys/unix/hints/linux sys/unix/hints/linux
+index 8629150..9a4d722 100644
+--- sys/unix/hints/linux
++++ sys/unix/hints/linux
+@@ -23,7 +23,7 @@ POSTINSTALL=cp -n sys/unix/sysconf $(INSTDIR)/sysconf; $(CHOWN) $(GAMEUID) $(INS
+ CFLAGS=-g -O -I../include -DNOTPARMDECL
+ CFLAGS+=-DDLB
+ CFLAGS+=-DCOMPRESS=\"/bin/gzip\" -DCOMPRESS_EXTENSION=\".gz\"
+-CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE
++CFLAGS+=-DSYSCF -DSYSCF_FILE=\"/etc/nethack/sysconf\" -DSECURE
+ CFLAGS+=-DTIMED_DELAY
+ CFLAGS+=-DHACKDIR=\"$(HACKDIR)\"
+ CFLAGS+=-DDUMPLOG
diff --git a/srcpkgs/nethack/template b/srcpkgs/nethack/template
index b7ec4c30753..e39eafb0b5c 100644
--- a/srcpkgs/nethack/template
+++ b/srcpkgs/nethack/template
@@ -1,9 +1,12 @@
 # Template file for 'nethack'
 pkgname=nethack
 version=3.6.6
-revision=1
+revision=2
+wrksrc="NetHack-NetHack-${version}_Released"
+conf_files="/etc/nethack/sysconf"
 make_dirs="/var/games/nethack/save 0775 nethack nethack"
-hostmakedepends="ncurses-devel flex"
+hostmakedepends="flex"
+makedepends="ncurses-devel ncurses-libtinfo-devel"
 depends="gzip"
 short_desc="Exploring The Mazes of Menace"
 maintainer="Leah Neukirchen <leah@vuxu.org>"
@@ -13,12 +16,6 @@ distfiles="https://www.nethack.org/download/${version}/nethack-${version//./}-sr
 checksum=cfde0c3ab6dd7c22ae82e1e5a59ab80152304eb23fb06e3129439271e5643ed2
 nocross=yes
 system_accounts="$pkgname"
-wrksrc="NetHack-NetHack-${version}_Released"
-
-post_extract() {
-	sed -i	-e '/COMPRESS/s/compress/gzip/g' \
-		-e '/COMPRESS_EXTENSION/s/\.Z/.gz/g' include/config.h
-}
 
 do_configure() {
 	sh sys/unix/setup.sh sys/unix/hints/linux
@@ -26,16 +23,15 @@ do_configure() {
 
 do_build() {
 	make all dungeon \
-		CC="$CC" LINK="$CC" LFLAGS="$LDFLAGS" \
-		LEX=flex WINTTYLIB=-lncurses \
-		CFLAGS="$CFLAGS -DLINUX -DTIMED_DELAY -DDLB \
-			-DSYSCF -DSYSCF_FILE='\"/usr/lib/nethack\"' \
-			-DHACKDIR='\"/var/games/nethack\"' -I../include"
+		CC="$CC" LINK="$CC" LFLAGS="$LDFLAGS" LEX=flex \
+		HACKDIR="/var/games/nethack"
 }
 
 do_install() {
 	vmkdir usr/share/man/man6
 	vmkdir var/games
+	vmkdir etc/nethack
+
 	make install manpages \
 		PREFIX=$DESTDIR \
 		SHELLDIR=$DESTDIR/usr/bin \
@@ -51,6 +47,7 @@ do_install() {
 
 	mv $DESTDIR/usr/lib/nethack/nhdat $DESTDIR/var/games/nethack
 	mv $DESTDIR/usr/lib/nethack/symbols $DESTDIR/var/games/nethack
+	mv $DESTDIR/usr/lib/nethack/sysconf $DESTDIR/etc/nethack
 	rm $DESTDIR/var/games/nethack/{logfile,perm,record,xlogfile}
 
 	sed -i	-e 's,^HACKDIR=.*,HACKDIR=/var/games/nethack,' \

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (19 preceding siblings ...)
  2020-12-12  9:32 ` [PR PATCH] [Updated] " ashpooljh
@ 2020-12-12  9:48 ` ashpooljh
  2020-12-16  1:26 ` ericonr
  2020-12-16  1:26 ` [PR PATCH] [Merged]: " ericonr
  22 siblings, 0 replies; 24+ messages in thread
From: ashpooljh @ 2020-12-12  9:48 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 351 bytes --]

New comment by ashpooljh on void-packages repository

https://github.com/void-linux/void-packages/pull/27036#issuecomment-743731571

Comment:
@ericonr, thank you for challenging me to explain the purpose of `SECURE` better, because that's what prompted me to dig deeper and find out what was really going on. I ended up defining it because of this :)

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (20 preceding siblings ...)
  2020-12-12  9:48 ` ashpooljh
@ 2020-12-16  1:26 ` ericonr
  2020-12-16  1:26 ` [PR PATCH] [Merged]: " ericonr
  22 siblings, 0 replies; 24+ messages in thread
From: ericonr @ 2020-12-16  1:26 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 162 bytes --]

New comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/27036#issuecomment-745703253

Comment:
Thank you very much! 

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PR PATCH] [Merged]: nethack: fix SYSCF_FILE location
  2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
                   ` (21 preceding siblings ...)
  2020-12-16  1:26 ` ericonr
@ 2020-12-16  1:26 ` ericonr
  22 siblings, 0 replies; 24+ messages in thread
From: ericonr @ 2020-12-16  1:26 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 749 bytes --]

There's a merged pull request on the void-packages repository

nethack: fix SYSCF_FILE location
https://github.com/void-linux/void-packages/pull/27036

Description:
I wasn't able to enter the wizard mode, not even as root, e.g. `sudo nethack -D -u wizard` just printed 
```
Entering explore/discovery mode instead
```
Then I found out that `SYSCF_FILE` in the template was pointing to the directory `/usr/lib/nethack` instead of the file itself `/usr/lib/nethack/sysconf`, and used `gdb` to verify that this had lead to `src/files.c:parse_conf_file` silently failing (parsing nothing) and `sysopt.wizards` ending up empty. Updating the `SYSCF_FILE` value fixed the issue, and now the sysconf file is read and I'm able to access the wizard mode.

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2020-12-16  1:26 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08 17:54 [PR PATCH] nethack: fix SYSCF_FILE location ashpooljh
2020-12-08 18:51 ` [PR PATCH] [Updated] " ashpooljh
2020-12-08 18:52 ` ashpooljh
2020-12-08 19:08 ` ashpooljh
2020-12-08 19:10 ` ashpooljh
2020-12-08 19:13 ` leahneukirchen
2020-12-08 19:16 ` leahneukirchen
2020-12-10  9:55 ` [PR PATCH] [Updated] " ashpooljh
2020-12-10 10:02 ` ashpooljh
2020-12-10 10:04 ` ashpooljh
2020-12-11 15:10 ` [PR REVIEW] " ericonr
2020-12-11 16:05 ` ashpooljh
2020-12-11 16:06 ` ashpooljh
2020-12-11 16:16 ` ericonr
2020-12-11 23:26 ` [PR PATCH] [Updated] " ashpooljh
2020-12-11 23:40 ` ashpooljh
2020-12-11 23:41 ` ashpooljh
2020-12-11 23:43 ` ashpooljh
2020-12-11 23:49 ` ashpooljh
2020-12-12  1:44 ` ericonr
2020-12-12  9:32 ` [PR PATCH] [Updated] " ashpooljh
2020-12-12  9:48 ` ashpooljh
2020-12-16  1:26 ` ericonr
2020-12-16  1:26 ` [PR PATCH] [Merged]: " ericonr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).