Drop setgid privileges early. Derived from OpenBSD and sent in as PR 5970
by Joseph Myers <jsm28@cam.ac.uk>.
This commit is contained in:
parent
01ec1d5609
commit
054e79fedd
@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
|
||||
#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 @@ main(argc, argv)
|
||||
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();
|
||||
|
@ -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 @@ live()
|
||||
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 @@ post(ch)
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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 murder __P((void));
|
||||
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));
|
||||
|
Loading…
Reference in New Issue
Block a user