[exim-cvs] cvs commit: exim/exim-src/scripts MakeLinks exim…

Góra strony
Delete this message
Reply to this message
Autor: Tom Kistner
Data:  
Dla: exim-cvs
Temat: [exim-cvs] cvs commit: exim/exim-src/scripts MakeLinks exim/exim-src/src drtables.c spf.c exim/exim-src/src/lookups Makefile spf.c spf.h
tom 2005/05/25 21:07:55 BST

  Modified files:
    exim-src/scripts     MakeLinks 
    exim-src/src         drtables.c spf.c 
    exim-src/src/lookups Makefile 
  Added files:
    exim-src/src/lookups spf.c spf.h 
  Log:
  Add simple SPF lookup method (armored in EXPERIMENTAL_SPF)


  Revision  Changes    Path
  1.4       +2 -0      exim/exim-src/scripts/MakeLinks
  1.4       +21 -0     exim/exim-src/src/drtables.c
  1.3       +2 -1      exim/exim-src/src/lookups/Makefile
  1.1       +75 -0     exim/exim-src/src/lookups/spf.c (new)
  1.1       +26 -0     exim/exim-src/src/lookups/spf.h (new)
  1.5       +1 -1      exim/exim-src/src/spf.c


  Index: MakeLinks
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/scripts/MakeLinks,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MakeLinks    8 Mar 2005 15:32:02 -0000    1.3
  +++ MakeLinks    25 May 2005 20:07:55 -0000    1.4
  @@ -1,5 +1,5 @@
   #!/bin/sh
  -# $Cambridge: exim/exim-src/scripts/MakeLinks,v 1.3 2005/03/08 15:32:02 tom Exp $
  +# $Cambridge: exim/exim-src/scripts/MakeLinks,v 1.4 2005/05/25 20:07:55 tom Exp $


   # Script to build links for all the exim source files from the system-
   # specific build directory. It should be run from within that directory.
  @@ -74,6 +74,8 @@
   ln -s ../../src/lookups/passwd.c         passwd.c
   ln -s ../../src/lookups/pgsql.h          pgsql.h
   ln -s ../../src/lookups/pgsql.c          pgsql.c
  +ln -s ../../src/lookups/spf.h            spf.h
  +ln -s ../../src/lookups/spf.c            spf.c
   ln -s ../../src/lookups/testdb.h         testdb.h
   ln -s ../../src/lookups/testdb.c         testdb.c
   ln -s ../../src/lookups/whoson.h         whoson.h


  Index: drtables.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/drtables.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- drtables.c    24 May 2005 08:15:02 -0000    1.3
  +++ drtables.c    25 May 2005 20:07:55 -0000    1.4
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/drtables.c,v 1.3 2005/05/24 08:15:02 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/drtables.c,v 1.4 2005/05/25 20:07:55 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -89,6 +89,10 @@
   #include "lookups/pgsql.h"
   #endif


  +#ifdef EXPERIMENTAL_SPF
  +#include "lookups/spf.h"
  +#endif
  +
   #ifdef LOOKUP_TESTDB
   #include "lookups/testdb.h"
   #endif
  @@ -434,6 +438,23 @@
     pgsql_quote                    /* quoting function */
   #else
     NULL, NULL, NULL, NULL, NULL, NULL   /* lookup not present */
  +#endif
  +  },
  +
  +/* SPF lookup */
  +
  +  {
  +  US"spf",                       /* lookup name */
  +  0,                             /* not absfile, not query style */
  +#ifdef EXPERIMENTAL_SPF
  +  spf_open,                      /* open function */
  +  NULL,                          /* no check function */
  +  spf_find,                      /* find function */
  +  spf_close,                     /* close function */
  +  NULL,                          /* no tidy function */
  +  NULL                           /* no quoting function */
  +#else
  +  NULL, NULL, NULL, NULL, NULL, NULL /* lookup not present */
   #endif
     },



  Index: spf.c
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/spf.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- spf.c    24 May 2005 08:15:02 -0000    1.4
  +++ spf.c    25 May 2005 20:07:55 -0000    1.5
  @@ -1,4 +1,4 @@
  -/* $Cambridge: exim/exim-src/src/spf.c,v 1.4 2005/05/24 08:15:02 tom Exp $ */
  +/* $Cambridge: exim/exim-src/src/spf.c,v 1.5 2005/05/25 20:07:55 tom Exp $ */


   /*************************************************
   *     Exim - an Internet mail transport agent    *
  @@ -25,7 +25,7 @@
   int spf_init(uschar *spf_helo_domain, uschar *spf_remote_addr) {
     uschar *p;


- spf_server = SPF_server_new(SPF_DNS_CACHE, 1);
+ spf_server = SPF_server_new(SPF_DNS_CACHE, 0);

     if ( spf_server == NULL ) {
       debug_printf("spf: SPF_server_new() failed.\n");


Index: spf.c
====================================================================
/* $Cambridge: exim/exim-src/src/lookups/spf.c,v 1.1 2005/05/25 20:07:55 tom Exp $ */

  /*************************************************
  *     Exim - an Internet mail transport agent    *
  *************************************************/


