summaryrefslogtreecommitdiffstats
path: root/quiz
diff options
context:
space:
mode:
authorjsm <jsm@NetBSD.org>1999-09-12 09:02:20 +0000
committerjsm <jsm@NetBSD.org>1999-09-12 09:02:20 +0000
commit2f593094f0c4f828fd81a3b052ee426135135694 (patch)
tree7b98927c7e61fffdc04daa44d0d99f2316fa1a47 /quiz
parentb8724a0a95054da51b0a8bfca19d6d2b2662609f (diff)
downloadbsdgames-darwin-2f593094f0c4f828fd81a3b052ee426135135694.tar.gz
bsdgames-darwin-2f593094f0c4f828fd81a3b052ee426135135694.tar.zst
bsdgames-darwin-2f593094f0c4f828fd81a3b052ee426135135694.zip
Security improvements for games (largely from or inspired by OpenBSD).
Games which run setgid from dm, but don't need to, should drop their privileges at startup. Games which have a scorefile should open it at startup, then drop all privileges leaving just the open writable file descriptor. If the game can invoke subprocesses, this should be made close-on-exec. Games with scorefiles should make sure they do not get a file descriptor < 3. (Otherwise, they could get confused and corrupt the scorefile when using stdin, stdout or stderr.) Some old setuid revokes from the days of setuid games change into gid revokes.
Diffstat (limited to 'quiz')
-rw-r--r--quiz/quiz.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/quiz/quiz.c b/quiz/quiz.c
index 96ede113..aec0ae78 100644
--- a/quiz/quiz.c
+++ b/quiz/quiz.c
@@ -1,4 +1,4 @@
-/* $NetBSD: quiz.c,v 1.14 1999/09/08 21:17:56 jsm Exp $ */
+/* $NetBSD: quiz.c,v 1.15 1999/09/12 09:02:22 jsm Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\
#if 0
static char sccsid[] = "@(#)quiz.c 8.3 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: quiz.c,v 1.14 1999/09/08 21:17:56 jsm Exp $");
+__RCSID("$NetBSD: quiz.c,v 1.15 1999/09/12 09:02:22 jsm Exp $");
#endif
#endif /* not lint */
@@ -88,6 +88,9 @@ main(argc, argv)
int ch;
const char *indexfile;
+ /* Revoke setgid privileges */
+ setregid(getgid(), getgid());
+
indexfile = _PATH_QUIZIDX;
while ((ch = getopt(argc, argv, "i:t")) != -1)
switch(ch) {