diff options
-rw-r--r-- | games/battlestar/Makefile | 9 | ||||
-rw-r--r-- | games/battlestar/battlestar.c | 3 | ||||
-rw-r--r-- | games/battlestar/com6.c | 28 |
3 files changed, 29 insertions, 11 deletions
diff --git a/games/battlestar/Makefile b/games/battlestar/Makefile index e0ca3f01722..b046130e616 100644 --- a/games/battlestar/Makefile +++ b/games/battlestar/Makefile @@ -9,5 +9,14 @@ MAN= battlestar.6 DPADD= ${LIBCURSES} ${LIBTERMLIB} LDADD= -lcurses -ltermlib HIDEGAME=hidegame +BINGRP= games + +beforeinstall: + @if [ ! -f ${DESTDIR}/var/games/battlestar.log ]; then \ + ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 664 \ + /dev/null ${DESTDIR}/var/games/battlestar.log ; \ + else \ + true ; \ + fi .include <bsd.prog.mk> diff --git a/games/battlestar/battlestar.c b/games/battlestar/battlestar.c index b97e89ca19c..bb809f4b3a9 100644 --- a/games/battlestar/battlestar.c +++ b/games/battlestar/battlestar.c @@ -63,6 +63,9 @@ char **argv; char mainbuf[LINELENGTH]; char *next; + open_score_file(); + + /* revoke privs. */ egid = getegid(); setegid(getgid()); diff --git a/games/battlestar/com6.c b/games/battlestar/com6.c index 9c6dcfb3084..f13cd2b2fb7 100644 --- a/games/battlestar/com6.c +++ b/games/battlestar/com6.c @@ -95,10 +95,17 @@ live() exit(0); } +static FILE *score_fp; + +open_score_file() +{ + if ((score_fp = fopen(_PATH_SCORE,"a")) == NULL) + perror(_PATH_SCORE); +} + post(ch) char ch; { - FILE *fp; struct timeval tv; char *date, *ctime(); sigset_t sigset, osigset; @@ -109,16 +116,15 @@ char ch; gettimeofday(&tv, (struct timezone *)0); /* can't call time */ date = ctime(&tv.tv_sec); date[24] = '\0'; - if (fp = fopen(_PATH_SCORE,"a")) { - fprintf(fp, "%s %8s %c%20s", date, uname, ch, rate()); - if (wiz) - fprintf(fp, " wizard\n"); - else if (tempwiz) - fprintf(fp, " WIZARD!\n"); - else - fprintf(fp, "\n"); - } else - perror(_PATH_SCORE); + + fprintf(score_fp, "%s %8s %c%20s", date, uname, ch, rate()); + if (wiz) + fprintf(score_fp, " wizard\n"); + else if (tempwiz) + fprintf(score_fp, " WIZARD!\n"); + else + fprintf(score_fp, "\n"); + sigprocmask(SIG_SETMASK, &osigset, (sigset_t *)0); } |