/*
* Exim - SPF lookup module using libspf2
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* Copyright (c) 2005 Chris Webb, Arachsys Internet Services Ltd
*
* 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
* of the License, or (at your option) any later version.
*
*/

#include "../exim.h"

#ifndef EXPERIMENTAL_SPF
static void dummy(int x) { dummy(x-1); }
#else

#include "lf_functions.h"
#include "spf.h"
#include <spf2/spf.h>
#include <spf2/spf_dns_resolv.h>
#include <spf2/spf_dns_cache.h>

  void *spf_open(uschar *filename, uschar **errmsg) {
    SPF_server_t *spf_server = NULL;
    spf_server = SPF_server_new(SPF_DNS_CACHE, 0);
    if (spf_server == NULL) {
      *errmsg = US"SPF_server_new() failed";
      return NULL;
    }
    return (void *) spf_server;
  }


  void spf_close(void *handle) {
    SPF_server_t *spf_server = handle;
    if (spf_server) SPF_server_free(spf_server);
  }


  int spf_find(void *handle, uschar *filename, uschar *keystring, int key_len,
               uschar **result, uschar **errmsg, BOOL *do_cache) {
    SPF_server_t *spf_server = handle;
    SPF_request_t *spf_request = NULL;
    SPF_response_t *spf_response = NULL;


    spf_request = SPF_request_new(spf_server);
    if (spf_request == NULL) {
      *errmsg = US"SPF_request_new() failed";
      return FAIL;
    }


    if (SPF_request_set_ipv4_str(spf_request, filename)) {
      *errmsg = string_sprintf("invalid IP address '%s'", filename);
      return FAIL;
    }
    if (SPF_request_set_env_from(spf_request, keystring)) {
      *errmsg = string_sprintf("invalid envelope from address '%s'", keystring);
      return FAIL;
    }


    SPF_request_query_mailfrom(spf_request, &spf_response);
    *result = string_copy(US SPF_strresult(SPF_response_result(spf_response)));
    SPF_response_free(spf_response);
    SPF_request_free(spf_request);
    return OK;
  }


#endif /* EXPERIMENTAL_SPF */

Index: spf.h
====================================================================
/* $Cambridge: exim/exim-src/src/lookups/spf.h,v 1.1 2005/05/25 20:07:55 tom Exp $ */

  /*************************************************
  *     Exim - an Internet mail transport agent    *
  *************************************************/


/*
* Exim - SPF lookup module using libspf2
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* Copyright (c) 2005 Chris Webb, Arachsys Internet Services Ltd
*
* 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
* of the License, or (at your option) any later version.
*
*/



  extern void *spf_open(uschar *, uschar **);
  extern void spf_close(void *);
  extern int spf_find(void *, uschar *, uschar *, int, uschar **, uschar **,
                      BOOL *);



  Index: Makefile
  ===================================================================
  RCS file: /home/cvs/exim/exim-src/src/lookups/Makefile,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Makefile    17 May 2005 09:53:35 -0000    1.2
  +++ Makefile    25 May 2005 20:07:55 -0000    1.3
  @@ -1,4 +1,4 @@
  -# $Cambridge: exim/exim-src/src/lookups/Makefile,v 1.2 2005/05/17 09:53:35 ph10 Exp $
  +# $Cambridge: exim/exim-src/src/lookups/Makefile,v 1.3 2005/05/25 20:07:55 tom Exp $


# Make file for building a library containing all the available lookups and
# calling it lookups.a. This is called from the main make file, after cd'ing
@@ -6,7 +6,7 @@
# defined, dummy modules get compiled.

   OBJ = cdb.o dbmdb.o dnsdb.o dsearch.o ibase.o ldap.o lsearch.o mysql.o nis.o \
  -      nisplus.o oracle.o passwd.o pgsql.o testdb.o whoson.o lf_check_file.o \
  +      nisplus.o oracle.o passwd.o pgsql.o spf.o testdb.o whoson.o lf_check_file.o \
         lf_quote.o


   lookups.a:       $(OBJ)
  @@ -36,6 +36,7 @@
   oracle.o:        $(HDRS) oracle.c    oracle.h
   passwd.o:        $(HDRS) passwd.c    passwd.h
   pgsql.o:         $(HDRS) pgsql.c     pgsql.h
  +spf.o:           $(HDRS) spf.c       spf.h
   testdb.o:        $(HDRS) testdb.c    testdb.h
   whoson.o:        $(HDRS) whoson.c    whoson.h