According to theo@ this was mangled, let's see if with mutt it works

Index: canfield/Makefile
===================================================================
RCS file: /cvs/src/games/canfield/canfield/Makefile,v
retrieving revision 1.8
diff -u -p -u -r1.8 Makefile
--- canfield/Makefile   31 May 2002 03:46:35 -0000      1.8
+++ canfield/Makefile   23 Nov 2015 22:06:33 -0000
@@ -6,15 +6,6 @@ MAN=   canfield.6
 DPADD= ${LIBCURSES}
 LDADD= -lcurses
 MLINKS=        canfield.6 cfscores.6
-BINMODE=2555
-
-beforeinstall:
-       @if [ ! -f ${DESTDIR}/var/games/cfscores ]; then \
-           ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m 664 \
-               /dev/null ${DESTDIR}/var/games/cfscores ; \
-       else \
-           true ; \
-       fi

 .include "../../Makefile.inc"
 .include <bsd.prog.mk>
Index: canfield/canfield.6
===================================================================
RCS file: /cvs/src/games/canfield/canfield/canfield.6,v
retrieving revision 1.9
diff -u -p -u -r1.9 canfield.6
--- canfield/canfield.6 26 Sep 2014 21:41:56 -0000      1.9
+++ canfield/canfield.6 23 Nov 2015 22:06:48 -0000
@@ -40,8 +40,6 @@
 .Sh SYNOPSIS
 .Nm canfield
 .Nm cfscores
-.Op Fl a
-.Op Ar username
 .Sh DESCRIPTION
 If you have never played solitaire before, it is recommended
 that you consult a solitaire instruction book.
@@ -101,23 +99,14 @@ that became visible since it was last tu
 Thus the maximum cost of information is $34.
 Playing time is charged at a rate of $1 per minute.
 .Pp
-With no arguments, the program
+The program
 .Nm cfscores
 prints out the current status of your canfield account.
-If a
-.Ar username
-is specified,
-it prints out the status of that user's canfield account.
-If the
-.Fl a
-flag is specified,
-it prints out the canfield accounts for all users that have
-played the game since the database was set up.
 .Sh FILES
 .Bl -tag -width /usr/games/cfscores -compact
 .It Pa /usr/games/cfscores
 the score database printer
-.It Pa /var/games/cfscores
+.It Pa $HOME/cfscores
 the database of scores
 .El
 .Sh AUTHORS
Index: canfield/canfield.c
===================================================================
RCS file: /cvs/src/games/canfield/canfield/canfield.c,v
retrieving revision 1.15
diff -u -p -u -r1.15 canfield.c
--- canfield/canfield.c 5 Nov 2015 23:16:44 -0000       1.15
+++ canfield/canfield.c 23 Nov 2015 22:06:52 -0000
@@ -46,6 +46,7 @@
 #include <ctype.h>
 #include <curses.h>
 #include <fcntl.h>
+#include <limits.h>
 #include <signal.h>
 #include <stdlib.h>
 #include <string.h>
@@ -53,8 +54,6 @@
 #include <time.h>
 #include <unistd.h>

-#include "pathnames.h"
-
 #define        decksize        52
 #define        originrow       0
 #define        origincol       0
@@ -154,7 +153,6 @@ bool mtfdone, Cflag = FALSE;
 #define        BETTINGBOX      2
 #define        NOBOX           3
 int status = INSTRUCTIONBOX;
-int uid;

 /*
  * Basic betting costs
@@ -1379,7 +1377,7 @@ suspend(void)
        move(21, 0);
        refresh();
        if (dbfd != -1) {
-               lseek(dbfd, uid * sizeof(struct betinfo), SEEK_SET);
+               lseek(dbfd, sizeof(struct betinfo), SEEK_SET);
                write(dbfd, (char *)&total, sizeof(total));
        }
        kill(getpid(), SIGTSTP);
@@ -1626,17 +1624,18 @@ void
 initall(void)
 {
        int i;
+       char scorepath[PATH_MAX];

        time(&acctstart);
        initdeck(deck);
-       uid = getuid();
-       if (uid < 0)
-               uid = 0;
-       dbfd = open(_PATH_SCORE, O_RDWR);
-       setegid(getgid());
+       if (!getenv("HOME"))
+               return;
+       snprintf(scorepath, sizeof(scorepath), "%s/%s", getenv("HOME"),
+               "cfscores");
+       dbfd = open(scorepath, O_RDWR | O_CREAT, 0644);
        if (dbfd < 0)
                return;
-       i = lseek(dbfd, uid * sizeof(struct betinfo), SEEK_SET);
+       i = lseek(dbfd, sizeof(struct betinfo), SEEK_SET);
        if (i < 0) {
                close(dbfd);
                dbfd = -1;
@@ -1699,7 +1698,7 @@ cleanup(int dummy)
        status = NOBOX;
        updatebettinginfo();
        if (dbfd != -1) {
-               lseek(dbfd, uid * sizeof(struct betinfo), SEEK_SET);
+               lseek(dbfd, sizeof(struct betinfo), SEEK_SET);
                write(dbfd, (char *)&total, sizeof(total));
                close(dbfd);
        }
@@ -1743,10 +1742,6 @@ main(int argc, char *argv[])
        raw();
        noecho();
        initall();
-
-       /* revoke privs */
-       gid = getgid();
-       setresgid(gid, gid, gid);

        instruct();
        makeboard();
