From 8b4b693dbef757e2287066fa288d9b8d79a4e39a Mon Sep 17 00:00:00 2001 From: christos Date: Sun, 14 Nov 2004 18:07:56 +0000 Subject: [PATCH] Pass -a [srrvis'd struct sockaddr] to login, so that login can record the address where we have logged in from. --- libexec/telnetd/sys_term.c | 25 ++++++++++++++++--------- libexec/telnetd/telnetd.c | 6 +++--- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/libexec/telnetd/sys_term.c b/libexec/telnetd/sys_term.c index 4565b7dd7044..f20081fa25fe 100644 --- a/libexec/telnetd/sys_term.c +++ b/libexec/telnetd/sys_term.c @@ -1,4 +1,4 @@ -/* $NetBSD: sys_term.c,v 1.40 2003/09/19 05:54:46 itojun Exp $ */ +/* $NetBSD: sys_term.c,v 1.41 2004/11/14 18:07:56 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)sys_term.c 8.4+1 (Berkeley) 5/30/95"; #else -__RCSID("$NetBSD: sys_term.c,v 1.40 2003/09/19 05:54:46 itojun Exp $"); +__RCSID("$NetBSD: sys_term.c,v 1.41 2004/11/14 18:07:56 christos Exp $"); #endif #endif /* not lint */ @@ -42,6 +42,7 @@ __RCSID("$NetBSD: sys_term.c,v 1.40 2003/09/19 05:54:46 itojun Exp $"); #include "pathnames.h" #include +#include #include @@ -611,24 +612,30 @@ start_login(host, autologin, name) char defstrs[TABBUFSIZ]; #undef TABBUFSIZ const char *loginprog = NULL; - + extern struct sockaddr_storage from; + char buf[sizeof(from) * 4 + 1]; scrub_env(); /* + * -a : pass on the address of the host. * -h : pass on name of host. - * WARNING: -h is accepted by login if and only if - * getuid() == 0. + * WARNING: -h and -a are accepted by login + * if and only if getuid() == 0. * -p : don't clobber the environment (so terminal type stays set). * * -f : force this login, he has already been authenticated */ argv = addarg(0, "login"); - { - argv = addarg(argv, "-h"); - argv = addarg(argv, host); - } + argv = addarg(argv, "-a"); + (void)strvisx(buf, (const char *)(const void *)&from, sizeof(from), + VIS_WHITE); + argv = addarg(argv, buf); + + argv = addarg(argv, "-h"); + argv = addarg(argv, host); + argv = addarg(argv, "-p"); #ifdef LINEMODE /* diff --git a/libexec/telnetd/telnetd.c b/libexec/telnetd/telnetd.c index 737e0ccc8192..078a47a57876 100644 --- a/libexec/telnetd/telnetd.c +++ b/libexec/telnetd/telnetd.c @@ -1,4 +1,4 @@ -/* $NetBSD: telnetd.c,v 1.43 2003/08/07 09:46:52 agc Exp $ */ +/* $NetBSD: telnetd.c,v 1.44 2004/11/14 18:07:56 christos Exp $ */ /* * Copyright (C) 1997 and 1998 WIDE Project. @@ -65,7 +65,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\ #if 0 static char sccsid[] = "@(#)telnetd.c 8.4 (Berkeley) 5/30/95"; #else -__RCSID("$NetBSD: telnetd.c,v 1.43 2003/08/07 09:46:52 agc Exp $"); +__RCSID("$NetBSD: telnetd.c,v 1.44 2004/11/14 18:07:56 christos Exp $"); #endif #endif /* not lint */ @@ -160,13 +160,13 @@ char valid_opts[] = { }; int family = AF_INET; +struct sockaddr_storage from; int main(argc, argv) int argc; char *argv[]; { - struct sockaddr_storage from; int on = 1, fromlen; register int ch; #if defined(IPPROTO_IP) && defined(IP_TOS)