sshd didn't handle actual size of struct sockaddr correctly,
and did copy it as long as just size of struct sockaddr. So, If connection is via IPv6, sshd didn't log hostname into utmp correctly. This problem occured only under FreeBSD because of our hack. However, this is potential problem of OpenSSH-portable, and they agreed to fix this. Though, there is no fixed version of OpenSSH-portable available yet, since this problem is serious for IPv6 users, I commit the fix. Reported by: many people Reviewed by: current@ and stable@ (no objection) MFC after: 3 days
This commit is contained in:
parent
c3e3619908
commit
7ac3260308
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=103134
@ -1113,8 +1113,8 @@ mm_record_login(Session *s, struct passwd *pw)
|
||||
* the address be 0.0.0.0.
|
||||
*/
|
||||
memset(&from, 0, sizeof(from));
|
||||
fromlen = sizeof(from);
|
||||
if (packet_connection_is_on_socket()) {
|
||||
fromlen = sizeof(from);
|
||||
if (getpeername(packet_get_connection_in(),
|
||||
(struct sockaddr *) & from, &fromlen) < 0) {
|
||||
debug("getpeername: %.100s", strerror(errno));
|
||||
@ -1124,7 +1124,7 @@ mm_record_login(Session *s, struct passwd *pw)
|
||||
/* 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);
|
||||
(struct sockaddr *)&from, fromlen);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -669,8 +669,8 @@ do_pre_login(Session *s)
|
||||
* the address be 0.0.0.0.
|
||||
*/
|
||||
memset(&from, 0, sizeof(from));
|
||||
fromlen = sizeof(from);
|
||||
if (packet_connection_is_on_socket()) {
|
||||
fromlen = sizeof(from);
|
||||
if (getpeername(packet_get_connection_in(),
|
||||
(struct sockaddr *) & from, &fromlen) < 0) {
|
||||
debug("getpeername: %.100s", strerror(errno));
|
||||
@ -680,7 +680,7 @@ do_pre_login(Session *s)
|
||||
|
||||
record_utmp_only(pid, s->tty, s->pw->pw_name,
|
||||
get_remote_name_or_ip(utmp_len, options.verify_reverse_mapping),
|
||||
(struct sockaddr *)&from);
|
||||
(struct sockaddr *)&from, fromlen);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -721,8 +721,8 @@ do_login(Session *s, const char *command)
|
||||
* the address be 0.0.0.0.
|
||||
*/
|
||||
memset(&from, 0, sizeof(from));
|
||||
fromlen = sizeof(from);
|
||||
if (packet_connection_is_on_socket()) {
|
||||
fromlen = sizeof(from);
|
||||
if (getpeername(packet_get_connection_in(),
|
||||
(struct sockaddr *) & from, &fromlen) < 0) {
|
||||
debug("getpeername: %.100s", strerror(errno));
|
||||
@ -735,7 +735,7 @@ do_login(Session *s, const char *command)
|
||||
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);
|
||||
(struct sockaddr *)&from, fromlen);
|
||||
|
||||
#ifdef USE_PAM
|
||||
/*
|
||||
|
@ -66,12 +66,12 @@ get_last_login_time(uid_t uid, const char *logname,
|
||||
*/
|
||||
void
|
||||
record_login(pid_t pid, const char *ttyname, const char *user, uid_t uid,
|
||||
const char *host, struct sockaddr * addr)
|
||||
const char *host, struct sockaddr * addr, socklen_t addrlen)
|
||||
{
|
||||
struct logininfo *li;
|
||||
|
||||
li = login_alloc_entry(pid, user, host, ttyname);
|
||||
login_set_addr(li, addr, sizeof(struct sockaddr));
|
||||
login_set_addr(li, addr, addrlen);
|
||||
login_login(li);
|
||||
login_free_entry(li);
|
||||
}
|
||||
@ -79,12 +79,12 @@ record_login(pid_t pid, const char *ttyname, const char *user, uid_t uid,
|
||||
#ifdef LOGIN_NEEDS_UTMPX
|
||||
void
|
||||
record_utmp_only(pid_t pid, const char *ttyname, const char *user,
|
||||
const char *host, struct sockaddr * addr)
|
||||
const char *host, struct sockaddr * addr, socklen_t addrlen)
|
||||
{
|
||||
struct logininfo *li;
|
||||
|
||||
li = login_alloc_entry(pid, user, host, ttyname);
|
||||
login_set_addr(li, addr, sizeof(struct sockaddr));
|
||||
login_set_addr(li, addr, addrlen);
|
||||
login_utmp_only(li);
|
||||
login_free_entry(li);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
/* $OpenBSD: sshlogin.h,v 1.3 2001/06/26 17:27:25 markus Exp $ */
|
||||
/* $FreeBSD$ */
|
||||
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
@ -16,13 +17,13 @@
|
||||
|
||||
void
|
||||
record_login(pid_t, const char *, const char *, uid_t,
|
||||
const char *, struct sockaddr *);
|
||||
const char *, struct sockaddr *, socklen_t);
|
||||
void record_logout(pid_t, const char *, const char *);
|
||||
u_long get_last_login_time(uid_t, const char *, char *, u_int);
|
||||
|
||||
#ifdef LOGIN_NEEDS_UTMPX
|
||||
void record_utmp_only(pid_t, const char *, const char *, const char *,
|
||||
struct sockaddr *);
|
||||
struct sockaddr *, socklen_t);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user