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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
'\" t
.\"<!-- Copyright 1998 - 2007 Double Precision, Inc. See COPYING for -->
.\"<!-- distribution information. -->
.\" Title: maildropgdbm
.\" Author: Sam Varshavchik
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\" Date: 06/20/2015
.\" Manual: Double Precision, Inc.
.\" Source: Courier Mail Server
.\" Language: English
.\"
.TH "MAILDROPGDBM" "7" "06/20/2015" "Courier Mail Server" "Double Precision, Inc\&."
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
maildropgdbm \- GDBM/DB support in maildrop
.SH "SYNOPSIS"
.sp
.nf
gdbmopen(filename, mode)
gdbmclose
gdbmfetch(key [,default])
gdbmstore(key,value)
.fi
.SH "DESCRIPTION"
.PP
The gdbm family of functions provides access to the GDBM library \- a library of routines that manage simple database files\&. The library provides a way of quickly storing and looking up key/data pairs\&.
.PP
GDBM support in
\fBmaildrop\fR
is optional, and may not be available to you\&.
.PP
GDBM support in
\fBmaildrop\fR
can optionally be implemented using the DB library\&. This option is selected by the system administrator\&. If this is the case, these functions still work exactly as described below, except that they will operate on DB hash files, instead of GDBM files\&.
.PP
To see whether GDBM or DB support is used, run the command "\fBmaildrop \-v"\fR\&.
.PP
GDBM support is minimal, and simplistic\&. A filter file may have only one gdbm file open at the same time\&. However, the filter file can close the current gdbm file, and open another one\&. If another filter file is included using the include statement, the included filter file may open its own, separate, gdbm file\&.
.PP
A GDBM file contains a list of key/value pairs\&. All keys in the GDBM file are unique\&. After storing an arbitrary key/value pair in the GDBM file, the value associated with the given key can be quickly located and retrieved\&.
.SS "gdbmclose \- close gdbm file"
.sp
.if n \{\
.RS 4
.\}
.nf
gdbmclose
.fi
.if n \{\
.RE
.\}
.PP
This function closes the current GDBM file\&.
.SS "gdbmfetch \- retrieve data"
.sp
.if n \{\
.RS 4
.\}
.nf
gdbmfetch (\fIkey\fR [, \fIoptions\fR] [, \fIdefault\fR])
.fi
.if n \{\
.RE
.\}
.PP
This function retrieves the data for the given key\&.
\fIkey\fR
is the key to retrieve\&. The
\fBgdbmfetch\fR
function returns the data associated with this key\&. If the key does not exist in the GDBM file,
\fBgdbmfetch\fR
returns the
\fBdefault\fR
argument\&. If the
\fBdefault\fR
argument is not specified,
\fBgdbmfetch\fR
returns empty text\&. Please note that the
\fBdefault\fR
argument is not actually evaluated unless the key does not exist in the GDBM file\&.
.PP
The
\fIoptions\fR
argument specifies additional
\fBmaildrop\fR
value\-added features\&. The following functionality is not available in the GDBM library, but is rather provided by
\fBmaildrop\fR\&.
.PP
If the
\fIoptions\fR
argument is set to "D", and the key could not be found in the GDBM database, and the key is of the form "user@domain",
\fBmaildrop\fR
will then attempt to look up the key "user@"\&. If that key is also not found,
\fBmaildrop\fR
finally looks up the key "domain"\&.
.PP
If "domain" is also not found, and domain is of the form "a\&.b\&.c\&.d\&.tld" (with variable number of period\-separated sections),
\fBmaildrop\fR
then attempts to look up the key "b\&.c\&.d\&.tld"\&. If that key is not found,
\fBmaildrop\fR
tries "c\&.d\&.tld", and so on, until a key is found, or there are no more subdomains to remove, at which point
\fBgdbmfetch\fR
will return either the
\fBdefault\fR
argument, or empty text\&.
.PP
If the
\fIoptions\fR
argument is set to "D", and the key could not be found in the GDBM database, and the key is of the form "a\&.b\&.c\&.d\&.tld" (with variable number of period\-separated sections),
\fBmaildrop\fR
will also attempt to look up keys for successive higher\-level domains in the GDBM database\&.
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
.PP
GDBM databases are case sensitive\&. Make sure that the GDBM database is created using lowercase letters only, and use the
\m[blue]\fB\fBtolower\fR\fR\m[]\&\s-2\u[1]\d\s+2
function to convert the key to lowercase\&.
.sp .5v
.RE
.PP
If the
\fIoptions\fR
argument is "I", and the key is not in the GDBM database, and the key is of the form "w\&.x\&.y\&.z" (with variable number of period\-separated sections),
\fBmaildrop\fR
then tries to look up the key "w\&.x\&.y", then "w\&.x", until a key is found, or there are no more sections to remove\&. Use this feature to look up IP\-address based GDBM lists\&.
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
.PP
These features are implemented by brute force: if the query doesn\*(Aqt succeed, try again\&. Take note of potential denial\-of\-service attacks where key is set to a long text string consisting mostly of periods, which will result in numerous GDBM queries that will take an excessive amount of time to complete\&.
.sp .5v
.RE
.SS "gdbmopen \- open gdbm file"
.sp
.if n \{\
.RS 4
.\}
.nf
gdbmopen (\fIfile\fR [, \fImode\fR])
.fi
.if n \{\
.RE
.\}
.PP
\fBgdbmopen\fR
opens the indicated GDBM file\&. The optional second argument specifies the following:
.PP
"R"
.RS 4
Open this GDBM file for reading\&.
.RE
.PP
"W"
.RS 4
Open this GDBM file for reading and writing\&.
.RE
.PP
"C"
.RS 4
Open this GDBM file for reading and writing\&. If the GBDM file doesn\*(Aqt exist, create it\&.
.RE
.PP
"N"
.RS 4
Create a new GDBM file\&. If the file exists, the existing file is deleted\&. The file is opened for reading and writing\&.
.RE
.PP
The
\fImode\fR
argument defaults to
"R"
is used\&. In embedded mode, only
"R"
is allowed\&.
.PP
The GDBM library allows multiple processes to read the same GDBM file at the same time, but it does not allow multiple access when the GDBM file is open for writing\&. Using
\m[blue]\fB\fBflock\fR\fR\m[]\&\s-2\u[2]\d\s+2
or
\m[blue]\fB\fBdotlock\fR\fR\m[]\&\s-2\u[3]\d\s+2
is highly recommended\&.
.PP
In delivery mode,
\fBmaildrop\fR
runs from the recipient\*(Aqs home directory\&. Keep that in mind while specifying the filename\&.
.PP
The gdbmopen function returns 0 if the GDBM file was successfully opened, non\-zero otherwise\&.
.SS "gdbmstore \- store data"
.sp
.if n \{\
.RS 4
.\}
.nf
gdbmstore(\fIkey\fR, \fIvalue\fR)
.fi
.if n \{\
.RE
.\}
.PP
\fIkey\fR
is the key value to store in the GDBM file\&.
\fIvalue\fR
is the value to store\&. If
\fIkey\fR
already exists in the GDBM file,
\fIvalue\fR
replacest the old value\&. The
\fBgdbmstore\fR
function is only permitted if the GDBM file is opened for writing\&. If
\fIgdbmopen\fR
opened the GDBM file for reading only,
\fBgdbmstore\fR
will return \-1\&. Otherwise,
\fBgdbmstore\fR
returns 0\&.
.SH "AUTHOR"
.PP
\fBSam Varshavchik\fR
.RS 4
Author
.RE
.SH "NOTES"
.IP " 1." 4
\fBtolower\fR
.RS 4
\%http://www.courier-mta.org/maildrop/maildropfilter.html#tolower
.RE
.IP " 2." 4
\fBflock\fR
.RS 4
\%http://www.courier-mta.org/maildrop/maildropfilter.html#flock
.RE
.IP " 3." 4
\fBdotlock\fR
.RS 4
\%http://www.courier-mta.org/maildrop/maildropfilter.html#dotlock
.RE
|