diff --git a/games/hack/Makefile b/games/hack/Makefile index 439b06c060c2..03b8dff87ee0 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 diff --git a/games/hack/hack.main.c b/games/hack/hack.main.c index 530eb0ba8903..fa66e2707c97 100644 --- a/games/hack/hack.main.c +++ b/games/hack/hack.main.c @@ -3,6 +3,8 @@ #include #include +#include +#include #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 df86ca609c5d..a3af28d6ec5e 100644 --- a/games/hack/hack.pager.c +++ b/games/hack/hack.pager.c @@ -8,11 +8,12 @@ #include #include #include +#include +#include #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