diff options
author | Paul Janzen <pjanzen@cvs.openbsd.org> | 1999-03-27 03:45:51 +0000 |
---|---|---|
committer | Paul Janzen <pjanzen@cvs.openbsd.org> | 1999-03-27 03:45:51 +0000 |
commit | f51cf7f2e10053f45c0ffa2e95347f56d2eecce7 (patch) | |
tree | 36f2fd5bc053b41ba6a744a078f5d81e0a22c0dd /games | |
parent | 5190786085567acf6f269919dffc1b455a46988c (diff) |
Changes from FreeBSD: install score files, use random(), and be more careful
on exec.
Diffstat (limited to 'games')
-rw-r--r-- | games/larn/Makefile | 6 | ||||
-rw-r--r-- | games/larn/data.c | 6 | ||||
-rw-r--r-- | games/larn/global.c | 9 | ||||
-rw-r--r-- | games/larn/header.h | 8 | ||||
-rw-r--r-- | games/larn/io.c | 6 | ||||
-rw-r--r-- | games/larn/larn.6 | 4 | ||||
-rw-r--r-- | games/larn/scores.c | 6 | ||||
-rw-r--r-- | games/larn/tok.c | 8 |
8 files changed, 31 insertions, 22 deletions
diff --git a/games/larn/Makefile b/games/larn/Makefile index 0235429e774..e9fd9d54c99 100644 --- a/games/larn/Makefile +++ b/games/larn/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.10 1999/01/01 17:47:17 millert Exp $ +# $OpenBSD: Makefile,v 1.11 1999/03/27 03:45:49 pjanzen Exp $ # EXTRA # Incorporates code to gather additional performance statistics @@ -69,5 +69,9 @@ beforeinstall: (cd ${.CURDIR}/datfiles; ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} \ -m 444 larnmaze larnopts larn.help \ ${DESTDIR}/usr/share/games/larn) + ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 660 /dev/null \ + ${DESTDIR}/var/games/larn/lscore12.0 + ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 660 /dev/null \ + ${DESTDIR}/var/games/larn/llog12.0 .include <bsd.prog.mk> diff --git a/games/larn/data.c b/games/larn/data.c index d3362fd8aa7..3ab1b5b2025 100644 --- a/games/larn/data.c +++ b/games/larn/data.c @@ -1,4 +1,4 @@ -/* $OpenBSD: data.c,v 1.5 1998/09/15 05:12:31 pjanzen Exp $ */ +/* $OpenBSD: data.c,v 1.6 1999/03/27 03:45:49 pjanzen Exp $ */ /* $NetBSD: data.c,v 1.9 1997/10/25 01:40:47 thorpej Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)data.c 5.3 (Berkeley) 5/13/91"; #else -static char rcsid[] = "$OpenBSD: data.c,v 1.5 1998/09/15 05:12:31 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: data.c,v 1.6 1999/03/27 03:45:49 pjanzen Exp $"; #endif #endif /* not lint */ @@ -162,7 +162,9 @@ short oldx, oldy; short lasthx = 0, lasthy = 0; /* location of monster last hit by * player */ short nobeep = 0; /* true if program is not to beep */ +#ifdef MACRORND unsigned long randx = 33601; /* the random number seed */ +#endif time_t initialtime = 0;/* time playing began */ long gltime = 0; /* the clock for the game */ long outstanding_taxes = 0; /* present tax bill from score file */ diff --git a/games/larn/global.c b/games/larn/global.c index f926125fffb..c23bb76e7b4 100644 --- a/games/larn/global.c +++ b/games/larn/global.c @@ -1,4 +1,4 @@ -/* $OpenBSD: global.c,v 1.3 1998/09/15 05:12:31 pjanzen Exp $ */ +/* $OpenBSD: global.c,v 1.4 1999/03/27 03:45:49 pjanzen Exp $ */ /* $NetBSD: global.c,v 1.6 1997/10/18 20:03:20 christos Exp $ */ /* @@ -23,7 +23,7 @@ * quit() subroutine to ask if the player really wants to quit */ #ifndef lint -static char rcsid[] = "$OpenBSD: global.c,v 1.3 1998/09/15 05:12:31 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: global.c,v 1.4 1999/03/27 03:45:49 pjanzen Exp $"; #endif /* not lint */ #include <string.h> @@ -32,7 +32,6 @@ static char rcsid[] = "$OpenBSD: global.c,v 1.3 1998/09/15 05:12:31 pjanzen Exp #include "extern.h" extern int score[], srcount, dropflag; -extern int random; /* the random number seed */ extern short playerx, playery, lastnum, level; extern u_char cheat; extern char monstnamelist[], logname[]; @@ -958,13 +957,13 @@ int rnd(x) int x; { - return ((((randx = randx * 1103515245 + 12345) >> 7) % (x)) + 1); + return ((random() % x) + 1); } int rund(x) int x; { - return ((((randx = randx * 1103515245 + 12345) >> 7) % (x))); + return (random() % x); } #endif /* MACRORND */ diff --git a/games/larn/header.h b/games/larn/header.h index 87946ef7b16..f228dfd839f 100644 --- a/games/larn/header.h +++ b/games/larn/header.h @@ -1,4 +1,4 @@ -/* $OpenBSD: header.h,v 1.7 1998/09/15 05:12:32 pjanzen Exp $ */ +/* $OpenBSD: header.h,v 1.8 1999/03/27 03:45:49 pjanzen Exp $ */ /* $NetBSD: header.h,v 1.12 1997/10/25 01:40:48 thorpej Exp $ */ /* header.h Larn is copyrighted 1986 by Noah Morgan. */ @@ -362,7 +362,6 @@ extern int dayplay, enable_scroll, srcount, yrepcount, userid, wisid, extern gid_t gid, egid; extern long outstanding_taxes, skill[], gltime, c[], cbak[]; extern time_t initialtime; -extern unsigned long randx; extern struct cel *cell; extern struct monst monster[]; extern struct sphere *spheres; @@ -427,9 +426,10 @@ extern int rmst, maxitm, lasttime; /* macro to output one byte to the output buffer */ #define lprc(ch) ((lpnt>=lpend)?(*lpnt++ =(ch), lflush()):(*lpnt++ =(ch))) -/* macro to seed the random number generator */ -#define srand(x) (randx=x) #ifdef MACRORND +extern unsigned long randx; +/* macro to seed the random number generator */ +#define srandom(x) (randx=x) /* macros to generate random numbers 1<=rnd(N)<=N 0<=rund(N)<=N-1 */ #define rnd(x) ((((randx=randx*1103515245+12345)>>7)%(x))+1) #define rund(x) ((((randx=randx*1103515245+12345)>>7)%(x)) ) diff --git a/games/larn/io.c b/games/larn/io.c index 069dd0bad16..fd5480a21cc 100644 --- a/games/larn/io.c +++ b/games/larn/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.4 1998/09/15 05:12:32 pjanzen Exp $ */ +/* $OpenBSD: io.c,v 1.5 1999/03/27 03:45:49 pjanzen Exp $ */ /* $NetBSD: io.c,v 1.7 1997/10/18 20:03:26 christos Exp $ */ /* @@ -61,7 +61,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: io.c,v 1.4 1998/09/15 05:12:32 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: io.c,v 1.5 1999/03/27 03:45:49 pjanzen Exp $"; #endif /* not lint */ #include "header.h" @@ -213,7 +213,7 @@ newgame() for (p = c, pe = c + 100; p < pe; *p++ = 0); time(&initialtime); - srand(initialtime); + srandom(initialtime); lcreat((char *) 0); /* open buffering for output to terminal */ } diff --git a/games/larn/larn.6 b/games/larn/larn.6 index 222d9a032b3..4476a2b146b 100644 --- a/games/larn/larn.6 +++ b/games/larn/larn.6 @@ -1,4 +1,4 @@ -.\" $OpenBSD: larn.6,v 1.5 1999/03/20 18:54:47 pjanzen Exp $ +.\" $OpenBSD: larn.6,v 1.6 1999/03/27 03:45:50 pjanzen Exp $ .\" $NetBSD: larn.6,v 1.3 1995/03/23 08:33:42 cgd Exp $ .\" .\" Copyright (c) 1990 The Regents of the University of California. @@ -178,6 +178,8 @@ Noah Morgan .Bl -tag -width "/var/games/larn.scores" -compact .It Pa /var/games/larn.scores Score file. +.It Pa /var/games/larn/llog12.0 +Log file. .It Pa ~/.larnopts Options file. .El diff --git a/games/larn/scores.c b/games/larn/scores.c index 655cdb5b7e3..8978a21c51b 100644 --- a/games/larn/scores.c +++ b/games/larn/scores.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scores.c,v 1.5 1998/09/15 05:12:33 pjanzen Exp $ */ +/* $OpenBSD: scores.c,v 1.6 1999/03/27 03:45:50 pjanzen Exp $ */ /* $NetBSD: scores.c,v 1.10 1997/10/18 20:03:48 christos Exp $ */ /* @@ -27,7 +27,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: scores.c,v 1.5 1998/09/15 05:12:33 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: scores.c,v 1.6 1999/03/27 03:45:50 pjanzen Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -661,7 +661,7 @@ invalid: sncbr(); resetscroll(); lflush(); - exit(0); + exit(1); } setegid(egid); chmod(logfile, 0660); diff --git a/games/larn/tok.c b/games/larn/tok.c index f295bab2b76..432d58d677c 100644 --- a/games/larn/tok.c +++ b/games/larn/tok.c @@ -1,9 +1,9 @@ -/* $OpenBSD: tok.c,v 1.2 1998/09/15 05:12:33 pjanzen Exp $ */ +/* $OpenBSD: tok.c,v 1.3 1999/03/27 03:45:50 pjanzen Exp $ */ /* $NetBSD: tok.c,v 1.5 1997/10/18 20:03:54 christos Exp $ */ /* tok.c Larn is copyrighted 1986 by Noah Morgan. */ #ifndef lint -static char rcsid[] = "$OpenBSD: tok.c,v 1.2 1998/09/15 05:12:33 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: tok.c,v 1.3 1999/03/27 03:45:50 pjanzen Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -63,7 +63,7 @@ yylex() * finish */ if (fork() == 0) { savegame(ckpfile); - exit(); + exit(0); } #endif @@ -99,6 +99,8 @@ yylex() clear();/* scrolling region, home, clear, no * attributes */ if ((ic = fork()) == 0) { /* child */ + /* revoke */ + setgid(getgid()); execl("/bin/csh", 0); exit(1); } |