Subject: Re: strange w(1) output ?
To: None <current-users@NetBSD.org>
From: Peter Postma <peter@pointless.nl>
List: current-users
Date: 07/14/2004 17:56:23
--0OAP2g/MAC+5xKAE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Tue, Jul 06, 2004 at 11:23:19AM +0900, enami tsugutomo wrote:
> login(1) exec'ed by rlogind(8) can't record sockaddr since stdin isn't
> a socket. sshd(8) truncates the addr up to sizoef(sockaddr).
>
Ok, thanks for explaining this.
So why don't we fix sshd(8)? (see attachment). Are there any reasons
for not applying this patch?
--
Peter Postma
--0OAP2g/MAC+5xKAE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="ssh.diff"
Index: monitor.c
===================================================================
RCS file: /cvsroot/src/crypto/dist/ssh/monitor.c,v
retrieving revision 1.15
diff -u -r1.15 monitor.c
--- monitor.c 24 Jul 2003 15:31:53 -0000 1.15
+++ monitor.c 14 Jul 2004 15:49:34 -0000
@@ -1000,7 +1000,7 @@
/* Record that there was a login on that tty from the remote host. */
record_login(s->pid, s->tty, pw->pw_name, pw->pw_uid,
get_remote_name_or_ip(utmp_len, options.verify_reverse_mapping),
- (struct sockaddr *)&from, fromlen);
+ &from);
}
static void
Index: session.c
===================================================================
RCS file: /cvsroot/src/crypto/dist/ssh/session.c,v
retrieving revision 1.35
diff -u -r1.35 session.c
--- session.c 17 Sep 2003 23:19:02 -0000 1.35
+++ session.c 14 Jul 2004 15:49:35 -0000
@@ -664,8 +664,7 @@
if (!use_privsep)
record_login(pid, s->tty, pw->pw_name, pw->pw_uid,
get_remote_name_or_ip(utmp_len,
- options.verify_reverse_mapping),
- (struct sockaddr *)&from, fromlen);
+ options.verify_reverse_mapping), &from);
if (check_quietlogin(s, command))
return;
Index: sshlogin.c
===================================================================
RCS file: /cvsroot/src/crypto/dist/ssh/sshlogin.c,v
retrieving revision 1.12
diff -u -r1.12 sshlogin.c
--- sshlogin.c 26 Aug 2003 16:48:34 -0000 1.12
+++ sshlogin.c 14 Jul 2004 15:49:35 -0000
@@ -106,7 +106,7 @@
*/
void
record_login(pid_t pid, const char *ttyname, const char *user, uid_t uid,
- const char *host, struct sockaddr * addr, socklen_t addrlen)
+ const char *host, struct sockaddr_storage *addr)
{
#if defined(SUPPORT_UTMP) || defined(SUPPORT_UTMPX)
int fd;
@@ -173,7 +173,6 @@
sizeof(ux.ut_id));
} else
strncpy(ux.ut_id, ttyname, sizeof(ux.ut_id));
- /* XXX: It would be better if we had sockaddr_storage here */
memcpy(&ux.ut_ss, addr, sizeof(*addr));
if (pututxline(&ux) == NULL)
logit("could not add utmpx line: %.100s",
Index: sshlogin.h
===================================================================
RCS file: /cvsroot/src/crypto/dist/ssh/sshlogin.h,v
retrieving revision 1.3
diff -u -r1.3 sshlogin.h
--- sshlogin.h 1 Oct 2002 14:07:48 -0000 1.3
+++ sshlogin.h 14 Jul 2004 15:49:35 -0000
@@ -17,7 +17,7 @@
void
record_login(pid_t, const char *, const char *, uid_t,
- const char *, struct sockaddr *, socklen_t);
+ const char *, struct sockaddr_storage *);
void record_logout(pid_t, const char *);
u_long get_last_login_time(uid_t, const char *, char *, u_int);
--0OAP2g/MAC+5xKAE--