summaryrefslogtreecommitdiffstats
path: root/games
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1997-09-24 07:10:47 +0000
committerache <ache@FreeBSD.org>1997-09-24 07:10:47 +0000
commit92a326af9bfd0b81b2fdf26af11118a8ec31f857 (patch)
tree39f88722cdde3eebf9c0ec434f9a38f4bf4790da /games
parentac34d7a57248486573bc587b412cba9fd24abc22 (diff)
downloadFreeBSD-src-92a326af9bfd0b81b2fdf26af11118a8ec31f857.zip
FreeBSD-src-92a326af9bfd0b81b2fdf26af11118a8ec31f857.tar.gz
Do not swap uids on log writting but open it first, then revoke
Simplify revoke
Diffstat (limited to 'games')
-rw-r--r--games/cribbage/crib.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/games/cribbage/crib.c b/games/cribbage/crib.c
index bc55c11..4f7bf5c 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",
OpenPOWER on IntegriCloud