Yahoo Groups archive

Milter-greylist

Index last updated: 2026-04-28 23:32 UTC

Message

Re: [milter-greylist] Submitter DNS name resolution and forgery detection

2013-08-14 by Johann Klasek

On Wed, Aug 14, 2013 at 07:18:41AM +0200, manu@... wrote:
> Jim Klimov <jimklimov@...> wrote:
> 
> > Okay, so here goes the third version of the un-bracketer :)
> 
> I was reading it and it seemed a bit overkill to me to do the 
> a.b.c.d -> d.c.b.a.in-addr.arpa transformation on your own. That adds
> many lines and still fail to support IPv6. Is your system able to use
> getnameinfo(), which is part of POSIX1?

That's what I am wondering about too. But as mentioned in a posting
before, the below solution under Solaris may suffer from the resolve-
double-checking behavior. However, maybe this can be neglected in favour of
not to reinvent the wheel and code stability ...

> Here is a sample proram to test, with both IPv4 or IPv6 addresses. It
> even works if you supply a DNS address.

To get to program (at least) on Solaris 8 to work:
(BSD calls err(), errx() do not exist - at least on old Solaris versions)

To build with "gcc -o getaddrinfo -lsocket -lnsl getaddrinfo.c"

--- lnx/getaddrinfo.c   Wed Aug 14 17:04:14 2013
+++ sol/getaddrinfo.c   Wed Aug 14 17:46:26 2013
@@ -1,6 +1,9 @@
 
 #include <stdio.h>
-#include <err.h>
+/* #include <sys/err.h>
+*/
+#include <sys/socket.h>
+
 #include <sysexits.h>
 #include <netdb.h>
 
@@ -14,21 +17,27 @@
         char hbuf[NI_MAXHOST];
         int rc;
 
-        if (argc != 2)
-                errx(EX_USAGE, "%s IP", argv[0]);
+        if (argc != 2) {
+                fprintf(stderr,"%s IP\n", argv[0]);
+                exit(EX_USAGE);
+       }
 
         addr = argv[1];
 
         rc = getaddrinfo(addr, NULL, NULL, &res);
-        if (rc != 0)
-                errx(EX_OSERR, "failed parsing %s: %s",
+        if (rc != 0) {
+                fprintf(stderr, "failed parsing %s: %s\n",
                      addr, gai_strerror(rc));
+                exit(EX_OSERR);
+       }
 
         rc = getnameinfo(res->ai_addr, res->ai_addrlen,
                          hbuf, sizeof(hbuf), NULL, 0, NI_NAMEREQD);
-        if (rc != 0)
-                errx(EX_OSERR, "failed resolving %s: %s",
+        if (rc != 0) {
+                fprintf(stderr, "failed resolving %s: %s\n",
                      addr, gai_strerror(rc));
+                exit(EX_OSERR);
+       }
 
         freeaddrinfo(res);
 


Johann E. K.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.