Back to index

courier  0.68.2
Classes | Functions | Variables
bofh.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  bofh_list

Functions

void bofh_init ()
int bofh_chkbadfrom (const char *)
int bofh_chkspamtrap (const char *)
struct bofh_listbofh_chkfreemail (const char *)
int bofh_chkbadmx (const char *)
int bofh_checkspf (const char *envvarname, const char *defaultValue, const char *keyword)
int bofh_checkspf_status (const char *envvarname, const char *defaultValue, const char *keyword)

Variables

unsigned max_bofh
int max_bofh_ishard

Class Documentation

struct bofh_list

Definition at line 20 of file bofh.h.

Collaboration diagram for bofh_list:
Class Members
struct bofh_list * aliases
char * name
struct bofh_list * next

Function Documentation

int bofh_checkspf ( const char *  envvarname,
const char *  defaultValue,
const char *  keyword 
)

Definition at line 319 of file bofh.c.

{
       char buf[256];
       const char *p=getenv(envvarname);
       char *s;

       if (!p || !*p) p=defaultValue;

       buf[0]=0;
       strncat(buf, p, sizeof(buf)-1);

       for (s=buf; (s=strtok(s, ",")) != NULL; s=NULL)
              if (strcmp(s, keyword) == 0)
                     return 1;
       return 0;
}

Here is the caller graph for this function:

int bofh_checkspf_status ( const char *  envvarname,
const char *  defaultValue,
const char *  keyword 
)

Definition at line 341 of file bofh.c.

{
       if (bofh_checkspf(envvarname, defaultValue, "all") ||
           bofh_checkspf(envvarname, defaultValue, keyword))
              return 1;
       return 0;
}

Here is the call graph for this function:

int bofh_chkbadfrom ( const char *  )

Definition at line 212 of file bofh.c.

{
       return (chkbadlist(pp, bofh_badfrom));
}

Here is the call graph for this function:

int bofh_chkbadmx ( const char *  )

Definition at line 300 of file bofh.c.

{
       struct bofh_list *b;

       if (strncasecmp(p, "::ffff:", 7) == 0)
              p += 7;

       for (b=bofh_badmx; b; b=b->next)
       {
              if (strcmp(b->name, p) == 0)
                     return (1);
       }
       return (0);
}
struct bofh_list* bofh_chkfreemail ( const char *  ) [read]

Definition at line 275 of file bofh.c.

{
       char *p;
       struct bofh_list *b;

       pp=strrchr(pp, '@');
       if (!pp)
              return (NULL);
       p=courier_malloc(strlen(pp));
       ++pp;
       strcpy(p, pp);
       address_lower(p);

       for (b=bofh_freemail; b; b=b->next)
       {
              if (strcmp(b->name, p) == 0)
              {
                     free(p);
                     return (b);
              }
       }
       free(p);
       return (NULL);
}

Here is the call graph for this function:

int bofh_chkspamtrap ( const char *  )

Definition at line 217 of file bofh.c.

{
       return (chkbadlist(pp, bofh_spamtrap));
}

Here is the call graph for this function:

void bofh_init ( )

Definition at line 54 of file bofh.c.

{
       struct bofh_list *p;
       char buf[BUFSIZ];

       char *f=config_localfilename("bofh");
       FILE    *fp=fopen(f, "r");

       free(f);

       /* Just in case */
       while ((p=bofh_freemail) != 0)
       {
              bofh_freemail=p->next;
              bofh_free(p);
       }
       freemailp= &bofh_freemail;

       while ((p=bofh_spamtrap) != 0)
       {
              bofh_spamtrap=p->next;
              bofh_free(p);
       }
       spamtrapp= &bofh_spamtrap;
 
       while ((p=bofh_badmx) != 0)
       {
              bofh_badmx=p->next;
              bofh_free(p);
       }
       badmxp= &bofh_badmx;

       while ((p=bofh_badfrom) != 0)
       {
              bofh_badfrom=p->next;
              bofh_free(p);
       }
       badfromp= &bofh_badfrom;

       if (!fp)
              return;

       while (fgets(buf, sizeof(buf), fp))
       {
              char *p=strchr(buf, '\n');

              if (p) *p=0;

              p=strchr(buf, '#');
              if (p) *p=0;

              p=strtok(buf, " \t\r");

              if (!p)
                     continue;

              if (strcasecmp(p, "freemail") == 0)
              {
                     addbofh(&freemailp, &strlower, 1);
              }
              else if (strcasecmp(p, "spamtrap") == 0)
              {
                     addbofh(&spamtrapp, &address_lower, 0);
              }
              else if (strcasecmp(p, "badmx") == 0)
              {
                     addbofh(&badmxp, NULL, 0);
              }
              else if (strcasecmp(p, "badfrom") == 0)
              {
                     addbofh(&badfromp, &address_lower, 0);
              }
              else if (strcasecmp(p, "maxrcpts") == 0)
              {
                     char *q=strtok(NULL, " \t\r");
                     
                     if (q)
                     {
                            unsigned n=atoi(q);

                            if (n <= 0)
                                   n=max_bofh;

                            max_bofh=n;
                            q=strtok(NULL, " \t\r");
                     }

                     if (q)
                            max_bofh_ishard=strcasecmp(q, "hard") == 0;
              }
              else if (strcasecmp(p, "opt") == 0)
              {
                     char *env=strtok(NULL, " \t\r");
                     char *var;

                     if (!env)
                            continue;

                     var=courier_malloc(strlen(env)+1);
                     strcpy(var, env);

                     env=strchr(var, '=');
                     if (!env)
                     {
                            free(var);
                            continue;
                     }

                     *env=0;

                     if (getenv(var))     /* Variable already set */
                     {
                            free(var);
                            continue;
                     }
                     *env='=';
                     putenv(var);
              }
       }
       fclose(fp);
}

Here is the call graph for this function:


Variable Documentation

unsigned max_bofh

Definition at line 14 of file bofh.c.

Definition at line 15 of file bofh.c.