summaryrefslogtreecommitdiff
path: root/games/robots
diff options
context:
space:
mode:
authortb <tb@cvs.openbsd.org>2015-12-04 16:40:10 +0000
committertb <tb@cvs.openbsd.org>2015-12-04 16:40:10 +0000
commit935e8322eb7a8b0ee7bbee7c6dbe09cdf3d08500 (patch)
tree0c7656cb80599cddc18a8801638604c871eeba17 /games/robots
parent7c02d3f03bb3cae0c0e9d87263afbeb92185eb37 (diff)
Drop pledge("getpw") and pwd.h and use the now usual
LOGNAME -> USER -> getlogin() -> ??? fallback in the score file, as requested by tedu@ Man page bits adapted from jmc@'s tweaks to snake.6
Diffstat (limited to 'games/robots')
-rw-r--r--games/robots/main.c4
-rw-r--r--games/robots/robots.611
-rw-r--r--games/robots/robots.h3
-rw-r--r--games/robots/score.c16
4 files changed, 22 insertions, 12 deletions
diff --git a/games/robots/main.c b/games/robots/main.c
index 7e1224eb007..3093deb4a6d 100644
--- a/games/robots/main.c
+++ b/games/robots/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.21 2015/11/29 15:13:19 tb Exp $ */
+/* $OpenBSD: main.c,v 1.22 2015/12/04 16:40:09 tb Exp $ */
/* $NetBSD: main.c,v 1.5 1995/04/22 10:08:54 cgd Exp $ */
/*
@@ -54,7 +54,7 @@ main(int ac, char *av[])
char *sp;
#endif
- if (pledge("stdio rpath wpath cpath getpw tty", NULL) == -1)
+ if (pledge("stdio rpath wpath cpath tty", NULL) == -1)
err(1, "pledge");
home = getenv("HOME");
diff --git a/games/robots/robots.6 b/games/robots/robots.6
index 2192113314c..2f5416ca9e5 100644
--- a/games/robots/robots.6
+++ b/games/robots/robots.6
@@ -1,4 +1,4 @@
-.\" $OpenBSD: robots.6,v 1.14 2015/11/29 15:13:19 tb Exp $
+.\" $OpenBSD: robots.6,v 1.15 2015/12/04 16:40:09 tb Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" @(#)robots.6 8.1 (Berkeley) 5/31/93
.\"
-.Dd $Mdocdate: November 29 2015 $
+.Dd $Mdocdate: December 4 2015 $
.Dt ROBOTS 6
.Os
.Sh NAME
@@ -136,8 +136,13 @@ Teleport automatically when you have no other option.
This is a little disconcerting until you get used to it, and then it is
very nice.
.El
+.Sh ENVIRONMENT
+.Bl -tag -width $HOME/.robots.scores
+.It Ev LOGNAME
+Name displayed in high score file.
+.El
.Sh FILES
-.Bl -tag -width $HOME/.robots.scores -compact
+.Bl -tag -width $HOME/.robots.scores
.It Pa $HOME/.robots.scores
the score file
.El
diff --git a/games/robots/robots.h b/games/robots/robots.h
index 3a4e2b66bb2..1a9b0ca289b 100644
--- a/games/robots/robots.h
+++ b/games/robots/robots.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: robots.h,v 1.10 2015/11/29 15:13:19 tb Exp $ */
+/* $OpenBSD: robots.h,v 1.11 2015/12/04 16:40:09 tb Exp $ */
/* $NetBSD: robots.h,v 1.5 1995/04/24 12:24:54 cgd Exp $ */
/*
@@ -40,7 +40,6 @@
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
-#include <pwd.h>
#include <signal.h>
#include <string.h>
#include <stdlib.h>
diff --git a/games/robots/score.c b/games/robots/score.c
index c7dbe235fd1..8eeeb06d943 100644
--- a/games/robots/score.c
+++ b/games/robots/score.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: score.c,v 1.12 2015/11/29 15:13:19 tb Exp $ */
+/* $OpenBSD: score.c,v 1.13 2015/12/04 16:40:09 tb Exp $ */
/* $NetBSD: score.c,v 1.3 1995/04/22 10:09:12 cgd Exp $ */
/*
@@ -129,11 +129,17 @@ score(int score_wfd)
void
set_name(SCORE *scp)
{
- struct passwd *pp;
+ const char *name;
- if ((pp = getpwuid(scp->s_uid)) == NULL)
- pp->pw_name = "???";
- strlcpy(scp->s_name, pp->pw_name, LOGIN_NAME_MAX);
+ name = getenv("LOGNAME");
+ if (name == NULL || *name == '\0')
+ name = getenv("USER");
+ if (name == NULL || *name == '\0')
+ name = getlogin();
+ if (name == NULL || *name == '\0')
+ name = " ???";
+
+ strlcpy(scp->s_name, name, LOGIN_NAME_MAX);
}
/*