summaryrefslogtreecommitdiffstats
path: root/games/snake
diff options
context:
space:
mode:
authoreivind <eivind@FreeBSD.org>1997-09-01 00:34:51 +0000
committereivind <eivind@FreeBSD.org>1997-09-01 00:34:51 +0000
commitd8e95d8c1a6a0918fc9dda2ca247833ad222696d (patch)
tree42fed91af49ba9290d473dbe68d13f3f33e7545c /games/snake
parentff4b4c1d18cef70a372542d0a1a7a48e6543cf9e (diff)
downloadFreeBSD-src-d8e95d8c1a6a0918fc9dda2ca247833ad222696d.zip
FreeBSD-src-d8e95d8c1a6a0918fc9dda2ca247833ad222696d.tar.gz
Change games from setuid games to setgid games.
Reviewed by: maybe@yes.no Obtained from: OpenBSD (mostly deraadt@openbsd.org)
Diffstat (limited to 'games/snake')
-rw-r--r--games/snake/snake/snake.c16
-rw-r--r--games/snake/snscore/snscore.c6
2 files changed, 18 insertions, 4 deletions
diff --git a/games/snake/snake/snake.c b/games/snake/snake/snake.c
index c41ee05..7fdf0db 100644
--- a/games/snake/snake/snake.c
+++ b/games/snake/snake/snake.c
@@ -93,6 +93,9 @@ int repeat=1;
long tv;
char *tn;
+int rawscores;
+FILE *logfile;
+
main(argc,argv)
int argc;
char **argv;
@@ -103,6 +106,13 @@ char **argv;
long atol();
void stop();
+ rawscores = open(_PATH_RAWSCORES, O_RDWR|O_CREAT, 0644);
+ logfile = fopen(_PATH_LOGFILE, "a");
+
+ /* revoke privs */
+ setegid(getgid());
+ setgid(getgid());
+
(void)time(&tv);
srandom((int)tv);
@@ -464,7 +474,6 @@ post(iscore, flag)
int iscore, flag;
{
short score = iscore;
- int rawscores;
short uid;
short oldbest=0;
short allbwho=0, allbscore=0;
@@ -477,7 +486,7 @@ int iscore, flag;
pr("No saved scores for uid %d.\n", uid);
return(1);
}
- if ((rawscores = open(_PATH_RAWSCORES, O_RDWR|O_CREAT, 0644)) < 0) {
+ if (rawscores == -1) {
pr("No score file %s: %s.\n", _PATH_RAWSCORES,
strerror(errno));
return(1);
@@ -880,10 +889,9 @@ int num;
logit(msg)
char *msg;
{
- FILE *logfile;
long t;
- if ((logfile=fopen(_PATH_LOGFILE, "a")) != NULL) {
+ if (logfile != NULL) {
time(&t);
fprintf(logfile, "%s $%d %dx%d %s %s",
getlogin(), cashvalue, lcnt, ccnt, msg, ctime(&t));
diff --git a/games/snake/snscore/snscore.c b/games/snake/snscore/snscore.c
index 1590404..a9ee82f 100644
--- a/games/snake/snscore/snscore.c
+++ b/games/snake/snscore/snscore.c
@@ -68,10 +68,16 @@ main()
struct passwd *p;
fd = fopen(recfile, "r");
+
if (fd == NULL) {
perror(recfile);
exit(1);
}
+
+ /* revoke privs */
+ setegid(getgid());
+ setgid(getgid());
+
printf("Snake players scores to date\n");
fread(&whoallbest, sizeof(short), 1, fd);
fread(&allbest, sizeof(short), 1, fd);
OpenPOWER on IntegriCloud