'\" t .\" .\" .\" Title: maildropgdbm .\" Author: Sam Varshavchik .\" Generator: DocBook XSL Stylesheets v1.78.1 .\" 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