add IPv6 and keyring support

This commit is contained in:
kzak 2006-07-17 09:09:59 +00:00
parent b7d2d653dc
commit 4f8c2f9bd0
2 changed files with 89 additions and 1 deletions

View File

@ -0,0 +1,79 @@
--- util-linux-2.13-pre6/login-utils/login.c.ipv6 2006-07-17 11:05:48.000000000 +0200
+++ util-linux-2.13-pre6/login-utils/login.c 2006-07-17 11:05:48.000000000 +0200
@@ -173,7 +173,7 @@
#ifdef HAVE_SECURITY_PAM_MISC_H
static struct passwd pwdcopy;
#endif
-char hostaddress[4]; /* used in checktty.c */
+char hostaddress[16]; /* used in checktty.c */
char *hostname; /* idem */
static char *username, *tty_name, *tty_number;
static char thishost[100];
@@ -281,7 +281,7 @@
if (hostname) {
xstrncpy(ut.ut_host, hostname, sizeof(ut.ut_host));
if (hostaddress[0])
- memcpy(&ut.ut_addr, hostaddress, sizeof(ut.ut_addr));
+ memcpy(&ut.ut_addr_v6, hostaddress, sizeof(ut.ut_addr_v6));
}
#if HAVE_UPDWTMP /* bad luck for ancient systems */
updwtmp(_PATH_BTMP, &ut);
@@ -380,13 +380,32 @@
hostname = strdup(optarg); /* strdup: Ambrose C. Li */
{
- struct hostent *he = gethostbyname(hostname);
+ struct addrinfo hints, *addr_info;
+ int k=0;
+
+ memset(&hints, '\0', sizeof(hints));
+ hints.ai_flags = AI_ADDRCONFIG;
+
+ if (getaddrinfo(hostname, NULL, &hints, &addr_info) != 0)
+ fprintf(stderr, "getaddrinfo: %s\n", strerror(errno));
+
+ hostaddress[0] = 0;
- /* he points to static storage; copy the part we use */
- hostaddress[0] = 0;
- if (he && he->h_addr_list && he->h_addr_list[0])
- memcpy(hostaddress, he->h_addr_list[0],
- sizeof(hostaddress));
+ if (addr_info && (addr_info->ai_family == AF_INET))
+ {
+ struct sockaddr_in *sa4;
+
+ sa4 = (struct sockaddr_in *)addr_info->ai_addr;
+ memcpy(hostaddress, &(sa4->sin_addr), sizeof(sa4->sin_addr));
+ }
+ if (addr_info && (addr_info->ai_family == AF_INET6))
+ {
+ struct sockaddr_in6 *sa6;
+
+ sa6 = (struct sockaddr_in6 *)addr_info->ai_addr;
+ memcpy(hostaddress, &(sa6->sin6_addr), sizeof(sa6->sin6_addr));
+ }
+ freeaddrinfo(addr_info);
}
break;
@@ -906,7 +925,7 @@
if (hostname) {
xstrncpy(ut.ut_host, hostname, sizeof(ut.ut_host));
if (hostaddress[0])
- memcpy(&ut.ut_addr, hostaddress, sizeof(ut.ut_addr));
+ memcpy(&ut.ut_addr_v6, hostaddress, sizeof(ut.ut_addr_v6));
}
pututline(&ut);
--- util-linux-2.13-pre6/login-utils/login.h.ipv6 2005-08-02 14:01:18.000000000 +0200
+++ util-linux-2.13-pre6/login-utils/login.h 2006-07-17 11:05:48.000000000 +0200
@@ -1,7 +1,7 @@
/* defined in login.c */
extern void badlogin(const char *s);
extern void sleepexit(int);
-extern char hostaddress[4];
+extern char hostaddress[16];
extern char *hostname;
/* defined in checktty.c */

View File

@ -9,7 +9,7 @@
Summary: A collection of basic system utilities.
Name: util-linux
Version: 2.13
Release: 0.31.1
Release: 0.32
License: distributable
Group: System Environment/Base
@ -217,6 +217,8 @@ Patch242: util-linux-2.12a-raw-man-dd.patch
Patch243: util-linux-2.13-swap-page.patch
# Don't use linux/posix_types.h or asm/posix_types.h
Patch244: util-linux-2.13-nfs4-posix_types.patch
# IPv6 support to login command
Patch245: util-linux-2.13-login-ipv6.patch
# When adding patches, please make sure that it is easy to find out what bug # the
# patch fixes.
@ -312,6 +314,7 @@ cp %{SOURCE8} %{SOURCE9} .
%patch242 -p1
%patch243 -p1
%patch244 -p1
%patch245 -p1
%build
unset LINGUAS || :
@ -702,6 +705,12 @@ exit 0
/sbin/losetup
%changelog
* Mon Jul 17 2006 Karel Zak <kzak@redhat.com> 2.13-0.32
- add IPv6 support to the login command (patch by Milan Zazrivec)
* Thu Jul 13 2006 David Howells <dhowells@redhat.com>
- fix #198626 - add keyinit instructions to the login PAM script
* Wed Jul 12 2006 Jesse Keating <jkeating@redhat.com> - 2.13-0.31.1
- rebuild