summaryrefslogtreecommitdiffstats
path: root/larn/scores.c
diff options
context:
space:
mode:
authormrg <mrg@NetBSD.org>1996-05-22 00:36:04 +0000
committermrg <mrg@NetBSD.org>1996-05-22 00:36:04 +0000
commit828801324c4d8462b517d534a818131d842ac1fe (patch)
tree287ae16a5d74464c23106093fdfdcf481c64b575 /larn/scores.c
parent9c906fe8393c2c0fdbad40c90606cefc983a91a0 (diff)
downloadbsdgames-darwin-828801324c4d8462b517d534a818131d842ac1fe.tar.gz
bsdgames-darwin-828801324c4d8462b517d534a818131d842ac1fe.tar.zst
bsdgames-darwin-828801324c4d8462b517d534a818131d842ac1fe.zip
oops, we do need privs. do the right seteuid() thing.
Diffstat (limited to 'larn/scores.c')
-rw-r--r--larn/scores.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/larn/scores.c b/larn/scores.c
index 8a2fac26..3a96271c 100644
--- a/larn/scores.c
+++ b/larn/scores.c
@@ -1,5 +1,5 @@
#ifndef lint
-static char rcsid[] = "$NetBSD: scores.c,v 1.5 1995/04/24 12:24:08 cgd Exp $";
+static char rcsid[] = "$NetBSD: scores.c,v 1.6 1996/05/22 00:36:14 mrg Exp $";
#endif /* not lint */
/* scores.c Larn is copyrighted 1986 by Noah Morgan.
@@ -101,7 +101,12 @@ static char *whydead[] = {
*/
readboard()
{
- if (lopen(scorefile)<0)
+ int i;
+
+ seteuid(euid);
+ i = lopen(scorefile);
+ seteuid(uid);
+ if (i<0)
{ lprcat("Can't read scoreboard\n"); lflush(); return(-1); }
lrfill((char*)sco,sizeof(sco)); lrfill((char*)winr,sizeof(winr));
lrclose(); lcreat((char*)0); return(0);
@@ -114,8 +119,13 @@ readboard()
*/
writeboard()
{
+ int i;
+
set_score_output();
- if (lcreat(scorefile)<0)
+ seteuid(euid);
+ i = lcreat(scorefile);
+ seteuid(uid);
+ if (i<0)
{ lprcat("Can't write scoreboard\n"); lflush(); return(-1); }
lwrite((char*)sco,sizeof(sco)); lwrite((char*)winr,sizeof(winr));
lwclose(); lcreat((char*)0); return(0);
@@ -135,7 +145,9 @@ makeboard()
winr[i].order = sco[i].order = i;
}
if (writeboard()) return(-1);
+ seteuid(euid);
chmod(scorefile,0660);
+ seteuid(uid);
return(0);
}
@@ -512,7 +524,9 @@ invalid:
lprcat("\nCan't open record file: I can't post your score.\n");
sncbr(); resetscroll(); lflush(); exit();
}
+ seteuid(euid);
chmod(logfile,0660);
+ seteuid(uid);
}
strcpy(logg.who,loginname);
logg.score = c[GOLD]; logg.diff = c[HARDGAME];