summaryrefslogtreecommitdiffstats
path: root/larn
diff options
context:
space:
mode:
authordholland <dholland@NetBSD.org>2008-02-03 03:45:55 +0000
committerdholland <dholland@NetBSD.org>2008-02-03 03:45:55 +0000
commitba1922e360028e00b0ecadd02bb51f723c22ce67 (patch)
treed373eca787b41d130b7054cd8af3bb08faf5aeb2 /larn
parent889e3f85515ffa0f8441d9e7de28c22569d2eabe (diff)
downloadbsdgames-darwin-ba1922e360028e00b0ecadd02bb51f723c22ce67.tar.gz
bsdgames-darwin-ba1922e360028e00b0ecadd02bb51f723c22ce67.tar.zst
bsdgames-darwin-ba1922e360028e00b0ecadd02bb51f723c22ce67.zip
Since games are (now) setgid, not setuid, it is no longer necessary to
manipulate the effective uid, only the effective gid.
Diffstat (limited to 'larn')
-rw-r--r--larn/header.h4
-rw-r--r--larn/main.c12
-rw-r--r--larn/scores.c44
3 files changed, 30 insertions, 30 deletions
diff --git a/larn/header.h b/larn/header.h
index d8025583..1a81f434 100644
--- a/larn/header.h
+++ b/larn/header.h
@@ -1,4 +1,4 @@
-/* $NetBSD: header.h,v 1.17 2008/01/28 05:38:53 dholland Exp $ */
+/* $NetBSD: header.h,v 1.18 2008/02/03 03:45:55 dholland Exp $ */
/* header.h Larn is copyrighted 1986 by Noah Morgan. */
@@ -363,7 +363,7 @@ extern short iarg[MAXX][MAXY], ivenarg[], lasthx, lasthy, lastnum, lastpx,
extern short nobeep, oldx, oldy, playerx, playery, level;
extern int dayplay, enable_scroll, srcount, yrepcount, userid, wisid,
io_outfd, io_infd;
-extern uid_t uid, euid;
+extern gid_t gid, egid;
extern long outstanding_taxes, skill[], gltime, c[], cbak[];
extern time_t initialtime;
extern unsigned long randx;
diff --git a/larn/main.c b/larn/main.c
index a7027b70..288a8f8b 100644
--- a/larn/main.c
+++ b/larn/main.c
@@ -1,9 +1,9 @@
-/* $NetBSD: main.c,v 1.20 2008/01/28 05:38:54 dholland Exp $ */
+/* $NetBSD: main.c,v 1.21 2008/02/03 03:45:55 dholland Exp $ */
/* main.c */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: main.c,v 1.20 2008/01/28 05:38:54 dholland Exp $");
+__RCSID("$NetBSD: main.c,v 1.21 2008/02/03 03:45:55 dholland Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -20,7 +20,7 @@ int srcount = 0; /* line counter for showstr() */
int dropflag = 0; /* if 1 then don't lookforobject() next round */
int rmst = 80; /* random monster creation counter */
int userid; /* the players login user id number */
-uid_t uid, euid; /* used for security */
+gid_t gid, egid; /* used for security */
u_char nowelcome = 0, nomove = 0; /* if (nomove) then don't
* count next iteration as a
* move */
@@ -63,9 +63,9 @@ main(argc, argv)
struct passwd *pwe;
i = 0;
- euid = geteuid();
- uid = getuid();
- seteuid(uid); /* give up "games" if we have it */
+ egid = getegid();
+ gid = getgid();
+ setegid(gid); /* give up "games" if we have it */
/*
* first task is to identify the player
*/
diff --git a/larn/scores.c b/larn/scores.c
index 27b9a13f..35224fba 100644
--- a/larn/scores.c
+++ b/larn/scores.c
@@ -1,4 +1,4 @@
-/* $NetBSD: scores.c,v 1.15 2008/01/28 05:38:54 dholland Exp $ */
+/* $NetBSD: scores.c,v 1.16 2008/02/03 03:45:55 dholland Exp $ */
/*
* scores.c Larn is copyrighted 1986 by Noah Morgan.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: scores.c,v 1.15 2008/01/28 05:38:54 dholland Exp $");
+__RCSID("$NetBSD: scores.c,v 1.16 2008/02/03 03:45:55 dholland Exp $");
#endif /* not lint */
#include <sys/types.h>
#include <sys/times.h>
@@ -112,11 +112,11 @@ readboard()
{
int i;
- if (uid != euid)
- seteuid(euid);
+ if (gid != egid)
+ setegid(egid);
i = lopen(scorefile);
- if (uid != euid)
- seteuid(uid);
+ if (gid != egid)
+ setegid(gid);
if (i < 0) {
lprcat("Can't read scoreboard\n");
lflush();
@@ -140,11 +140,11 @@ writeboard()
int i;
set_score_output();
- if (uid != euid)
- seteuid(euid);
+ if (gid != egid)
+ setegid(egid);
i = lcreat(scorefile);
- if (uid != euid)
- seteuid(uid);
+ if (gid != egid)
+ setegid(gid);
if (i < 0) {
lprcat("Can't write scoreboard\n");
lflush();
@@ -173,11 +173,11 @@ makeboard()
}
if (writeboard())
return (-1);
- if (uid != euid)
- seteuid(euid);
+ if (gid != egid)
+ setegid(egid);
chmod(scorefile, 0660);
- if (uid != euid)
- seteuid(uid);
+ if (gid != egid)
+ setegid(gid);
return (0);
}
@@ -652,8 +652,8 @@ invalid:
set_score_output();
if ((wizard == 0) && (c[GOLD] > 0)) { /* wizards can't score */
#ifndef NOLOG
- if (uid != euid)
- seteuid(euid);
+ if (gid != egid)
+ setegid(egid);
if (lappend(logfile) < 0) { /* append to file */
if (lcreat(logfile) < 0) { /* and can't create new
* log file */
@@ -664,14 +664,14 @@ invalid:
lflush();
exit(0);
}
- if (uid != euid)
- seteuid(euid);
+ if (gid != egid)
+ setegid(egid);
chmod(logfile, 0660);
- if (uid != euid)
- seteuid(uid);
+ if (gid != egid)
+ setegid(gid);
}
- if (uid != euid)
- seteuid(uid);
+ if (gid != egid)
+ setegid(gid);
strcpy(logg.who, loginname);
logg.score = c[GOLD];
logg.diff = c[HARDGAME];