Qsmtp  0.30dev
Macros | Typedefs | Enumerations | Functions | Variables
userfilters.h File Reference

common function definitions for all user filters More...

#include "qsmtpd.h"
#include <sstring.h>
#include <sys/queue.h>
#include <sys/types.h>

Go to the source code of this file.

Macros

#define THISRCPT   (thisrecip->to.s)
 

Typedefs

typedef enum filter_result(* rcpt_cb) (const struct userconf *ds, const char **logmsg, enum config_domain *t)
 this is a function for a user filter More...
 

Enumerations

enum  config_domain { CONFIG_NONE = 0, CONFIG_USER = 1, CONFIG_DOMAIN = 2, CONFIG_GLOBAL = 4 }
 describe where the domain a read config value is originating from More...
 
enum  filter_result {
  FILTER_ERROR = -1, FILTER_PASSED = 0, FILTER_DENIED_WITH_MESSAGE = 1, FILTER_DENIED_UNSPECIFIC = 2,
  FILTER_DENIED_NOUSER = 3, FILTER_DENIED_TEMPORARY = 4, FILTER_WHITELISTED = 5
}
 describes the result of a policy filter More...
 

Functions

int getfile (const struct userconf *ds, const char *fn, enum config_domain *type, const unsigned int flags)
 
long getsetting (const struct userconf *, const char *, enum config_domain *)
 
long getsettingglobal (const struct userconf *, const char *, enum config_domain *)
 
static int filter_denied (const enum filter_result r)
 check if the given filter code was a denied code More...
 
void logwhitelisted (const char *, const int, const int)
 

Variables

const char ** globalconf
 
rcpt_cb rcpt_cbs []
 
rcpt_cb late_rcpt_cbs []
 
const char * blocktype []
 

Detailed Description

common function definitions for all user filters

Typedef Documentation

rcpt_cb

this is a function for a user filter

Parameters
dsthe struct with the paths of domain- and userpath
logmsgstore here a reference to the message to write into logfile or NULL if you logged yourself
typewhich policy matched (user, domain, global)
Returns
filter result codes as in enum filter_result

Enumeration Type Documentation

describe where the domain a read config value is originating from

Enumerator
CONFIG_NONE 

no entry was returned

CONFIG_USER 

the config entry was found in the user specific configuration

CONFIG_DOMAIN 

the config entry was found in the domain specific configuration

CONFIG_GLOBAL 

the config entry was found in the global configuration

describes the result of a policy filter

Enumerator
FILTER_ERROR 

error during processing, errno is set

FILTER_PASSED 

filter passed

FILTER_DENIED_WITH_MESSAGE 

filter denied, network message has already been sent

FILTER_DENIED_UNSPECIFIC 

filter denied, caller should announce general policy error

FILTER_DENIED_NOUSER 

filter denied, caller should announce user does not exist

FILTER_DENIED_TEMPORARY 

filter denied temporarily, a transient error message should be given by the caller

FILTER_WHITELISTED 

filter passed, the mail is whitelisted and should not be rejected by any other filter

Function Documentation

static int filter_denied ( const enum filter_result  r)
inlinestatic

check if the given filter code was a denied code

Parameters
rthe code to check
int getfile ( const struct userconf ds,
const char *  fn,
enum config_domain type,
const unsigned int  flags 
)

check in user and domain directory if a file with given filename exists

Parameters
dsstrings of user and domain directory
fnfilename to search
typeif user, domain or global directory matched, undefined if result != 1
flagssearch flags
Returns
file descriptor of opened file
Return values
-1on error (errno is set)
See also
userconf_flags for values passed in flags
long getsetting ( const struct userconf ds,
const char *  flag,
enum config_domain type 
)

get setting from user or domain filterconf file

Parameters
dsstruct with the user/domain config info
flagname of the setting to find (case sensitive)
typeif user or domain directory matched, undefined if result != 1)
Returns
value of setting
Return values
1boolean setting or no number given
0setting not found
-1on syntax error
long getsettingglobal ( const struct userconf ds,
const char *  flag,
enum config_domain type 
)

use getsetting and fall back to /var/qmail/control if this finds nothing

Parameters
dsstruct with the user/domain config info
flagname of the setting to find (case sensitive)
typeif user, domain or global file matched, undefined if result != 1
Returns
value of setting
Return values
1boolean setting or no number given
0setting not found
-1on syntax error
void logwhitelisted ( const char *  reason,
const int  t,
const int  u 
)

write message to syslog that a otherwise rejected mail has been passed because of whitelisting

Parameters
reasonreason of whitelisting
twhich type of filter caused blacklisting
uwhich type of filter caused whitelisting

Variable Documentation

const char* blocktype[]

string constants for the type of blocklists

const char** globalconf

contents of the global "filterconf" file (or NULL)

rcpt_cb rcpt_cbs[]

the user filters will be called in the order in this array