Subject: misc/731: fix for larn save-game bug
To: None <gnats-admin@NetBSD.ORG>
From: None <Havard.Eidnes@runit.sintef.no>
List: netbsd-bugs
Date: 01/13/1995 13:05:08
>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 (Misc Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Jan 13 13:05:04 1995
>Originator: Havard Eidnes
>Organization:
" Disorganized..."
>Release: 1.0
>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();
>Audit-Trail:
>Unformatted: