From: guenther Date: Sun, 20 Jul 2014 04:07:16 +0000 (+0000) Subject: The manpage claims the -a option uses getlogin(2), so do so. Also, X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e6283523f873c9dcf718d9266fb1d43c630be8a4;p=openbsd 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 --- 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