Skip to content

Commit

Permalink
- (djm) Bug #460: Filling utmp[x]->ut_addr_v6 if present. Patch from
Browse files Browse the repository at this point in the history
   cjwatson@debian.org
  • Loading branch information
djmdjm committed Jan 3, 2003
1 parent 8aff5cb commit 02e16ad
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
6 changes: 4 additions & 2 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
20030103
- (djm) Bug #461: ssh-copy-id fails with no arguments. Patch from
cjwatson@debian.org

- (djm) Bug #460: Filling utmp[x]->ut_addr_v6 if present. Patch from
cjwatson@debian.org

20030101
- (stevesk) [session.c sshlogin.c sshlogin.h] complete portable
parts of pass addrlen with sockaddr * fix.
Expand Down Expand Up @@ -921,4 +923,4 @@
save auth method before monitor_reset_key_state(); bugzilla bug #284;
ok provos@

$Id: ChangeLog,v 1.2538 2003/01/03 03:34:06 djm Exp $
$Id: ChangeLog,v 1.2539 2003/01/03 03:42:27 djm Exp $
34 changes: 33 additions & 1 deletion loginrec.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
#include "log.h"
#include "atomicio.h"

RCSID("$Id: loginrec.c,v 1.44 2002/09/26 00:38:49 tim Exp $");
RCSID("$Id: loginrec.c,v 1.45 2003/01/03 03:42:28 djm Exp $");

#ifdef HAVE_UTIL_H
# include <util.h>
Expand Down Expand Up @@ -609,6 +609,9 @@ void
construct_utmp(struct logininfo *li,
struct utmp *ut)
{
# ifdef HAVE_ADDR_V6_IN_UTMP
struct sockaddr_in6 *sa6;
# endif
memset(ut, '\0', sizeof(*ut));

/* First fill out fields used for both logins and logouts */
Expand Down Expand Up @@ -661,6 +664,19 @@ construct_utmp(struct logininfo *li,
if (li->hostaddr.sa.sa_family == AF_INET)
ut->ut_addr = li->hostaddr.sa_in.sin_addr.s_addr;
# endif
# ifdef HAVE_ADDR_V6_IN_UTMP
/* this is just a 128-bit IPv6 address */
if (li->hostaddr.sa.sa_family == AF_INET6) {
sa6 = ((struct sockaddr_in6 *)&li->hostaddr.sa);
memcpy(ut->ut_addr_v6, sa6->sin6_addr.s6_addr, 16);
if (IN6_IS_ADDR_V4MAPPED(&sa6->sin6_addr)) {
ut->ut_addr_v6[0] = ut->ut_addr_v6[3];
ut->ut_addr_v6[1] = 0;
ut->ut_addr_v6[2] = 0;
ut->ut_addr_v6[3] = 0;
}
}
# endif
}
#endif /* USE_UTMP || USE_WTMP || USE_LOGIN */

Expand Down Expand Up @@ -689,6 +705,9 @@ set_utmpx_time(struct logininfo *li, struct utmpx *utx)
void
construct_utmpx(struct logininfo *li, struct utmpx *utx)
{
# ifdef HAVE_ADDR_V6_IN_UTMP
struct sockaddr_in6 *sa6;
# endif
memset(utx, '\0', sizeof(*utx));
# ifdef HAVE_ID_IN_UTMPX
line_abbrevname(utx->ut_id, li->line, sizeof(utx->ut_id));
Expand Down Expand Up @@ -725,6 +744,19 @@ construct_utmpx(struct logininfo *li, struct utmpx *utx)
if (li->hostaddr.sa.sa_family == AF_INET)
utx->ut_addr = li->hostaddr.sa_in.sin_addr.s_addr;
# endif
# ifdef HAVE_ADDR_V6_IN_UTMP
/* this is just a 128-bit IPv6 address */
if (li->hostaddr.sa.sa_family == AF_INET6) {
sa6 = ((struct sockaddr_in6 *)&li->hostaddr.sa);
memcpy(ut->ut_addr_v6, sa6->sin6_addr.s6_addr, 16);
if (IN6_IS_ADDR_V4MAPPED(&sa6->sin6_addr)) {
ut->ut_addr_v6[0] = ut->ut_addr_v6[3];
ut->ut_addr_v6[1] = 0;
ut->ut_addr_v6[2] = 0;
ut->ut_addr_v6[3] = 0;
}
}
# endif
# ifdef HAVE_SYSLEN_IN_UTMPX
/* ut_syslen is the length of the utx_host string */
utx->ut_syslen = MIN(strlen(li->hostname), sizeof(utx->ut_host));
Expand Down

0 comments on commit 02e16ad

Please sign in to comment.