Mailinglist Archive: opensuse-factory (458 mails)

< Previous Next >
[opensuse-factory] libwrap still broken over 2 years later...
Just rebooted (it had been 60 days since last reboot), and it picked
up the new tcpd/libwrap0 files from 13.1 (am pretty sure it's
not fixed in factory, given it hasn't been fixed in over 2 years)...

This is still a problem:

http://lists.opensuse.org/opensuse/2011-10/msg00351.html

Thought it was reported as I have a patch file...
making sure it is reported here:

https://bugzilla.novell.com/show_bug.cgi?id=861989

(had problems w/attachment, so am including it here as well..).



--- socket.c 2013-05-23 14:08:58.000000000 -0700
+++ socket.c 2013-05-23 16:28:40.415779720 -0700
@@ -22,6 +22,8 @@
/* System libraries. */

#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -38,6 +40,21 @@

#include "tcpd.h"

+
+static int ipv6_cached = -1;
+
+int ipv6 () {
+ int errstat;
+ struct stat buf;
+ if (ipv6_cached==-1) {
+ errstat=stat("/proc/sys/net/ipv6", &buf);
+ if (errstat==0 /* && (buf->mode_t & S_IFDIR)*/) ipv6_cached=1;
+ else ipv6_cached=0;
+ }
+ return ipv6_cached;
+}
+
+
/* Forward declarations. */

static void sock_sink();
@@ -66,10 +83,10 @@
} else {
sprintf(dot_name, "%s.", name);
hp = gethostbyname(dot_name);
- if (hp)
- return hp;
- else
- return (gethostbyname(name));
+ if (hp)
+ return hp;
+ else
+ return (gethostbyname(name));
}
}

@@ -79,15 +96,15 @@
/* sock_host - look up endpoint addresses and install conversion methods */

void sock_host(request)
-struct request_info *request;
-{
-#ifdef INET6
- static struct sockaddr_storage client;
- static struct sockaddr_storage server;
-#else
+struct request_info *request; {
+ static struct sockaddr_storage client6;
+ static struct sockaddr_storage server6;
static struct sockaddr_in client;
static struct sockaddr_in server;
-#endif
+
+ void * clientx = ipv6() ? &client6 : &client;
+ void * serverx = ipv6() ? &server6 : &server;
+
int len;
char buf[BUFSIZ];
int fd = request->fd;
@@ -103,12 +120,12 @@
* broken library code.
*/

- len = sizeof(client);
- if (getpeername(fd, (struct sockaddr *) & client, &len) < 0) {
+ len = ipv6() ? sizeof(client6) : sizeof(client);
+ if (getpeername(fd, (struct sockaddr *) clientx, &len) < 0) {
request->sink = sock_sink;
- len = sizeof(client);
+ len = ipv6() ? sizeof(client6) : sizeof(client);
if (recvfrom(fd, buf, sizeof(buf), MSG_PEEK,
- (struct sockaddr *) & client, &len) < 0) {
+ (struct sockaddr *) clientx, &len) < 0) {
tcpd_warn("can't get client address: %m");
return; /* give up */
}
@@ -116,11 +133,8 @@
memset(buf, 0 sizeof(buf));
#endif
}
-#ifdef INET6
- request->client->sin = (struct sockaddr *)&client;
-#else
- request->client->sin = &client;
-#endif
+
+ request->client->sin = (struct sockaddr *)clientx;

/*
* Determine the server binding. This is used for client username
@@ -128,16 +142,13 @@
* address or name.
*/

- len = sizeof(server);
- if (getsockname(fd, (struct sockaddr *) & server, &len) < 0) {
+ len = ipv6() ? sizeof(server6) : sizeof(server);
+ if (getsockname(fd, (struct sockaddr *) serverx, &len) < 0) {
tcpd_warn("getsockname: %m");
return;
}
-#ifdef INET6
- request->server->sin = (struct sockaddr *)&server;
-#else
- request->server->sin = &server;
-#endif
+
+ request->server->sin = (struct sockaddr *)serverx;
}


@@ -156,34 +167,35 @@
* field is empty or unknown, use the address field to get the sockaddr
* and hostname. */
if (strlen(request->client->addr) &&
- HOSTNAME_KNOWN(request->client->addr) &&
- (!strlen(request->client->addr) ||
- !HOSTNAME_KNOWN(request->client->name)))
- host = request->client->addr;
+ HOSTNAME_KNOWN(request->client->addr) &&
+ (!strlen(request->client->addr) ||
+ !HOSTNAME_KNOWN(request->client->name)))
+ host = request->client->addr;
else
- return;
+ return;

memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_INET6;
+
+ hints.ai_family = ipv6() ? AF_INET6 : AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST;

ret = getaddrinfo(host, NULL, &hints, &res);
if (ret != 0) {
- hints.ai_family = AF_INET;
- ret = getaddrinfo(host, NULL, &hints, &res);
+ hints.ai_family = AF_INET;
+ ret = getaddrinfo(host, NULL, &hints, &res);
}

if (ret != 0) {
- tcpd_warn("can't resolve hostname (%s): %s", host, gai_strerror(ret));
+ tcpd_warn("can't resolve hostname (%s): %s", host, gai_strerror(ret));
} else {
- sock_methods(request);
+ sock_methods(request);

- memcpy(&client, res->ai_addr, res->ai_addrlen);
- request->client->sin = (struct sockaddr *)&client;
- freeaddrinfo(res);
+ memcpy(&client, res->ai_addr, res->ai_addrlen);
+ request->client->sin = (struct sockaddr *)&client;
+ freeaddrinfo(res);

- request->client->name[0] = 0;
+ request->client->name[0] = 0;
}
}

