chiark / gitweb /
+ * New adns_init_logfn etc. for having logging done with a callback
authorian <ian>
Sat, 7 Jan 2006 17:08:04 +0000 (17:08 +0000)
committerian <ian>
Sat, 7 Jan 2006 17:08:04 +0000 (17:08 +0000)
@@ -1,4 +1,4 @@
-adns (1.2); urgency=medium
+adns (1.1.999.0.1); urgency=medium

   * Fix error in prototype in definition of adns__parse_domain.
   * New LICENCE.WAIVERS file for GPL-incompatility workarounds.
@@ -16,6 +16,8 @@
   * Add bind(2) and listen(2) to test harness (for epithet's benefit, but
     harmless in adns).
   * Add missing ENOTSOCK to hcommon.c.m4 (was already in hcommon.c!)
+  * New adns_init_logfn etc. for having logging done with a callback
+    function.

  --

27 files changed:
INSTALL
LICENCE.WAIVERS
Makefile.in
README
README.html
TODO
acconfig.h
aclocal.m4
changelog
client/.cvsignore
client/Makefile.in
client/adnsheloex.c [new file with mode: 0644]
configure
configure.in
regress/harness.h
regress/harness.h.m4
regress/hcommon.c
regress/hcommon.c.m4
regress/hplayback.c
regress/hplayback.c.m4
regress/hrecord.c
regress/hrecord.c.m4
regress/hredirect.h
regress/hsyscalls.h
regress/hsyscalls.i4
settings.make.in
src/adns.h

diff --git a/INSTALL b/INSTALL
index 1cbbd4f25834302e8e0f80939e20f7667a89304b..33a21f60f6b2c9684de94d18b056b81abe30c835 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -25,6 +25,7 @@ The following work, but only with --disable-dynamic:
    1.0         IRIX 6.5 *not* with GCC [1], [2]
    1.0         AIX 4.1.5
    1.0         HP-UX 10.20, 11.00
+   1.1          Darwin (kernel 7.5.1)
 Later versions of the same OS should work too.  Usually entries in
 this table mean adns passes its own regression test, when compiled
 with GCC, and appears to install and run correctly.  If you have more
@@ -100,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>
- 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
@@ -119,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.
 
