From 2f593094f0c4f828fd81a3b052ee426135135694 Mon Sep 17 00:00:00 2001 From: jsm Date: Sun, 12 Sep 1999 09:02:20 +0000 Subject: 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. --- fish/fish.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'fish/fish.c') diff --git a/fish/fish.c b/fish/fish.c index 1ce39130..b522a7b4 100644 --- a/fish/fish.c +++ b/fish/fish.c @@ -1,4 +1,4 @@ -/* $NetBSD: fish.c,v 1.9 1999/09/08 21:17:48 jsm Exp $ */ +/* $NetBSD: fish.c,v 1.10 1999/09/12 09:02:21 jsm Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 1993\n\ #if 0 static char sccsid[] = "@(#)fish.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: fish.c,v 1.9 1999/09/08 21:17:48 jsm Exp $"); +__RCSID("$NetBSD: fish.c,v 1.10 1999/09/12 09:02:21 jsm Exp $"); #endif #endif /* not lint */ @@ -104,7 +104,8 @@ main(argc, argv) { int ch, move; - setgid(getgid()); + /* Revoke setgid privileges */ + setregid(getgid(), getgid()); while ((ch = getopt(argc, argv, "p")) != -1) switch(ch) { -- cgit v1.2.3