1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
/*
$Id: dbmail.h 2017 2006-03-07 05:58:02Z aaron $
Copyright (C) 1999-2004 IC & S dbmail@ic-s.nl
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/**
* \file dbmail.h
* header file for a general configuration
*/
#ifndef _DBMAIL_H
#define _DBMAIL_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#else
#define VERSION "2.2"
#define PACKAGE "dbmail"
#endif
#define _XOPEN_SOURCE /* glibc2 */
#define __EXTENSIONS__ /* solaris */
#include <assert.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <fnmatch.h>
#include <gmime/gmime.h>
#include <glib.h>
#include <grp.h>
#include <limits.h>
#include <netinet/in.h>
#include <netdb.h>
#include <pwd.h>
#include <signal.h>
#include <syslog.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sysexits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <time.h>
#include <termios.h>
#include <unistd.h>
#ifdef AUTHLDAP
#define LDAP_DEPRECATED 1
#include <ldap.h>
#endif
#include "dbmailtypes.h"
#include "debug.h"
#include "dsn.h"
#include "acl.h"
#include "misc.h"
#include "pipe.h"
#include "db.h"
#include "auth.h"
#include "sort.h"
#include "imap4.h"
#include "imapcommands.h"
#include "memblock.h"
#include "server.h"
#include "serverchild.h"
#include "serverparent.h"
#include "pool.h"
#include "pop3.h"
#include "quota.h"
#include "lmtp.h"
#include "dm_md5.h"
#include "dm_cidr.h"
#include "dm_imaputil.h"
#include "dm_base64.h"
#include "dm_getopt.h"
#include "dm_match.h"
#ifdef SIEVE
#include <sieve2.h>
#include <sieve2_error.h>
#endif
#include "timsieve.h"
#ifdef HAVE_CRYPT_H
#include <crypt.h>
#endif
#ifdef HAVE_ENDIAN_H
#include <endian.h>
#endif
#include "dbmail-message.h"
#include "dbmail-user.h"
#include "dbmail-mailbox.h"
#include "dbmail-imapsession.h"
#define GETCONFIGVALUE(key, sect, var) \
config_get_value(key, sect, var); \
if (strlen(var) == 0) \
TRACE(TRACE_DEBUG, "no value for "#key" in section "#sect); \
TRACE(TRACE_DEBUG, "key "#key" section "#sect" var "#var" value [%s]", var)
/* No final ';' so macro can be called "like a function" */
#define CONFIG_ERROR_LEVEL TRACE_WARNING
#define COPYRIGHT \
"Copyright (C) 1999-2004 IC & S, dbmail@ic-s.nl\n" \
"Copyright (C) 2001-2007 Aaron Stone, aaron@serendipity.cx\n" \
"Copyright (C) 2004-2007 NFG Net Facilities Group BV, support@nfg.nl\n" \
"\n" \
"Please see the AUTHORS and THANKS files for additional contributors.\n" \
"\n" \
"This program is free software; you can redistribute it and/or \n" \
"modify it under the terms of the GNU General Public License as\n" \
"published by the Free Software Foundation; either version 2 of\n" \
"the License, or (at your option) any later version.\n" \
"\n" \
"This program is distributed in the hope that it will be useful,\n" \
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" \
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" \
"GNU General Public License for more details.\n" \
"\n" \
"You should have received a copy of the GNU General Public License\n" \
"along with this program; if not, write to the Free Software\n" \
"Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n" \
""
/** default directory and extension for pidfiles */
#define DEFAULT_PID_DIR "@DM_STATEDIR@"
#define DEFAULT_PID_EXT ".pid"
#define DEFAULT_STATE_DIR "@DM_STATEDIR@"
#define DEFAULT_STATE_EXT ".state"
/** default configuration file */
#define DEFAULT_CONFIG_FILE "@DM_CONFDIR@/dbmail.conf"
/** default log files */
#define DEFAULT_LOG_FILE "@DM_LOGDIR@/dbmail.log"
#define DEFAULT_ERROR_LOG "@DM_LOGDIR@/dbmail.err"
/** prefix for #Users namespace */
#define NAMESPACE_USER "#Users"
/** prefix for public namespace */
#define NAMESPACE_PUBLIC "#Public"
/** seperator for namespaces and mailboxes and submailboxes */
#define MAILBOX_SEPARATOR "/"
/** username for owner of public folders */
// FIXME: Should be #define PUBLIC_FOLDER_USER "__@!internal_public_user!@__"
#define PUBLIC_FOLDER_USER "__public__"
/* name of internal delivery user. */
#define DBMAIL_DELIVERY_USERNAME "__@!internal_delivery_user!@__"
/* standard user for ACL anyone (see RFC 2086 and 4314) */
#define DBMAIL_ACL_ANYONE_USER "anyone"
/* Consumers of this should be using POSTMASTER from dbmail.conf! */
#define DEFAULT_POSTMASTER "DBMAIL-MAILER@dbmail"
#define AUTO_NOTIFY_SENDER "autonotify@dbmail"
#define AUTO_NOTIFY_SUBJECT "NEW MAIL NOTIFICATION"
/* input reading linelimit */
#define MAX_LINESIZE (65*1024)
/** default table prefix */
#define DEFAULT_DBPFX "dbmail_"
#define MATCH(x,y) strcasecmp((x),(y))==0
#define min(x,y) ((x)<=(y)?(x):(y))
#define max(x,y) ((x)>=(y)?(x):(y))
/**
* \brief read configuration from filename
* \param cfilename name of configuration file
* \return
* - -1 on error
* - 0 on success
*/
int config_read(const char *config_filename);
/**
* free all memory taken up by config.
*/
void config_free(void);
/**
* \brief get configuration value for an item
* \param name name of configuration item
* \param service_name name of service
* \param value value of configuration item name
* \return 0
* \attention value is set to a string beginning with a '\\0'
* if no configuration item with name is found in items.
*/
int config_get_value(const field_t name, const char *service_name,
/*@out@*/ field_t value);
/* some common used functions reading config options */
/**
\brief get parameters for database connection
\param db_params list of database parameters (db_param_t)
*/
void GetDBParams(db_param_t * db_params);
/**
\brief set the overall trace level, using the value in cfg_items
\param service_name name of service to get trace level for.
\attention trace level is set to TRACE_ERROR if no trace level value is found
* for service.
*/
void SetTraceLevel(const char *service_name);
void pidfile_create(const char *pidFile, pid_t pid);
void config_get_logfiles(serverConfig_t *config);
char * config_get_pidfile(serverConfig_t *config, const char *name);
char * config_get_statefile(serverConfig_t *config, const char *name);
#endif
|