Index: canfield/pathnames.h
===================================================================
RCS file: /cvs/src/games/canfield/canfield/pathnames.h,v
retrieving revision 1.3
diff -u -p -u -r1.3 pathnames.h
--- canfield/pathnames.h        3 Jun 2003 03:01:39 -0000       1.3
+++ canfield/pathnames.h        23 Nov 2015 22:07:01 -0000
@@ -1,36 +0,0 @@
-/*     $OpenBSD: pathnames.h,v 1.3 2003/06/03 03:01:39 millert Exp $   */
-/*     $NetBSD: pathnames.h,v 1.3 1995/03/21 15:08:34 cgd Exp $        */
-
-/*-
- * Copyright (c) 1990, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- *     @(#)pathnames.h 8.1 (Berkeley) 5/31/93
- */
-
-#define        _PATH_SCORE     "/var/games/cfscores"
-
Index: cfscores/cfscores.c
===================================================================
RCS file: /cvs/src/games/canfield/cfscores/cfscores.c,v
retrieving revision 1.15
diff -u -p -u -r1.15 cfscores.c
--- cfscores/cfscores.c 27 Oct 2009 23:59:24 -0000      1.15
+++ cfscores/cfscores.c 23 Nov 2015 22:07:17 -0000
@@ -33,12 +33,12 @@
 #include <sys/types.h>
 #include <err.h>
 #include <fcntl.h>
+#include <limits.h>
 #include <pwd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
-#include "pathnames.h"

 struct betinfo {
        long    hand;           /* cost of dealing hand */
@@ -52,6 +52,7 @@ struct betinfo {
 };

 int dbfd;
+char scorepath[PATH_MAX];

 void   printuser(const struct passwd *, int);

@@ -60,41 +61,19 @@ main(int argc, char *argv[])
 {
        struct passwd *pw;
        uid_t uid;
-       gid_t gid;
-
-       if (argc > 2) {
-               fprintf(stderr, "usage: cfscores [-a] [username]\n");
-               exit(1);
-       }
-       dbfd = open(_PATH_SCORE, O_RDONLY);
+       
+       if (!getenv("HOME"))
+               return;
+       snprintf(scorepath, sizeof(scorepath), "%s/%s", getenv("HOME"),
+                       "cfscores");
+       dbfd = open(scorepath, O_RDONLY);
        if (dbfd < 0)
-               err(2, "%s", _PATH_SCORE);
-
-       /* revoke privs */
-       gid = getgid();
-       setresgid(gid, gid, gid);
+               err(2, "%s", scorepath);

        setpwent();
-       if (argc == 1) {
-               uid = getuid();
-               pw = getpwuid(uid);
-               if (pw == 0) {
-                       printf("You are not listed in the password file?!?\n");
-                       exit(2);
-               }
-               printuser(pw, 1);
-               exit(0);
-       }
-       if (strcmp(argv[1], "-a") == 0) {
-               while ((pw = getpwent()) != 0)
-                       printuser(pw, 0);
-               exit(0);
-       }
-       pw = getpwnam(argv[1]);
-       if (pw == 0) {
-               printf("User %s unknown\n", argv[1]);
-               exit(3);
-       }
+       uid = getuid();
+       pw = getpwuid(uid);
+
        printuser(pw, 1);
        exit(0);
 }
@@ -112,14 +91,14 @@ printuser(const struct passwd *pw, int p
                printf("Bad uid %u\n", pw->pw_uid);
                return;
        }
-       i = lseek(dbfd, pw->pw_uid * sizeof(struct betinfo), SEEK_SET);
+       i = lseek(dbfd, sizeof(struct betinfo), SEEK_SET);
        if (i < 0) {
-               warn("lseek %s", _PATH_SCORE);
+               warn("lseek %s", scorepath);
                return;
        }
        i = read(dbfd, (char *)&total, sizeof(total));
        if (i < 0) {
-               warn("lseek %s", _PATH_SCORE);
+               warn("lseek %s", scorepath);
                return;
        }
        if (i == 0 || total.hand == 0) {
Index: cfscores/Makefile
===================================================================
RCS file: /cvs/src/games/canfield/cfscores/Makefile,v
retrieving revision 1.4
diff -u -p -u -r1.4 Makefile
--- cfscores/Makefile   31 May 2002 03:46:35 -0000      1.4
+++ cfscores/Makefile   23 Nov 2015 22:07:26 -0000
@@ -4,7 +4,6 @@
 PROG=  cfscores
 CFLAGS+=-I${.CURDIR}/../canfield
 NOMAN= noman
-BINMODE=2555

 .include "../../Makefile.inc"
 .include <bsd.prog.mk>

Reply via email to