Qsmtp
0.30dev
|
function to get domain directory of vpopmail virtual domain More...
#include <qsmtpd/vpop.h>
#include <cdb.h>
#include <control.h>
#include <diropen.h>
#include <qsmtpd/addrparse.h>
#include <qsmtpd/qsmtpd.h>
#include <qsmtpd/userconf.h>
#include <qsmtpd/userfilters.h>
#include <sstring.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
Functions | |
int | vget_dir (const char *domain, struct userconf *ds) |
query the users/cdb file for information about this domain More... | |
static int | qmexists (int domaindirfd, const char *suff1, const size_t len, const int def, int *fd) |
check if a .qmail file exists for the user More... | |
int | user_exists (const string *localpart, const char *domain, struct userconf *dsp) |
check if the user identified by localpart and ds->domainpath exists More... | |
int | userbackend_init (void) |
initialize the backend to query for local users More... | |
void | userbackend_free (void) |
free the resources needed by the user backend | |
void | userconf_init (struct userconf *ds) |
initialize the struct userconf More... | |
void | userconf_free (struct userconf *ds) |
free all information in a struct userconf More... | |
int | userconf_load_configs (struct userconf *ds) |
load the filter settings for user and domain More... | |
int | userconf_get_buffer (const struct userconf *ds, const char *key, char ***values, checkfunc cf, const unsigned int flags) |
get a config buffer for a given user or domain More... | |
int | userconf_find_domain (const struct userconf *ds, const char *key, const char *domain, const unsigned int flags) |
find a domain in the user configuration key More... | |
Variables | |
static char * | vpopbounce |
static struct userconf | uconf |
function to get domain directory of vpopmail virtual domain
|
static |
check if a .qmail file exists for the user
domaindirfd | descriptor of the domain directory |
suff1 | the suffix to test (e.g. localpart), may be NULL when def is 1 |
len | length of suff1 |
def | which suffixes to use (logically or'ed)
|
fd | file descriptor of .qmail file is returned here if argument is not NULL |
0 | file does not exist |
1 | file exists |
<0 | error code from opening the file |
The contents of fd are undefined if the return value is not 1.
check if the user identified by localpart and ds->domainpath exists
localpart | localpart of mail address |
domain | domainpart of the domain |
ds | path of domain |
0 | user doesn't exist |
1 | user exists |
2 | mail would be catched by .qmail-default and .qmail-default != vpopbounce |
3 | domain is not filtered (use for domains not local) |
4 | mail would be catched by .qmail-foo-default (i.e. mailinglist) |
5 | domain is not local |
<0 | error code |
If the user has it's own mail directory ds->userpath will be filled with the correct values.
This function must be implemented by the password backend (i.e. currently vpop.c).
int userbackend_init | ( | void | ) |
initialize the backend to query for local users
0 | backend was successfully initialized |
>0 | error code |
int userconf_find_domain | ( | const struct userconf * | ds, |
const char * | key, | ||
const char * | domain, | ||
const unsigned int | flags | ||
) |
find a domain in the user configuration key
ds | the userconf buffer |
key | the key name for lookup |
domain | the domain name to search for |
flags | search flags |
CONFIG_NONE | the domain was not found in the configuration |
>0 | the domain was found in the configuration |
<0 | negative error code |
void userconf_free | ( | struct userconf * | ds | ) |
free all information in a struct userconf
ds | the struct to clear |
This will not free the struct itself so it is safe to use a static or stack allocated struct. It will reset all values to a safe value so the struct can be reused.
int userconf_get_buffer | ( | const struct userconf * | ds, |
const char * | key, | ||
char *** | values, | ||
checkfunc | cf, | ||
const unsigned int | flags | ||
) |
get a config buffer for a given user or domain
ds | the userconf buffer |
key | the key name to load the information for |
values | the result array |
cf | a function to filter the entries (may be NULL) |
flags | search flags |
<0 | negative error code |
void userconf_init | ( | struct userconf * | ds | ) |
initialize the struct userconf
ds | the struct to initialize |
All fields of the struct are reset to a safe invalid value.
int userconf_load_configs | ( | struct userconf * | ds | ) |
load the filter settings for user and domain
ds | the userconf buffer to hold the information |
0 | filters were loaded (or no configuration is present) |
>0 | error code |
int vget_dir | ( | const char * | domain, |
struct userconf * | ds | ||
) |
query the users/cdb file for information about this domain
domain | the domain to query |
ds | pointer to userconf struct holding the domain info |
0 | domain is not in database |
1 | domain was found |
<0 | negative error code |
-EDONE | the error was already handled |
Function will return 1 on success, memory for domaindir will be malloced. The directory name will always end with a single '/' and be 0-terminated. If the domain does not exist 0 is returned, also if no users/cdb exists. On error a negative error code is returned.
If ds already contains information about the same domain directory then the already existing information is preserved.
|
static |
global userconfig cache
|
static |
the bounce command in vpopmails .qmail-default