chiark / gitweb /
+ * New adnsheloex client courtesy of Tony Finch (and copyright notices
authorian <ian>
Wed, 16 Mar 2005 21:28:51 +0000 (21:28 +0000)
committerian <ian>
Wed, 16 Mar 2005 21:28:51 +0000 (21:28 +0000)
@@ -7,6 +7,8 @@
+  * New adnsheloex client courtesy of Tony Finch (and copyright notices
+    updated).

13 files changed:
INSTALL
LICENCE.WAIVERS
Makefile.in
README
README.html
acconfig.h
aclocal.m4
changelog
client/.cvsignore
client/Makefile.in
client/adnsheloex.c [new file with mode: 0644]
configure.in
settings.make.in

diff --git a/INSTALL b/INSTALL
index 69f6ded4127fe4bd36fc6bf5417bab6f4b9487f1..33a21f60f6b2c9684de94d18b056b81abe30c835 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -101,8 +101,8 @@ details for adns.  It is
  Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
 
 adns is
  Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
 
 adns is
- Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>         [1]
+ Copyright (C) 1997-2005 Ian Jackson <ian@davenant.greenend.org.uk>
+ Copyright (C) 1999-2004 Tony Finch <dot@dotat.at>         [1]
  Copyright (C) 1991 Massachusetts Institute of Technology  [2]
 
 adns is free software; you can redistribute it and/or modify it under
  Copyright (C) 1991 Massachusetts Institute of Technology  [2]
 
 adns is free software; you can redistribute it and/or modify it under
@@ -120,8 +120,9 @@ along with adns as the file COPYING; if not, email me at the address
 above or write to the Free Software Foundation, 59 Temple Place -
 Suite 330, Boston, MA 02111-1307, USA.
 
 above or write to the Free Software Foundation, 59 Temple Place -
 Suite 330, Boston, MA 02111-1307, USA.
 
-[1] Tony Finch holds the original copyright on client/adnslogres.c and
-    client/fanftest.c, and some modifications to those files.
+[1] Tony Finch holds the original copyright on client/adnslogres.c,
+    client/adnsheloex.c and client/fanftest.c, and some modifications
+    to those files.
 [2] MIT hold the original copyright on the included install-sh,
     which came via GNU autoconf.
 
 [2] MIT hold the original copyright on the included install-sh,
     which came via GNU autoconf.
 
index e13275fe4e9af5d2147fe282720ee51c0ff31fc5..5e7ee6826e793a198105c5a283748d28b66e7d75 100644 (file)
@@ -10,11 +10,11 @@ IMPORTANT NOTES
 ---------------
 
  * Not all of the code in adns was written by me.  The programs
 ---------------
 
  * Not all of the code in adns was written by me.  The programs
-   `fanftest' and `adnslogres' are (partially) copyright Tony Finch
-   and to that extent are not covered by the waivers.  I believe - but
-   do not warrant - that the rest of adns is (at the time of writing,
-   4th May 2004) entirely my work, but please check the copyright
-   notices on the individual files.
+   `fanftest', `adnslogres' and `adnsheloex' are (partially) copyright
+   Tony Finch and to that extent are not covered by the waivers.  I
+   believe - but do not warrant - that the rest of adns is (at the
+   time of writing, 16th of March 2005) entirely my work, but please
+   check the copyright notices on the individual files.
 
  * These waivers apply only in the specified circumstances.
 
 
  * These waivers apply only in the specified circumstances.
 
index 18cf2fe75ea995b8dc6ece902e82bf112a1f5915..4ce3657a2229b80133600459da4ce9928c0f9a63 100644 (file)
@@ -4,8 +4,8 @@
 #    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
 #
 #  It is part of adns, which is
 #    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
 #
 #  It is part of adns, which is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+#    Copyright (C) 1997-2005 Ian Jackson <ian@davenant.greenend.org.uk>
+#    Copyright (C) 1999-2004 Tony Finch <dot@dotat.at>
 # 
 #  This program is free software; you can redistribute it and/or modify
 #  it under the terms of the GNU General Public License as published by
 # 
 #  This program is free software; you can redistribute it and/or modify
 #  it under the terms of the GNU General Public License as published by
diff --git a/README b/README
index aa31b0ed430219c7df79fb99ae4fadd90cc53790..5711a58c2f7f141d012608eed70538888b8331bd 100644 (file)
--- a/README
+++ b/README
@@ -130,7 +130,7 @@ References and related projects
 
 Copyright and licensing
 
 
 Copyright and licensing
 
-   adns is Copyright 1997-2001 Ian Jackson, Copyright 1999-2000 Tony
+   adns is Copyright 1997-2005 Ian Jackson, Copyright 1999-2004 Tony
    Finch, and Copyright (C) 1991 Massachusetts Institute of Technology.
 
    adns is free software; you can redistribute it and/or modify it under
    Finch, and Copyright (C) 1991 Massachusetts Institute of Technology.
 
    adns is free software; you can redistribute it and/or modify it under
@@ -154,7 +154,7 @@ Copyright and licensing
 
    [23]GNU home page; [24]chiark home page; [25]site or mirror home page
 
 
    [23]GNU home page; [24]chiark home page; [25]site or mirror home page
 
-   This web page is Copyright (C)1996-2001 Ian Jackson. See the
+   This web page is Copyright (C)1996-2005 Ian Jackson. See the
    [26]Copyright/acknowledgements.
 
    Use any browser - [27]Campaign for a non-browser-specific WWW
    [26]Copyright/acknowledgements.
 
    Use any browser - [27]Campaign for a non-browser-specific WWW
index fe0461da119f7cebff6d0da05f5013848da0e56d..3f6ab522bf1d74b5132e2dad8ad9b127ee39c43a 100644 (file)
@@ -200,8 +200,8 @@ C++</a> by Jarle Aase.
 
 <h2>Copyright and licensing</h2>
 
 
 <h2>Copyright and licensing</h2>
 
-<kbd>adns</kbd> is Copyright 1997-2001 Ian Jackson, Copyright
-1999-2000 Tony Finch, and Copyright (C) 1991 Massachusetts Institute
+<kbd>adns</kbd> is Copyright 1997-2005 Ian Jackson, Copyright
+1999-2004 Tony Finch, and Copyright (C) 1991 Massachusetts Institute
 of Technology.
 
 <p>
 of Technology.
 
 <p>
@@ -243,7 +243,7 @@ software</A> by me.
 <A href="/">site or mirror home page</A>
 <p>
 
 <A href="/">site or mirror home page</A>
 <p>
 
-This web page is Copyright (C)1996-2001 Ian Jackson.  See the
+This web page is Copyright (C)1996-2005 Ian Jackson.  See the
 <A href="http://www.chiark.greenend.org.uk/~ian/sw-www-copy.html">Copyright/acknowledgements</A>.
 <p>
 
 <A href="http://www.chiark.greenend.org.uk/~ian/sw-www-copy.html">Copyright/acknowledgements</A>.
 <p>
 
index 1d0e671435ccf6c653897c1c5915da9d51ee0ce0..9e42673ba047e12257d45bcdc1d2040eb2a4d253 100644 (file)
@@ -7,8 +7,8 @@
  *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
  *
  *  It is part of adns, which is
  *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
  *
  *  It is part of adns, which is
- *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
- *    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+ *    Copyright (C) 1997-2005 Ian Jackson <ian@davenant.greenend.org.uk>
+ *    Copyright (C) 1999-2004 Tony Finch <dot@dotat.at>
  *  
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  *  
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
index 6c4099eec6680dfe31dbcd2d6e593aa37e8a839f..cb6e9229b4d42017cff6b65097175c9375c4ee1f 100644 (file)
@@ -4,8 +4,8 @@
 #    Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
 #
 #  It is part of adns, which is
 #    Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
 #
 #  It is part of adns, which is
-#    Copyright (C) 1997-1999 Ian Jackson <ian@davenant.greenend.org.uk>
-#    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+#    Copyright (C) 1997-2005 Ian Jackson <ian@davenant.greenend.org.uk>
+#    Copyright (C) 1999-2004 Tony Finch <dot@dotat.at>
 #  
 #  This file is part of adns, which is Copyright (C) 1997-1999 Ian Jackson
 #
 #  
 #  This file is part of adns, which is Copyright (C) 1997-1999 Ian Jackson
 #
index b36b68f6f44f8a9c7ed62b088b203904b9b0ca91..5f6085ca74711c855b42d4294746f1304d5359c5 100644 (file)
--- a/changelog
+++ b/changelog
@@ -7,6 +7,8 @@ adns (1.2); urgency=medium
   * Added a TODO list item.
   * Add .PHONY: install to Makefile, to help people with demented fs's.
   * Darwin listed in INSTALL.
   * Added a TODO list item.
   * Add .PHONY: install to Makefile, to help people with demented fs's.
   * Darwin listed in INSTALL.
+  * New adnsheloex client courtesy of Tony Finch (and copyright notices
+    updated).
 
  --
 
 
  --
 
index 45bcf1e01117a93ba1539b59b640d41fb50af047..dc16cfb2214cc17803ebb94f4a05e287ca5f54e4 100644 (file)
@@ -3,6 +3,8 @@ adnstest
 adnstest_s
 adnslogres
 adnslogres_s
 adnstest_s
 adnslogres
 adnslogres_s
+adnsheloex
+adnsheloex_s
 adnshost
 adnshost_s
 adnsresfilter
 adnshost
 adnshost_s
 adnsresfilter
index 59a358228ea9a2ba31acd23be1ae296aa5320c65..462ca579c0eca6e6976bbe1eaa2a3f38c2826bea 100644 (file)
@@ -27,7 +27,7 @@ VPATH=                @srcdir@
 PROGS_SYSDEP=  @PROGS_HAVE_TSEARCH@
 ENABLE_DYNAMIC=        @ENABLE_DYNAMIC@
 
 PROGS_SYSDEP=  @PROGS_HAVE_TSEARCH@
 ENABLE_DYNAMIC=        @ENABLE_DYNAMIC@
 
-PROGRAMS=      adnslogres adnshost $(PROGS_SYSDEP)
+PROGRAMS=      adnslogres adnsheloex adnshost $(PROGS_SYSDEP)
 PROGRAMS_LOCAL=        fanftest adnstest
 PROGRAMS_ALL=  $(PROGRAMS) $(PROGRAMS_LOCAL)
 
 PROGRAMS_LOCAL=        fanftest adnstest
 PROGRAMS_ALL=  $(PROGRAMS) $(PROGRAMS_LOCAL)
 
diff --git a/client/adnsheloex.c b/client/adnsheloex.c
new file mode 100644 (file)
index 0000000..6fff9a3
--- /dev/null
@@ -0,0 +1,301 @@
+/*
+ * adnsheloex.c
+ * - look up the A record of hosts in an Exim log that failed HELO verification
+ */
+/*
+ *  This file is
+ *   Copyright (C) 2004 Tony Finch <dot@dotat.at>
+ *
+ *  It is part of adns, which is
+ *    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
+ *    Copyright (C) 1999-2004 Tony Finch <dot@dotat.at>
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software Foundation,
+ *  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *  This file is by Tony Finch, based on adnslogres.c.
+ */
+
+static const char * const cvsid =
+       "$Id$";
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stdarg.h>
+
+#include "config.h"
+#include "adns.h"
+#include "client.h"
+
+#ifdef ADNS_REGRESS_TEST
+# include "hredirect.h"
+#endif
+
+/* maximum number of concurrent DNS queries */
+#define MAXMAXPENDING 64000
+#define DEFMAXPENDING 2000
+
+/* maximum length of a line */
+#define MAXLINE 1024
+
+/* option flags */
+#define OPT_DEBUG 1
+#define OPT_POLL 2
+
+static const char *const progname= "adnsheloex";
+static const char *config_text;
+
+#define guard_null(str) ((str) ? (str) : "")
+
+#define sensible_ctype(type,ch) (type((unsigned char)(ch)))
+  /* isfoo() functions from ctype.h can't safely be fed char - blech ! */
+
+static void msg(const char *fmt, ...) {
+  va_list al;
+
+  fprintf(stderr, "%s: ", progname);
+  va_start(al,fmt);
+  vfprintf(stderr, fmt, al);
+  va_end(al);
+  fputc('\n',stderr);
+}
+
+static void aargh(const char *cause) {
+  const char *why = strerror(errno);
+  if (!why) why = "Unknown error";
+  msg("%s: %s (%d)", cause, why, errno);
+  exit(1);
+}
+
+typedef struct logline {
+  struct logline *next;
+  char *start, *name, *rest, *addr;
+  adns_query query;
+} logline;
+
+static logline *readline(FILE *inf, adns_state adns, int opts) {
+  static char buf[MAXLINE];
+  char *str, *p, *q, *r;
+  logline *line;
+
+  if (fgets(buf, MAXLINE, inf)) {
+    str= malloc(sizeof(*line) + strlen(buf) + 1);
+    if (!str) aargh("malloc");
+    line= (logline*)str;
+    line->next= NULL;
+    line->start= str+sizeof(logline);
+    strcpy(line->start, buf);
+    line->name= line->rest= line->addr= NULL;
+    /* look for unverifiable HELO information matching the regex
+       H=[a-z0-9.- ]*[(][a-z0-9.-]*[)] [[][0-9.]*[]] */
+    for (p= strchr(line->start, ' '); p; p= strchr(p+1, ' ')) {
+      if (!strncmp(p, " H=", 3)) {
+       r= strchr(p, '[');
+       if (!r) break;
+       q= strchr(p, ')');
+       if (!q || q>r) break;
+       p= strchr(p, '(');
+       if (!p || p>q) break;
+       line->name= p+1;
+       line->rest= q;
+       line->addr= r+1;
+       break;
+      }
+    }
+    if (line->name) {
+      *line->rest= '\0';
+      if (opts & OPT_DEBUG)
+       msg("submitting %s", line->name);
+      if (adns_submit(adns, line->name, adns_r_a,
+                     adns_qf_quoteok_query|adns_qf_quoteok_cname|adns_qf_cname_loose,
+                     NULL, &line->query))
+       aargh("adns_submit");
+      *line->rest= ')';
+    } else {
+      if (opts & OPT_DEBUG)
+       msg("no query");
+      line->query= NULL;
+    }
+    return line;
+  }
+  if (!feof(inf))
+    aargh("fgets");
+  return NULL;
+}
+
+static void proclog(FILE *inf, FILE *outf, int maxpending, int opts) {
+  int eof, err, len;
+  adns_state adns;
+  adns_answer *answer;
+  logline *head, *tail, *line;
+  adns_initflags initflags;
+
+  initflags= (opts & OPT_DEBUG) ? adns_if_debug : 0;
+  if (config_text) {
+    errno= adns_init_strcfg(&adns, initflags, stderr, config_text);
+  } else {
+    errno= adns_init(&adns, initflags, 0);
+  }
+  if (errno) aargh("adns_init");
+  head= tail= readline(inf, adns, opts);
+  len= 1; eof= 0;
+  while (head) {
+    while (head) {
+      if (head->query) {
+       if (opts & OPT_DEBUG)
+         msg("%d in queue; checking %.*s", len,
+             head->rest-head->name, guard_null(head->name));
+       if (eof || len >= maxpending) {
+         if (opts & OPT_POLL)
+           err= adns_wait_poll(adns, &head->query, &answer, NULL);
+         else
+           err= adns_wait(adns, &head->query, &answer, NULL);
+       } else {
+         err= adns_check(adns, &head->query, &answer, NULL);
+       }
+       if (err == EAGAIN) break;
+       if (err) {
+         fprintf(stderr, "%s: adns_wait/check: %s", progname, strerror(err));
+         exit(1);
+       }
+       if (answer->status == adns_s_ok) {
+         const char *addr;
+         int ok = 0;
+         fprintf(outf, "%.*s", head->rest-head->start, head->start);
+         while(answer->nrrs--) {
+           addr= inet_ntoa(answer->rrs.inaddr[answer->nrrs]);
+           ok |= !strncmp(addr, head->addr, strlen(addr));
+           fprintf(outf, " [%s]", addr);
+         }
+         fprintf(outf, "%s%s", ok ? " OK" : "", head->rest);
+       } else {
+         if (opts & OPT_DEBUG)
+           msg("query failed");
+         fputs(head->start, outf);
+       }
+       free(answer);
+       len--;
+      } else {
+       if (opts & OPT_DEBUG)
+         msg("%d in queue; no query on this line", len);
+       fputs(head->start, outf);
+      }
+      line= head; head= head->next;
+      free(line);
+    }
+    if (!eof) {
+      line= readline(inf, adns, opts);
+      if (line) {
+        if (!head) head= line;
+        else tail->next= line;
+        tail= line;
+       if (line->query) len++;
+      } else {
+       eof= 1;
+      }
+    }
+  }
+  adns_finish(adns);
+}
+
+static void printhelp(FILE *file) {
+  fputs("usage: adnsheloex [<options>] [<logfile>]\n"
+       "       adnsheloex --version|--help\n"
+       "options: -c <concurrency>  set max number of outstanding queries\n"
+       "         -p                use poll(2) instead of select(2)\n"
+       "         -d                turn on debugging\n"
+       "         -C <config>       use instead of contents of resolv.conf\n",
+       stdout);
+}
+
+static void usage(void) {
+  printhelp(stderr);
+  exit(1);
+}
+
+int main(int argc, char *argv[]) {
+  int c, opts, maxpending;
+  extern char *optarg;
+  FILE *inf;
+
+  if (argv[1] && !strncmp(argv[1],"--",2)) {
+    if (!strcmp(argv[1],"--help")) {
+      printhelp(stdout);
+    } else if (!strcmp(argv[1],"--version")) {
+      fputs(VERSION_MESSAGE("adnsheloex"),stdout);
+    } else {
+      usage();
+    }
+    if (ferror(stdout) || fclose(stdout)) { perror("stdout"); exit(1); }
+    exit(0);
+  }
+
+  maxpending= DEFMAXPENDING;
+  opts= 0;
+  while ((c= getopt(argc, argv, "c:C:dp")) != -1)
+    switch (c) {
+    case 'c':
+      maxpending= atoi(optarg);
+      if (maxpending < 1 || maxpending > MAXMAXPENDING) {
+       fprintf(stderr, "%s: unfeasible concurrency %d\n", progname, maxpending);
+       exit(1);
+      }
+      break;
+    case 'C':
+      config_text= optarg;
+      break;
+    case 'd':
+      opts|= OPT_DEBUG;
+      break;
+    case 'p':
+      opts|= OPT_POLL;
+      break;
+    default:
+      usage();
+    }
+
+  argc-= optind;
+  argv+= optind;
+
+  inf= NULL;
+  if (argc == 0)
+    inf= stdin;
+  else if (argc == 1)
+    inf= fopen(*argv, "r");
+  else
+    usage();
+
+  if (!inf)
+    aargh("couldn't open input");
+
+  proclog(inf, stdout, maxpending, opts);
+
+  if (fclose(inf))
+    aargh("fclose input");
+  if (fclose(stdout))
+    aargh("fclose output");
+
+  return 0;
+}
index 096396d1e9eaacef1d63e9d97ed85fa457e2392e..b21404022c592d1af3a2b86cf29c428237438794 100644 (file)
@@ -4,8 +4,8 @@
 #    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
 #
 #  It is part of adns, which is
 #    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
 #
 #  It is part of adns, which is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+#    Copyright (C) 1997-2005 Ian Jackson <ian@davenant.greenend.org.uk>
+#    Copyright (C) 1999-2004 Tony Finch <dot@dotat.at>
 #  
 #  This program is free software; you can redistribute it and/or modify
 #  it under the terms of the GNU General Public License as published by
 #  
 #  This program is free software; you can redistribute it and/or modify
 #  it under the terms of the GNU General Public License as published by
index cfb44e00ddf0d4c154900a78d5571130135000ac..3714d78a70992995abe0fbbf6410561cc09bf521 100644 (file)
@@ -5,8 +5,8 @@
 #    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
 #
 #  It is part of adns, which is
 #    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
 #
 #  It is part of adns, which is
-#    Copyright (C) 1997-2000 Ian Jackson <ian@davenant.greenend.org.uk>
-#    Copyright (C) 1999-2000 Tony Finch <dot@dotat.at>
+#    Copyright (C) 1997-2005 Ian Jackson <ian@davenant.greenend.org.uk>
+#    Copyright (C) 1999-2004 Tony Finch <dot@dotat.at>
 #  
 #  This program is free software; you can redistribute it and/or modify
 #  it under the terms of the GNU General Public License as published by
 #  
 #  This program is free software; you can redistribute it and/or modify
 #  it under the terms of the GNU General Public License as published by