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. --- gomoku/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gomoku/main.c') diff --git a/gomoku/main.c b/gomoku/main.c index e7f0448f..7b8fc674 100644 --- a/gomoku/main.c +++ b/gomoku/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.7 1999/09/08 21:45:27 jsm Exp $ */ +/* $NetBSD: main.c,v 1.8 1999/09/12 09:02:21 jsm Exp $ */ /* * Copyright (c) 1994 @@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1994\n\ #if 0 static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: main.c,v 1.7 1999/09/08 21:45:27 jsm Exp $"); +__RCSID("$NetBSD: main.c,v 1.8 1999/09/12 09:02:21 jsm Exp $"); #endif #endif /* not lint */ @@ -98,6 +98,9 @@ main(argc, argv) "%3d %-6s" }; + /* Revoke setgid privileges */ + setregid(getgid(), getgid()); + color = curmove = 0; prog = strrchr(argv[0], '/'); -- cgit v1.2.3