NetBSD Problem Report #731

From gnats  Fri Jan 13 13:00:17 1995
Received: from pain.lcs.mit.edu (pain.lcs.mit.edu [128.52.46.239]) by sun-lamp.cs.berkeley.edu (8.6.9/8.6.9) with ESMTP id NAA00561 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Fri, 13 Jan 1995 13:00:14 -0800
Message-Id: <199501132054.VAA00305@kolibri.runit.sintef.no>
Date: Fri, 13 Jan 1995 21:54:44 +0100
From: Havard.Eidnes@runit.sintef.no
Reply-To: Havard.Eidnes@runit.sintef.no
To: gnats-bugs@NetBSD.ORG
Subject: fix for larn save-game bug
X-Send-Pr-Version: 3.2

>Number:         731
>Category:       misc
>Synopsis:       larn tries to save in home dir with euid "games"
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jan 13 13:05:04 +0000 1995
>Closed-Date:    Tue May 21 23:18:16 +0000 1996
>Last-Modified:  Tue May 21 23:20:16 +0000 1996
>Originator:     Havard Eidnes
>Release:        1.0
>Organization:
"	Disorganized..."
>Environment:
System: NetBSD kolibri.runit.sintef.no 1.0 NetBSD 1.0 (FOSSEKALL) #26: Mon Jan 2 15:02:13 MET 1995 root@kolibri.runit.sintef.no:/usr/src/sys/arch/i386/compile/FOSSEKALL i386


>Description:
	larn tries to save game in home dir while holding euid "games",
	thus failes
>How-To-Repeat:
	Trivial
>Fix:
	The following should fix it.

*** diag.c.orig	Fri Jan 13 21:12:20 1995
--- diag.c	Sun Dec 25 01:39:29 1994
***************
*** 156,159 ****
--- 156,165 ----
  	register struct sphere *sp;
  	struct stat statbuf;
+ 	uid_t eff, real;
+ 	
+ 	eff = geteuid();
+ 	real = getuid();
+ 	seteuid(real); /* So that we can create user's save file */
+ 
  	nosignal=1;  lflush();	savelevel();
  	ointerest();
***************
*** 193,196 ****
--- 199,203 ----
  #endif VT100
  	lcreat((char*)0);  nosignal=0;
+ 	seteuid(eff); /* Revert to old effective uid */
  	return(0);
  	}
***************
*** 261,265 ****
  		lcreat((char*)0);
  		}
! 	else if (unlink(fname) < 0) fcheat(); /* can't unlink save file */
  /*	for the greedy cheater checker	*/
  	for (k=0; k<6; k++) if (c[k]>99) greedy();
--- 268,280 ----
  		lcreat((char*)0);
  		}
! 	else {
! 		uid_t real, eff;
! 
! 		real = getuid();
! 		eff = geteuid();
! 		seteuid(real);
! 		if (unlink(fname) < 0) fcheat(); /* can't unlink save file */
! 		seteuid(eff);
! 	}
  /*	for the greedy cheater checker	*/
  	for (k=0; k<6; k++) if (c[k]>99) greedy();
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: mrg 
State-Changed-When: Tue May 21 19:18:16 EDT 1996 
State-Changed-Why:  
larn gives up setuid-ness at the top of main() now. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.