summaryrefslogtreecommitdiffstats
path: root/games
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1997-09-24 08:58:44 +0000
committerache <ache@FreeBSD.org>1997-09-24 08:58:44 +0000
commitc332edcb082f1bf06a3a5702ff16593fe53d00dc (patch)
treeddd06bffa163ae4d5c0cf72c60c0c757edc62a68 /games
parent8a2532864c311362e03def0330257451972d754a (diff)
downloadFreeBSD-src-c332edcb082f1bf06a3a5702ff16593fe53d00dc.zip
FreeBSD-src-c332edcb082f1bf06a3a5702ff16593fe53d00dc.tar.gz
Make hack suid "games" (additionly to sgid "games" as run),
it is needed for savegames and bones, they intendent to not be altered by user and can't be pre-created as scorefile. Clear savegames on install: target too, not only bones Install rumors not readable by all. Cleanup includes a little.
Diffstat (limited to 'games')
-rw-r--r--games/hack/Makefile12
-rw-r--r--games/hack/hack.main.c4
-rw-r--r--games/hack/hack.pager.c4
3 files changed, 16 insertions, 4 deletions
diff --git a/games/hack/Makefile b/games/hack/Makefile
index 439b06c..03b8dff 100644
--- a/games/hack/Makefile
+++ b/games/hack/Makefile
@@ -20,6 +20,13 @@ HIDEGAME=hidegame
DPSRCS+= hack.onames.h
CLEANFILES+= hack.onames.h makedefs
+#
+# Need to be suid for created savefiles and bones, they must not be
+# altered by user
+#
+BINOWN= games
+BINMODE= 4550
+
.depend: hack.onames.h
hack.onames.h: makedefs def.objects.h
@@ -33,11 +40,12 @@ beforeinstall:
${DESTDIR}/var/games/hackdir/perm
${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \
${DESTDIR}/var/games/hackdir/record
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 664 ${.CURDIR}/rumors \
+ ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 660 ${.CURDIR}/rumors \
${DESTDIR}/var/games/hackdir/rumors
${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
${.CURDIR}/help ${.CURDIR}/hh ${.CURDIR}/data \
${DESTDIR}/var/games/hackdir
- rm -f ${DESTDIR}/var/games/hackdir/bones*
+ rm -f ${DESTDIR}/var/games/hackdir/bones* \
+ ${DESTDIR}/var/games/hackdir/save/*
.include <bsd.prog.mk>
diff --git a/games/hack/hack.main.c b/games/hack/hack.main.c
index 530eb0b..fa66e27 100644
--- a/games/hack/hack.main.c
+++ b/games/hack/hack.main.c
@@ -3,6 +3,8 @@
#include <stdio.h>
#include <signal.h>
+#include <stdlib.h>
+#include <unistd.h>
#include "hack.h"
#ifdef QUEST
@@ -11,7 +13,6 @@
#define gamename "hack"
#endif
-extern char *getlogin(), *getenv();
extern char plname[PL_NSIZ], pl_character[PL_CSIZ];
extern struct permonst mons[CMNUM+2];
extern char genocided[], fut_geno[];
@@ -461,6 +462,7 @@ boolean wr;
) {
/* revoke */
setgid(getgid());
+ setuid(getuid());
}
#endif
diff --git a/games/hack/hack.pager.c b/games/hack/hack.pager.c
index df86ca6..a3af28d 100644
--- a/games/hack/hack.pager.c
+++ b/games/hack/hack.pager.c
@@ -8,11 +8,12 @@
#include <sys/types.h>
#include <sys/signal.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
#include "hack.h"
extern int CO, LI; /* usually COLNO and ROWNO+2 */
extern char *CD;
extern char quitchars[];
-extern char *getenv(), *getlogin();
void done1();
dowhatis()
@@ -380,6 +381,7 @@ child(wt) {
settty((char *) 0); /* also calls end_screen() */
/* revoke */
setgid(getgid());
+ setuid(getuid());
#ifdef CHDIR
(void) chdir(getenv("HOME"));
#endif CHDIR
OpenPOWER on IntegriCloud