Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-3-0]: src/games/larn Pull up following revision(s) (requested by ...
details: https://anonhg.NetBSD.org/src/rev/3f6bbe98ecb8
branches: netbsd-3-0
changeset: 579469:3f6bbe98ecb8
user: riz <riz%NetBSD.org@localhost>
date: Sun Feb 03 18:30:23 2008 +0000
description:
Pull up following revision(s) (requested by dholland in ticket #1899):
games/larn/scores.c: revision 1.16
games/larn/header.h: revision 1.18
games/larn/bill.c: revision 1.9
games/larn/main.c: revision 1.21
Since games are (now) setgid, not setuid, it is no longer necessary to
manipulate the effective uid, only the effective gid.
Use mkstemp to make the temporary files used when you win.
diffstat:
games/larn/bill.c | 10 +++++-----
games/larn/header.h | 4 ++--
games/larn/main.c | 12 ++++++------
games/larn/scores.c | 34 ++++++++++++++++++++++------------
4 files changed, 35 insertions(+), 25 deletions(-)
diffs (182 lines):
diff -r e560a9a03e93 -r 3f6bbe98ecb8 games/larn/bill.c
--- a/games/larn/bill.c Mon Jan 21 19:08:40 2008 +0000
+++ b/games/larn/bill.c Sun Feb 03 18:30:23 2008 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bill.c,v 1.7 2003/08/07 09:37:22 agc Exp $ */
+/* $NetBSD: bill.c,v 1.7.10.1 2008/02/03 18:30:23 riz Exp $ */
/*-
* Copyright (c) 1991 The Regents of the University of California.
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)bill.c 5.2 (Berkeley) 5/28/91";
#else
-__RCSID("$NetBSD: bill.c,v 1.7 2003/08/07 09:37:22 agc Exp $");
+__RCSID("$NetBSD: bill.c,v 1.7.10.1 2008/02/03 18:30:23 riz Exp $");
#endif
#endif /* not lint */
@@ -44,6 +44,7 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
+#include <paths.h>
#include "header.h"
#include "extern.h"
@@ -130,10 +131,9 @@
if (fork() == 0) {
resetscroll();
cp = mail;
- snprintf(fname, sizeof(fname), "/tmp/#%dlarnmail", getpid());
+ snprintf(fname, sizeof(fname), "%slarnmail.XXXXXX", _PATH_TMP);
for (i = 0; i < 6; i++) {
- if ((fd = open(fname, O_WRONLY | O_TRUNC | O_CREAT,
- 0666)) == -1)
+ if ((fd = mkstemp(fname)) == -1)
exit(0);
while (*cp != NULL) {
if (*cp[0] == '1') {
diff -r e560a9a03e93 -r 3f6bbe98ecb8 games/larn/header.h
--- a/games/larn/header.h Mon Jan 21 19:08:40 2008 +0000
+++ b/games/larn/header.h Sun Feb 03 18:30:23 2008 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: header.h,v 1.15 2005/02/03 02:23:02 perry Exp $ */
+/* $NetBSD: header.h,v 1.15.4.1 2008/02/03 18:30:23 riz Exp $ */
/* header.h Larn is copyrighted 1986 by Noah Morgan. */
@@ -360,7 +360,7 @@
extern short nobeep, oldx, oldy, playerx, playery, level;
extern int dayplay, enable_scroll, srcount, yrepcount, userid, wisid,
lfd, fd;
-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 -r e560a9a03e93 -r 3f6bbe98ecb8 games/larn/main.c
--- a/games/larn/main.c Mon Jan 21 19:08:40 2008 +0000
+++ b/games/larn/main.c Sun Feb 03 18:30:23 2008 +0000
@@ -1,9 +1,9 @@
-/* $NetBSD: main.c,v 1.16 2001/02/05 00:57:33 christos Exp $ */
+/* $NetBSD: main.c,v 1.16.12.1 2008/02/03 18:30:23 riz Exp $ */
/* main.c */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: main.c,v 1.16 2001/02/05 00:57:33 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.16.12.1 2008/02/03 18:30:23 riz Exp $");
#endif /* not lint */
#include <sys/types.h>
@@ -20,7 +20,7 @@
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 @@
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 -r e560a9a03e93 -r 3f6bbe98ecb8 games/larn/scores.c
--- a/games/larn/scores.c Mon Jan 21 19:08:40 2008 +0000
+++ b/games/larn/scores.c Sun Feb 03 18:30:23 2008 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: scores.c,v 1.12 2004/02/13 11:36:08 wiz Exp $ */
+/* $NetBSD: scores.c,v 1.12.10.1 2008/02/03 18:30:23 riz 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.12 2004/02/13 11:36:08 wiz Exp $");
+__RCSID("$NetBSD: scores.c,v 1.12.10.1 2008/02/03 18:30:23 riz Exp $");
#endif /* not lint */
#include <sys/types.h>
#include <sys/times.h>
@@ -112,9 +112,11 @@
{
int i;
- seteuid(euid);
+ if (gid != egid)
+ setegid(egid);
i = lopen(scorefile);
- seteuid(uid);
+ if (gid != egid)
+ setegid(gid);
if (i < 0) {
lprcat("Can't read scoreboard\n");
lflush();
@@ -138,9 +140,11 @@
int i;
set_score_output();
- seteuid(euid);
+ if (gid != egid)
+ setegid(egid);
i = lcreat(scorefile);
- seteuid(uid);
+ if (gid != egid)
+ setegid(gid);
if (i < 0) {
lprcat("Can't write scoreboard\n");
lflush();
@@ -168,9 +172,11 @@
}
if (writeboard())
return (-1);
- seteuid(euid);
+ if (gid != egid)
+ setegid(egid);
chmod(scorefile, 0660);
- seteuid(uid);
+ if (gid != egid)
+ setegid(gid);
return (0);
}
@@ -643,7 +649,8 @@
set_score_output();
if ((wizard == 0) && (c[GOLD] > 0)) { /* wizards can't score */
#ifndef NOLOG
- 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 */
@@ -654,11 +661,14 @@
lflush();
exit(0);
}
- seteuid(euid);
+ if (gid != egid)
+ setegid(egid);
chmod(logfile, 0660);
- seteuid(uid);
+ if (gid != egid)
+ setegid(gid);
}
- seteuid(uid);
+ if (gid != egid)
+ setegid(gid);
strcpy(logg.who, loginname);
logg.score = c[GOLD];
logg.diff = c[HARDGAME];
Home |
Main Index |
Thread Index |
Old Index