From 92a326af9bfd0b81b2fdf26af11118a8ec31f857 Mon Sep 17 00:00:00 2001 From: ache Date: Wed, 24 Sep 1997 07:10:47 +0000 Subject: [PATCH] Do not swap uids on log writting but open it first, then revoke Simplify revoke --- games/cribbage/crib.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/games/cribbage/crib.c b/games/cribbage/crib.c index bc55c116aae..4f7bf5c2b3c 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 #include #include +#include #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", -- 2.45.2