1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00

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
This commit is contained in:
tb 2015-12-04 16:40:09 +00:00
parent 42c5e26a20
commit 87b7d5d4a1
4 changed files with 22 additions and 12 deletions

View File

@ -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");

View File

@ -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

View File

@ -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>

View File

@ -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);
}
/*