Subject: bin/8024: [PATCH] Backgammon gid revoke
To: None <gnats-bugs@gnats.netbsd.org>
From: Joseph Myers <jsm28@cam.ac.uk>
List: netbsd-bugs
Date: 07/18/1999 01:35:50
>Number:         8024
>Category:       bin
>Synopsis:       [PATCH] Backgammon gid revoke
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 18 01:35:00 1999
>Last-Modified:
>Originator:     Joseph S. Myers
>Organization:
Trinity College, University of Cambridge, UK
>Release:        NetBSD-current of 1999-07-16
>Environment:
[
System: Linux decomino 2.2.10 #1 Mon Jun 14 07:48:53 UTC 1999 i686 unknown
Architecture: i686
]
>Description:

As in previously sent patches: backgammon(6) does not need setgid
games privileges from dm, so should revoke them on startup.

If this patch is accepted, bin/5945 can also be closed.

>How-To-Repeat:

>Fix:

diff -ruN backgammon/backgammon/main.c backgammon+/backgammon/main.c
--- backgammon/backgammon/main.c	Fri Jul 16 11:02:54 1999
+++ backgammon+/backgammon/main.c	Sun Jul 18 07:33:53 1999
@@ -99,6 +99,9 @@
 	char    c;		/* non-descript character storage */
 	long    t;		/* time for random num generator */
 
+	/* revoke setgid privileges */
+	setregid(getgid(), getgid());
+
 	/* initialization */
 	bflag = 2;		/* default no board */
 	signal(SIGINT, getout);	/* trap interrupts */
diff -ruN backgammon/teachgammon/teach.c backgammon+/teachgammon/teach.c
--- backgammon/teachgammon/teach.c	Thu Feb 11 12:06:27 1999
+++ backgammon+/teachgammon/teach.c	Sun Jul 18 07:35:02 1999
@@ -72,6 +72,9 @@
 {
 	int     i;
 
+	/* revoke setgid privileges */
+	setregid(getgid(), getgid());
+
 	signal(SIGINT, getout);
 	if (tcgetattr(0, &old) == -1)	/* get old tty mode */
 		errexit("teachgammon(gtty)");
>Audit-Trail:
>Unformatted: