1 - IPv6 support to login command
3 --- util-linux-2.13-pre6/login-utils/login.c.ipv6 2006-10-12 10:10:34.000000000 +0200
4 +++ util-linux-2.13-pre6/login-utils/login.c 2006-10-12 10:17:16.000000000 +0200
6 #ifdef HAVE_SECURITY_PAM_MISC_H
7 static struct passwd pwdcopy;
9 -char hostaddress[4]; /* used in checktty.c */
10 +char hostaddress[16]; /* used in checktty.c */
11 char *hostname; /* idem */
12 static char *username, *tty_name, *tty_number;
13 static char thishost[100];
16 xstrncpy(ut.ut_host, hostname, sizeof(ut.ut_host));
18 - memcpy(&ut.ut_addr, hostaddress, sizeof(ut.ut_addr));
19 + memcpy(&ut.ut_addr_v6, hostaddress, sizeof(ut.ut_addr_v6));
21 #if HAVE_UPDWTMP /* bad luck for ancient systems */
22 updwtmp(_PATH_BTMP, &ut);
25 hostname = strdup(optarg); /* strdup: Ambrose C. Li */
27 - struct hostent *he = gethostbyname(hostname);
28 + struct addrinfo hints, *info = NULL;
30 + memset(&hints, '\0', sizeof(hints));
31 + hints.ai_flags = AI_ADDRCONFIG;
35 - /* he points to static storage; copy the part we use */
37 - if (he && he->h_addr_list && he->h_addr_list[0])
38 - memcpy(hostaddress, he->h_addr_list[0],
39 - sizeof(hostaddress));
40 + if (getaddrinfo(hostname, NULL, &hints, &info)==0 && info)
42 + if (info->ai_family == AF_INET)
44 + struct sockaddr_in *sa4;
46 + sa4 = (struct sockaddr_in *) info->ai_addr;
47 + memcpy(hostaddress, &(sa4->sin_addr),
48 + sizeof(sa4->sin_addr));
50 + if (info->ai_family == AF_INET6)
52 + struct sockaddr_in6 *sa6;
54 + sa6 = (struct sockaddr_in6 *) info->ai_addr;
55 + memcpy(hostaddress, &(sa6->sin6_addr),
56 + sizeof(sa6->sin6_addr));
65 xstrncpy(ut.ut_host, hostname, sizeof(ut.ut_host));
67 - memcpy(&ut.ut_addr, hostaddress, sizeof(ut.ut_addr));
68 + memcpy(&ut.ut_addr_v6, hostaddress, sizeof(ut.ut_addr_v6));
72 --- util-linux-2.13-pre6/login-utils/login.h.ipv6 2005-08-02 14:01:18.000000000 +0200
73 +++ util-linux-2.13-pre6/login-utils/login.h 2006-10-12 10:10:34.000000000 +0200
75 /* defined in login.c */
76 extern void badlogin(const char *s);
77 extern void sleepexit(int);
78 -extern char hostaddress[4];
79 +extern char hostaddress[16];
80 extern char *hostname;
82 /* defined in checktty.c */