-[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.
 
index e13275fe4e9af5d2147fe282720ee51c0ff31fc5..5e7ee6826e793a198105c5a283748d28b66e7d75 100644 (file)
@@ -10,11 +10,11 @@ IMPORTANT NOTES
 ---------------
 
  * 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.
 
index 1583602ef59808372ca45e61ea6069e586856e26..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>
-#    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
@@ -75,3 +75,5 @@ README:                       README.html
 
 TAGS info dvi:
        # do nothing
+
+.PHONY: install #people with case-insensitive filesystems lose otherwise!
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
 
-   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
@@ -154,7 +154,7 @@ Copyright and licensing
 
    [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
index fe0461da119f7cebff6d0da05f5013848da0e56d..3f6ab522bf1d74b5132e2dad8ad9b127ee39c43a 100644 (file)
@@ -200,8 +200,8 @@ C++</a> by Jarle Aase.
 
 <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>
@@ -243,7 +243,7 @@ software</A> by me.
 <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>
 
diff --git a/TODO b/TODO
index 01c74b8a95b01565ab1e8058cbd8aed9c6563619..71e4c9df7999be4c1030ef48607757cec4005127 100644 (file)
--- a/TODO
+++ b/TODO
@@ -15,3 +15,6 @@ WISHLIST:
 * Caching in the library.
 * SRV RRs.
 * Make port configurable in config file.
+* `Nameserver sent bad response' should produce a hexdump in the log
+  (see eg mail to ian@davenant Mon, 25 Oct 2004 14:19:46 +0100 re
+  `compressed datagram contains loop')
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>
- *    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
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>
-#    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
 #
index 1d9416086e9483fbddfbf90d5ad858d660da0a08..a4bdd9725ecde97b689ac4e345bde744dc261040 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,24 +1,23 @@
-
-
-THIS BRANCH IS NOW CLOSED
-
-  EVERYTHING HAS BEEN MERGED TO THE TRUNK
-   (at CVS tag mergepoint-logcallbackfn)
-
-  DO NOT EDIT
-  
-
-  * New adns_init_logfn etc. for having logging done with a callback
-    function.
-
- --
-
-adns (1.2); urgency=medium
+adns (1.1.999.0.1); urgency=medium
 
   * Fix error in prototype in definition of adns__parse_domain.
   * New LICENCE.WAIVERS file for GPL-incompatility workarounds.
   * Clarified GPL-vs-LGPL: a bit less hostile and a bit more mercenary.
   * Allow `;'-comments in resolv.conf (report from Colin Charles).    
+  * 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).
+  * Add documentation comment by definition of adns_r_ptr_raw type enum.
+  * Add -Wno-pointer-sign if GCC has that option.
+  * Call Tensurerecordfile in Hgettimeofday (Tensurerecordfile was
+    Tensureinputfile/Tensureoutputfile).
+  * Add bind(2) and listen(2) to test harness (for epithet's benefit, but
+    harmless in adns).
+  * Add missing ENOTSOCK to hcommon.c.m4 (was already in hcommon.c!)
+  * New adns_init_logfn etc. for having logging done with a callback
+    function.
 
  --
 
index 45bcf1e01117a93ba1539b59b640d41fb50af047..dc16cfb2214cc17803ebb94f4a05e287ca5f54e4 100644 (file)
@@ -3,6 +3,8 @@ adnstest
 adnstest_s
 adnslogres
 adnslogres_s
+adnsheloex
+adnsheloex_s
 adnshost
 adnshost_s
 adnsresfilter
index 59a358228ea9a2ba31acd23be1ae296aa5320c65..462ca579c0eca6e6976bbe1eaa2a3f38c2826bea 100644 (file)
@@ -27,7 +27,7 @@ VPATH=                @srcdir@
 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)
 
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 e5d26ec9d0ebbf1bbd51581c5ea82fbd5522f68e..ff4675cdbdf394f6626ab7f7dca714afd875a27e 100755 (executable)
--- a/configure
+++ b/configure
@@ -1507,22 +1507,70 @@ EOF
 
 
 
+
+if test "${GCC-no}" = yes; then
+       WARNS="-Wall -Wmissing-prototypes -Wwrite-strings -Wstrict-prototypes -Wcast-qual -Wpointer-arith"
+       saved_cflags="$CFLAGS"
+       CFLAGS="$CFLAGS -Wno-pointer-sign"
+       
+ echo $ac_n "checking -Wno-pointer-sign""... $ac_c" 1>&6
+echo "configure:1518: checking -Wno-pointer-sign" >&5
+ if eval "test \"`echo '$''{'adns_cv_c_wnoptrsign'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  
+  cat > conftest.$ac_ext <<EOF
+#line 1524 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1531: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  adns_cv_c_wnoptrsign=yes
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  adns_cv_c_wnoptrsign=no
+fi
+rm -f conftest*
+fi
+
+ if test "x$adns_cv_c_wnoptrsign" = xyes; then
+  true
+  echo "$ac_t""yes" 1>&6
+        WARNS="$WARNS -Wno-pointer-sign"
+ else
+  true
+  echo "$ac_t""no" 1>&6
+ fi
+
+       CFLAGS="$saved_cflags"
+else
+       WARNS=
+fi
+
+
  
  echo $ac_n "checking __attribute__((,,))""... $ac_c" 1>&6
-echo "configure:1513: checking __attribute__((,,))" >&5
+echo "configure:1561: checking __attribute__((,,))" >&5
  if eval "test \"`echo '$''{'adns_cv_c_attribute_supported'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
   cat > conftest.$ac_ext <<EOF
-#line 1519 "configure"
+#line 1567 "configure"
 #include "confdefs.h"
 
 int main() {
 extern int testfunction(int x) __attribute__((,,))
 ; return 0; }
 EOF
-if { (eval echo configure:1526: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1574: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   adns_cv_c_attribute_supported=yes
 else
@@ -1544,20 +1592,20 @@ EOF
 
    
  echo $ac_n "checking __attribute__((noreturn))""... $ac_c" 1>&6
-echo "configure:1548: checking __attribute__((noreturn))" >&5
+echo "configure:1596: checking __attribute__((noreturn))" >&5
  if eval "test \"`echo '$''{'adns_cv_c_attribute_noreturn'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
   cat > conftest.$ac_ext <<EOF
-#line 1554 "configure"
+#line 1602 "configure"
 #include "confdefs.h"
 
 int main() {
 extern int testfunction(int x) __attribute__((noreturn))
 ; return 0; }
 EOF
-if { (eval echo configure:1561: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1609: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   adns_cv_c_attribute_noreturn=yes
 else
@@ -1584,20 +1632,20 @@ EOF
 
    
  echo $ac_n "checking __attribute__((const))""... $ac_c" 1>&6
-echo "configure:1588: checking __attribute__((const))" >&5
+echo "configure:1636: checking __attribute__((const))" >&5
  if eval "test \"`echo '$''{'adns_cv_c_attribute_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
   cat > conftest.$ac_ext <<EOF
-#line 1594 "configure"
+#line 1642 "configure"
 #include "confdefs.h"
 
 int main() {
 extern int testfunction(int x) __attribute__((const))
 ; return 0; }
 EOF
-if { (eval echo configure:1601: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1649: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   adns_cv_c_attribute_const=yes
 else
@@ -1624,20 +1672,20 @@ EOF
 
    
  echo $ac_n "checking __attribute__((format...))""... $ac_c" 1>&6
-echo "configure:1628: checking __attribute__((format...))" >&5
+echo "configure:1676: checking __attribute__((format...))" >&5
  if eval "test \"`echo '$''{'adns_cv_attribute_format'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
   cat > conftest.$ac_ext <<EOF
-#line 1634 "configure"
+#line 1682 "configure"
 #include "confdefs.h"
 
 int main() {
 extern int testfunction(char *y, ...) __attribute__((format(printf,1,2)))
 ; return 0; }
 EOF
-if { (eval echo configure:1641: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1689: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   adns_cv_attribute_format=yes
 else
@@ -1671,14 +1719,6 @@ EOF
 
 
 
-if test "${GCC-no}" = yes; then
-       WARNS="-Wall -Wmissing-prototypes -Wwrite-strings -Wstrict-prototypes -Wcast-qual -Wpointer-arith"
-else
-       WARNS=
-fi
-
-
-
 
 
 
index 096396d1e9eaacef1d63e9d97ed85fa457e2392e..882a4d79e7e6f8083f8c119cce1520376edb9878 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>
-#    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
@@ -112,16 +112,24 @@ DPKG_CACHED_TRY_COMPILE(inlines,dpkg_cv_c_inline,,
  AC_DEFINE(HAVE_INLINE),
  AC_MSG_RESULT(no))
 
-ADNS_C_GCCATTRIB
-
 AC_SUBST(WARNS)
 
 if test "${GCC-no}" = yes; then
        WARNS="-Wall -Wmissing-prototypes -Wwrite-strings -Wstrict-prototypes -Wcast-qual -Wpointer-arith"
+       saved_cflags="$CFLAGS"
+       CFLAGS="$CFLAGS -Wno-pointer-sign"
+       DPKG_CACHED_TRY_COMPILE(-Wno-pointer-sign,adns_cv_c_wnoptrsign,,
+        [],
+        AC_MSG_RESULT(yes)
+        WARNS="$WARNS -Wno-pointer-sign",
+        AC_MSG_RESULT(no))
+       CFLAGS="$saved_cflags"
 else
        WARNS=
 fi
 
+ADNS_C_GCCATTRIB
+
 AC_SUBST(SHLIBCC)
 AC_SUBST(MKSHLIB_1)
 AC_SUBST(MKSHLIB_2)
index 2708e66688efccd7bdace2fcc4bfe05f054eb10f..3bcccf9b30af366b3507524ae1015bf375e8d708 100644 (file)
@@ -13,6 +13,8 @@ void Qpoll(   const struct pollfd *fds , int nfds , int timeout       );
 void Qsocket(   int type       );
 void Qfcntl(   int fd , int cmd , long arg     );
 void Qconnect( int fd , const struct sockaddr *addr , int addrlen      );
+void Qbind(    int fd , const struct sockaddr *addr , int addrlen      );
+void Qlisten(  int fd , int backlog    );
 void Qclose(   int fd  );
 void Qsendto(  int fd , const void *msg , int msglen , const struct sockaddr *addr , int addrlen       );
 void Qrecvfrom(        int fd , int buflen , int addrlen       );
@@ -25,7 +27,7 @@ void Tfailed(const char *why);
 void Toutputerr(void);
 void Tnomem(void);
 void Tfsyscallr(const char *fmt, ...) PRINTFFORMAT(1,2);
-void Tensureoutputfile(void);
+void Tensurerecordfile(void);
 void Tmust(const char *call, const char *arg, int cond);
 void Tvbf(const char *fmt, ...) PRINTFFORMAT(1,2);
 void Tvbvf(const char *fmt, va_list al);
index a25bd37ee79dbff73f99c45d9d4c28d276dcf4cc..fca588d263a8e8ba63e8601c9e1560a00f67b320 100644 (file)
@@ -51,7 +51,7 @@ void Tfailed(const char *why);
 void Toutputerr(void);
 void Tnomem(void);
 void Tfsyscallr(const char *fmt, ...) PRINTFFORMAT(1,2);
-void Tensureoutputfile(void);
+void Tensurerecordfile(void);
 void Tmust(const char *call, const char *arg, int cond);
 
 void Tvbf(const char *fmt, ...) PRINTFFORMAT(1,2);
index 4a6293ae4fad5a14ba639375bf82e2728c28c740..3466ec98025648f29faff2be6bace386885734a7 100644 (file)
@@ -34,6 +34,7 @@ const struct Terrno Terrnos[]= {
 };
 static vbuf vbw;
 int Hgettimeofday(struct timeval *tv, struct timezone *tz) {
+  Tensurerecordfile();
   Tmust("gettimeofday","tz",!tz);
   *tv= currenttime;
   return 0;
@@ -92,6 +93,20 @@ void Qconnect(       int fd , const struct sockaddr *addr , int addrlen      ) {
        Tvba(" addr="); Tvbaddr(addr,addrlen); 
   Q_vb();
 }
+void Qbind(    int fd , const struct sockaddr *addr , int addrlen      ) {
+ vb.used= 0;
+ Tvba("bind");
+       Tvbf(" fd=%d",fd); 
+       Tvba(" addr="); Tvbaddr(addr,addrlen); 
+  Q_vb();
+}
+void Qlisten(  int fd , int backlog    ) {
+ vb.used= 0;
+ Tvba("listen");
+       Tvbf(" fd=%d",fd); 
+       Tvbf(" backlog=%d",backlog); 
+  Q_vb();
+}
 void Qclose(   int fd  ) {
  vb.used= 0;
  Tvba("close");
index 68127bea0ba3099ca0374990c9117e2119991fa7..17f6955a84cc122c3593799a733dc2b1c3907284 100644 (file)
@@ -61,12 +61,14 @@ const struct Terrno Terrnos[]= {
   { "ECONNRESET",                ECONNRESET                   },
   { "ECONNREFUSED",              ECONNREFUSED                 },
   { "EPIPE",                     EPIPE                        },
+  { "ENOTSOCK",                  ENOTSOCK                     },
   {  0,                          0                            }
 };
 
 static vbuf vbw;
 
 int Hgettimeofday(struct timeval *tv, struct timezone *tz) {
+  Tensurerecordfile();
   Tmust("gettimeofday","tz",!tz);
   *tv= currenttime;
   return 0;
index fdb3a7d307e17eecf699d30fa8ceec9e9b174e29..594f7e60decc9f68c6a302bf59e77d9edf0bdeb7 100644 (file)
@@ -32,7 +32,7 @@ static void Pcheckinput(void) {
   if (ferror(Tinputfile)) Tfailed("read test log input file");
   if (feof(Tinputfile)) Psyntax("eof at syscall reply");
 }
-static void Tensureinputfile(void) {
+void Tensurerecordfile(void) {
   const char *fdstr;
   int fd;
   int chars;
@@ -196,7 +196,7 @@ static int Pbytes(byte *buf, int maxlen) {
 void Q_vb(void) {
   int r;
   const char *nl;
-  Tensureinputfile();
+  Tensurerecordfile();
   if (!adns__vbuf_ensure(&vb2,vb.used+2)) Tnomem();
   r= fread(vb2.buf,1,vb.used+2,Tinputfile);
   if (feof(Tinputfile)) {
@@ -385,6 +385,60 @@ int Hconnect(      int fd , const struct sockaddr *addr , int addrlen      ) {
  P_updatetime();
  return r;
 }
+int Hbind(     int fd , const struct sockaddr *addr , int addrlen      ) {
+ int r, amtread;
+ Qbind(        fd , addr , addrlen     );
+ if (!adns__vbuf_ensure(&vb2,1000)) Tnomem();
+ fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput();
+ Tensurereportfile();
+ fprintf(Treportfile,"%s",vb2.buf);
+ amtread= strlen(vb2.buf);
+ if (amtread<=0 || vb2.buf[--amtread]!='\n')
+  Psyntax("badly formed line");
+ vb2.buf[amtread]= 0;
+ if (memcmp(vb2.buf," bind=",6)) Psyntax("syscall reply mismatch");
+ if (vb2.buf[6] == 'E') {
+  int e;
+  e= Perrno(vb2.buf+6);
+  P_updatetime();
+  errno= e;
+  return -1;
+ }
+  if (memcmp(vb2.buf+6,"OK",2)) Psyntax("success/fail not E* or OK");
+  vb2.used= 6+2;
+  r= 0;
+ assert(vb2.used <= amtread);
+ if (vb2.used != amtread) Psyntax("junk at end of line");
+ P_updatetime();
+ return r;
+}
+int Hlisten(   int fd , int backlog    ) {
+ int r, amtread;
+ Qlisten(      fd , backlog    );
+ if (!adns__vbuf_ensure(&vb2,1000)) Tnomem();
+ fgets(vb2.buf,vb2.avail,Tinputfile); Pcheckinput();
+ Tensurereportfile();
+ fprintf(Treportfile,"%s",vb2.buf);
+ amtread= strlen(vb2.buf);
+ if (amtread<=0 || vb2.buf[--amtread]!='\n')
+  Psyntax("badly formed line");
+ vb2.buf[amtread]= 0;
+ if (memcmp(vb2.buf," listen=",8)) Psyntax("syscall reply mismatch");
+ if (vb2.buf[8] == 'E') {
+  int e;
+  e= Perrno(vb2.buf+8);
+  P_updatetime();
+  errno= e;
+  return -1;
+ }
+  if (memcmp(vb2.buf+8,"OK",2)) Psyntax("success/fail not E* or OK");
+  vb2.used= 8+2;
+  r= 0;
+ assert(vb2.used <= amtread);
+ if (vb2.used != amtread) Psyntax("junk at end of line");
+ P_updatetime();
+ return r;
+}
 int Hclose(    int fd  ) {
  int r, amtread;
  Qclose(       fd      );
index 3437293d9a71fa651101386e65c3b55c0ad62c33..9fd0780071b7057c7a28064189e8917eb44fefd9 100644 (file)
@@ -69,7 +69,7 @@ static void Pcheckinput(void) {
   if (feof(Tinputfile)) Psyntax("eof at syscall reply");
 }
 
-static void Tensureinputfile(void) {
+void Tensurerecordfile(void) {
   const char *fdstr;
   int fd;
   int chars;
@@ -261,7 +261,7 @@ void Q_vb(void) {
   int r;
   const char *nl;
 
-  Tensureinputfile();
+  Tensurerecordfile();
   if (!adns__vbuf_ensure(&vb2,vb.used+2)) Tnomem();
   r= fread(vb2.buf,1,vb.used+2,Tinputfile);
   if (feof(Tinputfile)) {
index c60f93c2286c93782a8f1c915e1dcac6187d69e5..88e24a41f48925918a5601747e178098fd2df027 100644 (file)
@@ -12,7 +12,7 @@ void Tshutdown(void) {
 static void R_recordtime(void) {
   int r;
   struct timeval tv, tvrel;
-  Tensureoutputfile();
+  Tensurerecordfile();
   r= gettimeofday(&tv,0); if (r) Tfailed("gettimeofday syscallbegin");
   tvrel.tv_sec= tv.tv_sec - currenttime.tv_sec;
   tvrel.tv_usec= tv.tv_usec - currenttime.tv_usec;
@@ -20,7 +20,7 @@ static void R_recordtime(void) {
   Tvbf("\n +%ld.%06ld",(long)tvrel.tv_sec,(long)tvrel.tv_usec);
   currenttime= tv;
 }
-void Tensureoutputfile(void) {
+void Tensurerecordfile(void) {
   const char *fdstr;
   int fd, r;
   if (Toutputfile) return;
@@ -36,7 +36,7 @@ void Tensureoutputfile(void) {
 }
 void Q_vb(void) {
   if (!adns__vbuf_append(&vb,"",1)) Tnomem();
-  Tensureoutputfile();
+  Tensurerecordfile();
   if (fprintf(Toutputfile," %s\n",vb.buf) == EOF) Toutputerr();
   if (fflush(Toutputfile)) Toutputerr();
 }
@@ -142,6 +142,36 @@ int Hconnect(      int fd , const struct sockaddr *addr , int addrlen      ) {
  errno= e;
  return r;
 }
+int Hbind(     int fd , const struct sockaddr *addr , int addrlen      ) {
+ int r, e;
+ Qbind(        fd , addr , addrlen     );
+ r= bind(      fd , addr , addrlen     );
+ e= errno;
+ vb.used= 0;
+ Tvba("bind=");
+  if (r) { Tvberrno(e); goto x_error; }
+  Tvba("OK");
+ x_error:
+ R_recordtime();
+ R_vb();
+ errno= e;
+ return r;
+}
+int Hlisten(   int fd , int backlog    ) {
+ int r, e;
+ Qlisten(      fd , backlog    );
+ r= listen(    fd , backlog    );
+ e= errno;
+ vb.used= 0;
+ Tvba("listen=");
+  if (r) { Tvberrno(e); goto x_error; }
+  Tvba("OK");
+ x_error:
+ R_recordtime();
+ R_vb();
+ errno= e;
+ return r;
+}
 int Hclose(    int fd  ) {
  int r, e;
  Qclose(       fd      );
index e5287a0d09a383ece9533a1f3b54bd458b5b8f7c..033796c5c638ab7981bd51334c708dd301fdee1b 100644 (file)
@@ -45,7 +45,7 @@ static void R_recordtime(void) {
   int r;
   struct timeval tv, tvrel;
 
-  Tensureoutputfile();
+  Tensurerecordfile();
   r= gettimeofday(&tv,0); if (r) Tfailed("gettimeofday syscallbegin");
   tvrel.tv_sec= tv.tv_sec - currenttime.tv_sec;
   tvrel.tv_usec= tv.tv_usec - currenttime.tv_usec;
@@ -54,7 +54,7 @@ static void R_recordtime(void) {
   currenttime= tv;
 }
 
-void Tensureoutputfile(void) {
+void Tensurerecordfile(void) {
   const char *fdstr;
   int fd, r;
 
@@ -74,7 +74,7 @@ void Tensureoutputfile(void) {
 
 void Q_vb(void) {
   if (!adns__vbuf_append(&vb,"",1)) Tnomem();
-  Tensureoutputfile();
+  Tensurerecordfile();
   if (fprintf(Toutputfile," %s\n",vb.buf) == EOF) Toutputerr();
   if (fflush(Toutputfile)) Toutputerr();
 }
index 75506877c65ee222c7dbb810ada17556d2e400e9..fd2fa405116a0ed880a63b6e8a4df9ca84328543 100644 (file)
 #define fcntl Hfcntl
 #undef connect
 #define connect Hconnect
+#undef bind
+#define bind Hbind
+#undef listen
+#define listen Hlisten
 #undef close
 #define close Hclose
 #undef sendto
index 5d87442322241805d30456149ccba0cf4e4a015c..3e886be0a1b24a31f27f0ce62a437b0499a315b4 100644 (file)
@@ -15,6 +15,8 @@ int Hpoll(    struct pollfd *fds , int nfds , int timeout     );
 int Hsocket(   int domain , int type , int protocol    );
 int Hfcntl(    int fd , int cmd , ...  );
 int Hconnect(  int fd , const struct sockaddr *addr , int addrlen      );
+int Hbind(     int fd , const struct sockaddr *addr , int addrlen      );
+int Hlisten(   int fd , int backlog    );
 int Hclose(    int fd  );
 int Hsendto(   int fd , const void *msg , int msglen , unsigned int flags , const struct sockaddr *addr , int addrlen  );
 int Hrecvfrom( int fd , void *buf , int buflen , unsigned int flags , struct sockaddr *addr , int *addrlen     );
index d5a57b75e2ebd7085240cce3cb26531c35aa27ee..6be9556ccd473f9eacc85f7e707a0b2b79f76fa9 100644 (file)
@@ -88,6 +88,18 @@ hm_syscall(
        hm_arg_addr_in(addr,addrlen) hm_na
 ')
 
+hm_syscall(
+       bind, `hm_rv_succfail', `
+       hm_arg_fd(fd) hm_na
+       hm_arg_addr_in(addr,addrlen) hm_na
+')
+
+hm_syscall(
+       listen, `hm_rv_succfail', `
+       hm_arg_fd(fd) hm_na
+       hm_arg_int(backlog) hm_na
+')
+
 hm_syscall(
        close, `hm_rv_succfail', `
        hm_arg_fd(fd) hm_na
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>
-#    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
index 9be8b68d0b327d1bc8b15c2cef0ba1864254a3ad..f262d478ce38898a978d5089c519dff818d4f2e8 100644 (file)
@@ -118,7 +118,7 @@ typedef enum {
  adns_r_soa_raw=          6,
  adns_r_soa=                 adns_r_soa_raw|adns__qtf_mail822, 
                     
- adns_r_ptr_raw=         12,
+ adns_r_ptr_raw=         12, /* do not mind PTR with wrong or missing A */
  adns_r_ptr=                 adns_r_ptr_raw|adns__qtf_deref,
                     
  adns_r_hinfo=           13,