Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/games/battlestar Drop setgid privileges early. Derived from ...
details: https://anonhg.NetBSD.org/src/rev/9137f0793ac5
branches: trunk
changeset: 474797:9137f0793ac5
user: hubertf <hubertf%NetBSD.org@localhost>
date: Wed Jul 21 03:56:53 1999 +0000
description:
Drop setgid privileges early. Derived from OpenBSD and sent in as PR 5970
by Joseph Myers <jsm28%cam.ac.uk@localhost>.
diffstat:
games/battlestar/battlestar.c | 7 +++++--
games/battlestar/com6.c | 28 ++++++++++++++++++----------
games/battlestar/extern.h | 3 ++-
3 files changed, 25 insertions(+), 13 deletions(-)
diffs (109 lines):
diff -r 1201ef8ae802 -r 9137f0793ac5 games/battlestar/battlestar.c
--- a/games/battlestar/battlestar.c Wed Jul 21 03:32:53 1999 +0000
+++ b/games/battlestar/battlestar.c Wed Jul 21 03:56:53 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: battlestar.c,v 1.6 1997/10/11 02:06:55 lukem Exp $ */
+/* $NetBSD: battlestar.c,v 1.7 1999/07/21 03:56:53 hubertf Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)battlestar.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: battlestar.c,v 1.6 1997/10/11 02:06:55 lukem Exp $");
+__RCSID("$NetBSD: battlestar.c,v 1.7 1999/07/21 03:56:53 hubertf Exp $");
#endif
#endif /* not lint */
@@ -66,6 +66,9 @@
char mainbuf[LINELENGTH];
char *next;
+ /* Open the score file then revoke setgid privileges */
+ open_score_file();
+ setregid(getgid(), getgid());
initialize(argc < 2 || strcmp(argv[1], "-r"));
start:
news();
diff -r 1201ef8ae802 -r 9137f0793ac5 games/battlestar/com6.c
--- a/games/battlestar/com6.c Wed Jul 21 03:32:53 1999 +0000
+++ b/games/battlestar/com6.c Wed Jul 21 03:56:53 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: com6.c,v 1.10 1999/02/10 01:36:50 hubertf Exp $ */
+/* $NetBSD: com6.c,v 1.11 1999/07/21 03:56:53 hubertf Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)com6.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: com6.c,v 1.10 1999/02/10 01:36:50 hubertf Exp $");
+__RCSID("$NetBSD: com6.c,v 1.11 1999/07/21 03:56:53 hubertf Exp $");
#endif
#endif /* not lint */
@@ -105,11 +105,20 @@
exit(0);
}
+static FILE *score_fp;
+
+void
+open_score_file()
+{
+ score_fp = fopen(_PATH_SCORE, "a");
+ if (score_fp == NULL)
+ warn("open %s for append", _PATH_SCORE);
+}
+
void
post(ch)
char ch;
{
- FILE *fp;
struct timeval tv;
time_t tvsec;
char *date;
@@ -122,17 +131,16 @@
tvsec = (time_t) tv.tv_sec;
date = ctime(&tvsec);
date[24] = '\0';
- if ((fp = fopen(_PATH_SCORE, "a")) != NULL) {
- fprintf(fp, "%s %8s %c%20s", date, uname, ch, rate());
+ if (score_fp != NULL) {
+ fprintf(score_fp, "%s %8s %c%20s", date, uname, ch, rate());
if (wiz)
- fprintf(fp, " wizard\n");
+ fprintf(score_fp, " wizard\n");
else
if (tempwiz)
- fprintf(fp, " WIZARD!\n");
+ fprintf(score_fp, " WIZARD!\n");
else
- fprintf(fp, "\n");
- } else
- warn("fopen %s", _PATH_SCORE);
+ fprintf(score_fp, "\n");
+ }
sigprocmask(SIG_SETMASK, &osigset, (sigset_t *) 0);
}
diff -r 1201ef8ae802 -r 9137f0793ac5 games/battlestar/extern.h
--- a/games/battlestar/extern.h Wed Jul 21 03:32:53 1999 +0000
+++ b/games/battlestar/extern.h Wed Jul 21 03:56:53 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.10 1999/02/10 01:36:50 hubertf Exp $ */
+/* $NetBSD: extern.h,v 1.11 1999/07/21 03:56:53 hubertf Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -340,6 +340,7 @@
void news __P((void));
void newway __P((int));
void notarget __P((void));
+void open_score_file __P((void));
void parse __P((void));
void post __P((char));
void printobjs __P((void));
Home |
Main Index |
Thread Index |
Old Index