summaryrefslogtreecommitdiff
path: root/news/knews/patches/patch-ag
diff options
context:
space:
mode:
Diffstat (limited to 'news/knews/patches/patch-ag')
-rw-r--r--news/knews/patches/patch-ag137
1 files changed, 137 insertions, 0 deletions
diff --git a/news/knews/patches/patch-ag b/news/knews/patches/patch-ag
new file mode 100644
index 00000000000..0e7aefcfbbb
--- /dev/null
+++ b/news/knews/patches/patch-ag
@@ -0,0 +1,137 @@
+$NetBSD: patch-ag,v 1.3 2001/02/23 22:19:42 tron Exp $
+
+--- src/sysdeps.c.orig Tue Dec 29 11:46:52 1998
++++ src/sysdeps.c Fri Feb 23 23:11:36 2001
+@@ -20,8 +20,8 @@
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
+
+-#include "server.h"
+ #include "sysdeps.h"
++#include "server.h"
+
+ #undef PURIFY_HACK
+ /*#define PURIFY_HACK*/
+@@ -96,6 +96,9 @@
+ #ifdef EINPROGRESS
+ err_no == EINPROGRESS ||
+ #endif
++#ifdef EALREADY
++ err_no == EALREADY ||
++#endif
+ err_no == EAGAIN);
+ }
+
+@@ -256,10 +259,12 @@
+
+ /***********************************************************************/
+
++#if !defined(USE_INET6)
+ struct SERV_ADDR {
+ struct in_addr addr;
+ unsigned short port;
+ };
++#endif
+
+ /*
+ * host: either "hostname:port" or "ip.ip.ip.ip:port",
+@@ -271,6 +276,28 @@
+ */
+ SERV_ADDR *get_host(char *host, unsigned short def_port, int byte_swap)
+ {
++#if defined(USE_INET6)
++ char *c, *port, buffer[6];
++ struct addrinfo hints, *res;
++
++ port = 0;
++ c = strchr(host, ':');
++ if (c) {
++ *c = '\0';
++ if (c[1] >= '0' && c[1] <= '9')
++ port = c + 1;
++ }
++ if (!port) {
++ sprintf(buffer, "%d", def_port);
++ port = buffer;
++ }
++
++ memset(&hints, '\0', sizeof(hints));
++ hints.ai_family = AF_UNSPEC;
++ hints.ai_socktype = SOCK_STREAM;
++ hints.ai_protocol = 0;
++ return getaddrinfo(host, port, &hints, &res) ? NULL : res;
++#else
+ SERV_ADDR *ret;
+ struct in_addr addr;
+ unsigned short port;
+@@ -332,14 +359,15 @@
+ ret->port = port;
+
+ return ret;
++#endif
+ }
+
+-int open_socket(void)
++int open_socket(int family)
+ {
+ int fd, tmp;
+
+ do {
+- fd = socket(PF_INET, SOCK_STREAM, 0);
++ fd = socket(family, SOCK_STREAM, 0);
+ } while (fd < 0 && errno == EINTR);
+
+ if (fd < 0) {
+@@ -372,6 +400,35 @@
+
+ int connect_socket(int fd, SERV_ADDR *addr)
+ {
++#ifdef USE_INET6
++ int family;
++
++ family = AF_INET;
++ while (addr) {
++ if (family != addr->ai_family) {
++ int newsocket;
++
++ newsocket = open_socket(addr->ai_family);
++ if (newsocket < 0)
++ return -1;
++ if (dup2(newsocket, fd) < 0)
++ close(newsocket);
++
++ close(newsocket);
++ family = addr->ai_family;
++ }
++
++ do {
++ if ((connect(fd, addr->ai_addr, addr->ai_addrlen) == 0) ||
++ (errno == EISCONN))
++ return 0;
++ } while (would_block(fd, errno));
++
++ addr = addr->ai_next;
++ }
++
++ return -1;
++#else
+ struct sockaddr_in serv_addr;
+ int tmp;
+
+@@ -390,6 +447,7 @@
+ } while (tmp < 0 && errno == EINTR);
+
+ return tmp;
++#endif
+ }
+
+ #if 0 /* Misc stuff for ftp routines */
+@@ -548,7 +606,7 @@
+ char *get_mailhostname(void)
+ {
+ struct utsname un = {{0,},};
+- char *host = NULL, *domain;
++ char *host = NULL;
+
+ #ifdef PURIFY_HACK
+ return NULL;