@@ -192,39 +204,37 @@
void sock_hostaddr(host)
struct host_info *host;
{
-#ifdef INET6
- struct sockaddr *sin = host->sin;
- char *ap;
- int alen;
+ if (ipv6()) {
+ struct sockaddr *sin = host->sin;
+ char *ap;
+ int alen;

- if (!sin)
- return;
- switch (sin->sa_family) {
- case AF_INET:
- ap = (char *)&((struct sockaddr_in *)sin)->sin_addr;
- alen = sizeof(struct in_addr);
- break;
- case AF_INET6:
- ap = (char *)&((struct sockaddr_in6 *)sin)->sin6_addr;
- alen = sizeof(struct in6_addr);
- break;
- default:
+ if (!sin)
return;
- }
- host->addr[0] = '\0';
- inet_ntop(sin->sa_family, ap, host->addr, sizeof(host->addr));
-#else
- struct sockaddr_in *sin = host->sin;
+ switch (sin->sa_family) {
+ case AF_INET:
+ ap = (char *)&((struct sockaddr_in *)sin)->sin_addr;
+ alen = sizeof(struct in_addr);
+ break;
+ case AF_INET6:
+ ap = (char *)&((struct sockaddr_in6 *)sin)->sin6_addr;
+ alen = sizeof(struct in6_addr);
+ break;
+ default:
+ return;
+ }
+ host->addr[0] = '\0';
+ inet_ntop(sin->sa_family, ap, host->addr, sizeof(host->addr));
+ } else {
+ struct sockaddr_in *sin = host->sin;

- if (sin != 0)
- STRN_CPY(host->addr, inet_ntoa(sin->sin_addr), sizeof(host->addr));
-#endif
+ if (sin != 0)
+ STRN_CPY(host->addr, inet_ntoa(sin->sin_addr), sizeof(host->addr));
+ }
}

-#ifdef INET6
/* sock_hostname - map endpoint address to host name */
-void
-sock_hostname(struct host_info *host)
+void sock_hostname6(struct host_info *host)
{
struct addrinfo hints, *res, *resbase;
struct sockaddr *sa = host->sin;
@@ -330,7 +340,7 @@
host->name,
inet_ntop2 (sin6->sin6_family, &sin6->sin6_addr));
strncpy(host->name, paranoid, sizeof(host->name));
- freeaddrinfo (resbase);
+ freeaddrinfo (resbase);
return;
}

@@ -344,8 +354,8 @@
freeaddrinfo (resbase);
return;
}
-#else /* INET6 */
-void sock_hostname(host)
+
+void sock_hostname4(host)
struct host_info *host;
{
struct sockaddr_in *sin = host->sin;
@@ -428,7 +438,10 @@
strcpy(host->name, paranoid); /* name is bad, clobber it */
}
}
-#endif /* INET6 */
+
+void sock_hostname(struct host_info *host) {
+ ipv6()? sock_hostname6(host) :sock_hostname4(host);
+}

/* sock_sink - absorb unreceived IP datagram */

@@ -436,17 +449,18 @@
int fd;
{
char buf[BUFSIZ];
-#ifdef INET6
- struct sockaddr_storage sin;
-#else
+
+ struct sockaddr_storage sin6;
struct sockaddr_in sin;
-#endif
- int size = sizeof(sin);
+
+ void * sinx = ipv6() ? &sin6 : &sin;
+
+ int size = ipv6()? sizeof(sin6): sizeof(sin);

/*
* Eat up the not-yet received datagram. Some systems insist on a
* non-zero source address argument in the recvfrom() call below.
*/

- (void) recvfrom(fd, buf, sizeof(buf), 0, (struct sockaddr *) & sin, &size);
+ (void) recvfrom(fd, buf, sizeof(buf), 0, (struct sockaddr *) sinx, &size);
}
< Previous Next >
Follow Ups