From e6283523f873c9dcf718d9266fb1d43c630be8a4 Mon Sep 17 00:00:00 2001 From: guenther Date: Sun, 20 Jul 2014 04:07:16 +0000 Subject: [PATCH] The manpage claims the -a option uses getlogin(2), so do so. Also, ignore its value if it returns a user that doesn't exit --- usr.bin/telnet/commands.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c index e9fc0556a51..37c6e1eb877 100644 --- a/usr.bin/telnet/commands.c +++ b/usr.bin/telnet/commands.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commands.c,v 1.57 2014/07/20 04:00:47 guenther Exp $ */ +/* $OpenBSD: commands.c,v 1.58 2014/07/20 04:07:16 guenther Exp $ */ /* $NetBSD: commands.c,v 1.14 1996/03/24 22:03:48 jtk Exp $ */ /* @@ -2088,9 +2088,9 @@ tn(argc, argv) if (autologin && user == NULL) { struct passwd *pw; - user = getenv("USER"); + user = getlogin(); if (user == NULL || - ((pw = getpwnam(user)) && pw->pw_uid != getuid())) { + (pw = getpwnam(user)) == NULL || pw->pw_uid != getuid()) { if ((pw = getpwuid(getuid())) != NULL) user = pw->pw_name; else -- 2.20.1