diff options
| author | jsm <jsm@NetBSD.org> | 2000-02-09 22:27:55 +0000 |
|---|---|---|
| committer | jsm <jsm@NetBSD.org> | 2000-02-09 22:27:55 +0000 |
| commit | 6a2a60db41cc5b3db833740e9381e58f5270a775 (patch) | |
| tree | 2437ba95f91b7f0cdaa57157b4588f68a0e652f4 /sail/main.c | |
| parent | dc6fb5dc49807bdfab1b64b687522b76a6492011 (diff) | |
| download | bsdgames-darwin-6a2a60db41cc5b3db833740e9381e58f5270a775.tar.gz bsdgames-darwin-6a2a60db41cc5b3db833740e9381e58f5270a775.zip | |
Fix insecure /tmp usage in sail.
Essentially concludes the merge into NetBSD of those changes in the
Linux port of the NetBSD games which it is fairly clear to me should
be so merged.
Diffstat (limited to 'sail/main.c')
| -rw-r--r-- | sail/main.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/sail/main.c b/sail/main.c index d4a9c6b1..1808be6c 100644 --- a/sail/main.c +++ b/sail/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.6 1997/10/13 21:03:55 christos Exp $ */ +/* $NetBSD: main.c,v 1.7 2000/02/09 22:27:56 jsm Exp $ */ /* * Copyright (c) 1983, 1993 @@ -43,11 +43,12 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\ #if 0 static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: main.c,v 1.6 1997/10/13 21:03:55 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.7 2000/02/09 22:27:56 jsm Exp $"); #endif #endif /* not lint */ #include "extern.h" +#include <fcntl.h> #include <unistd.h> #include <stdlib.h> #include <string.h> @@ -62,9 +63,18 @@ main(argc, argv) { char *p; int i; + int fd; + + gid = getgid(); + egid = getegid(); + setegid(gid); + + fd = open("/dev/null", O_RDONLY); + if (fd < 3) + exit(1); + close(fd); (void) srand(getpid()); - issetuid = getuid() != geteuid(); if ((p = strrchr(*argv, '/')) != NULL) p++; else |
