summaryrefslogtreecommitdiff
path: root/games/hack/hack.main.c
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2005-05-01 02:43:13 +0000
committerDamien Miller <djm@cvs.openbsd.org>2005-05-01 02:43:13 +0000
commitc95bccb936556e0fd39a029d1dcd998c0691187d (patch)
treebf587d52b86dbbf6c51b4dc5f672f56e62222f50 /games/hack/hack.main.c
parentddeaac82999e25819a7b555fb4af8b901a6a5aab (diff)
use setresgid() to drop privs, it is simply a better and less ambiguous API;
ok deraadt@ and millert@ a while ago, more to come
Diffstat (limited to 'games/hack/hack.main.c')
-rw-r--r--games/hack/hack.main.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/games/hack/hack.main.c b/games/hack/hack.main.c
index d240035272e..5f69d9365c3 100644
--- a/games/hack/hack.main.c
+++ b/games/hack/hack.main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hack.main.c,v 1.13 2003/07/06 02:07:45 avsm Exp $ */
+/* $OpenBSD: hack.main.c,v 1.14 2005/05/01 02:43:12 djm Exp $ */
/*
* Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica,
@@ -62,7 +62,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: hack.main.c,v 1.13 2003/07/06 02:07:45 avsm Exp $";
+static const char rcsid[] = "$OpenBSD: hack.main.c,v 1.14 2005/05/01 02:43:12 djm Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -519,6 +519,7 @@ impossible(char *s, ...)
static void
chdirx(char *dir, boolean wr)
{
+ gid_t gid;
#ifdef SECURE
if(dir /* User specified directory? */
@@ -526,9 +527,9 @@ chdirx(char *dir, boolean wr)
&& strcmp(dir, HACKDIR) /* and not the default? */
#endif
) {
- /* revoke */
- setegid(getgid());
- setgid(getgid());
+ /* revoke privs */
+ gid = getgid();
+ setresgid(gid, gid, gid);
}
#endif