diff options
author | Andrey A. Chernov <ache@FreeBSD.org> | 1997-09-24 07:10:47 +0000 |
---|---|---|
committer | Andrey A. Chernov <ache@FreeBSD.org> | 1997-09-24 07:10:47 +0000 |
commit | f5d548e45a4951a2804fe3774ce2797cb0152deb (patch) | |
tree | bd0bd358a443945134808b0469a9b39a94ce7832 /games/cribbage | |
parent | 7b89fc8e074d94efd84e3f48b4fe6e7fd3c8c733 (diff) | |
download | src-f5d548e45a4951a2804fe3774ce2797cb0152deb.tar.gz src-f5d548e45a4951a2804fe3774ce2797cb0152deb.zip |
Do not swap uids on log writting but open it first, then revoke
Simplify revoke
Notes
Notes:
svn path=/head/; revision=29785
Diffstat (limited to 'games/cribbage')
-rw-r--r-- | games/cribbage/crib.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/games/cribbage/crib.c b/games/cribbage/crib.c index bc55c116aaeb..4f7bf5c2b3c2 100644 --- a/games/cribbage/crib.c +++ b/games/cribbage/crib.c @@ -46,6 +46,7 @@ static char sccsid[] = "@(#)crib.c 8.1 (Berkeley) 5/31/93"; #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <stdio.h> #include "deck.h" #include "cribbage.h" @@ -60,10 +61,11 @@ main(argc, argv) BOOLEAN playing; FILE *f; int ch; - gid_t egid; - egid = getegid(); - setegid(getgid()); + f = fopen(_PATH_LOG, "a"); + + /* revoke */ + setgid(getgid()); while ((ch = getopt(argc, argv, "eqr")) != EOF) switch (ch) { @@ -124,13 +126,11 @@ main(argc, argv) playing = (getuchar() == 'Y'); } while (playing); - setegid(egid); - if (f = fopen(_PATH_LOG, "a")) { + if (f != NULL) { (void)fprintf(f, "%s: won %5.5d, lost %5.5d\n", getlogin(), cgames, pgames); (void) fclose(f); } - setegid(getgid()); bye(); if (!f) { (void) fprintf(stderr, "\ncribbage: can't open %s.\n", |