Back to index

courier  0.68.2
Defines | Functions
spf.h File Reference
#include "rfc1035/rfc1035.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define SPF_NONE   0
#define SPF_NEUTRAL   '?'
#define SPF_PASS   '+'
#define SPF_FAIL   '-'
#define SPF_SOFTFAIL   '~'
#define SPF_ERROR   '4'
#define SPF_UNKNOWN   '5'

Functions

char rfc1035_spf_lookup (const char *mailfrom, const char *tcpremoteip, const char *tcpremotehost, const char *helodomain, const char *mydomain, char *errmsg_buf, size_t errmsg_buf_size)

Define Documentation

#define SPF_ERROR   '4'

Definition at line 56 of file spf.h.

#define SPF_FAIL   '-'

Definition at line 54 of file spf.h.

#define SPF_NEUTRAL   '?'

Definition at line 52 of file spf.h.

#define SPF_NONE   0

Definition at line 51 of file spf.h.

#define SPF_PASS   '+'

Definition at line 53 of file spf.h.

#define SPF_SOFTFAIL   '~'

Definition at line 55 of file spf.h.

#define SPF_UNKNOWN   '5'

Definition at line 59 of file spf.h.


Function Documentation

char rfc1035_spf_lookup ( const char *  mailfrom,
const char *  tcpremoteip,
const char *  tcpremotehost,
const char *  helodomain,
const char *  mydomain,
char *  errmsg_buf,
size_t  errmsg_buf_size 
)

Definition at line 60 of file spf.c.

{
       size_t lookup_cnt=0;
       struct rfc1035_spf_info info;
       char result;

       if (!tcpremoteip) tcpremoteip="";
       if (!tcpremotehost) tcpremotehost="";
       if (!helodomain) helodomain="";
       if (!mydomain) mydomain="";

       if (errmsg_buf && errmsg_buf_size)
              *errmsg_buf=0;

       /*
       ** If the <responsible-sender> has no localpart, clients MUST
       ** substitute the string "postmaster" for the localpart.
       */
       if (strchr(mailfrom, '@') == NULL)
       {
              char *buf=malloc(sizeof("postmaster@")+strlen(mailfrom));
              char err_code;

              if (buf == NULL)
              {
                     set_err_msg(errmsg_buf, errmsg_buf_size,
                                strerror(errno));
                     return SPF_ERROR;
              }

              err_code=rfc1035_spf_lookup(strcat(strcpy(buf, "postmaster@"),
                                             mailfrom),
                                       tcpremoteip,
                                       tcpremotehost,
                                       helodomain,
                                       mydomain,
                                       errmsg_buf,
                                       errmsg_buf_size);
              free(buf);
              return err_code;
       }

       memset(&info, 0, sizeof(info));

       info.mailfrom=mailfrom;

       /*
       ** The <current-domain> is initially drawn from the
       ** <responsible-sender>.  Recursive mechanisms such as
       ** Include and Redirect replace the initial
       ** <current-domain> with another domain.  However, they
       ** do not change the value of the <responsible-sender>.
       */
       info.current_domain=strrchr(mailfrom, '@')+1;

       info.tcpremoteip=tcpremoteip;
       info.tcpremotehost=tcpremotehost;
       info.errmsg_buf=errmsg_buf;
       info.errmsg_buf_size=errmsg_buf_size;
       info.helodomain=helodomain;
       info.mydomain=mydomain;
       info.lookup_cnt=&lookup_cnt;

       rfc1035_init_resolv(&info.res);

       result=lookup(&info);

       if (errmsg_buf[0] == 0)
       {
              static const char errmsg[]="Address %s the Sender Policy Framework";
              char *p=malloc(sizeof(errmsg)+strlen(mailfrom)+20);

              if (p)
                     sprintf(p, errmsg, result == SPF_PASS
                            ? "passes":"does not pass");

              set_err_msg(errmsg_buf, errmsg_buf_size,
                         p ? p:strerror(errno));
              if (p) free(p);
       }
       rfc1035_destroy_resolv(&info.res);
       return result;
}

Here is the call graph for this function:

Here is the caller graph for this function: