|
@@ -0,0 +1,663 @@
+diff -urpN -x ,,build greylisting-spp-1.0.1-stock/doc/README greylisting-spp-1.0.1/doc/README
+--- greylisting-spp-1.0.1-stock/doc/README 2008-04-27 20:27:48.000000000 +0000
++++ greylisting-spp-1.0.1/doc/README 2008-10-30 17:37:35.000000000 +0000
+@@ -81,6 +81,12 @@ logging output:
+ output ends up. The output of GL_DEBUG includes that of
+ GL_VERBOSE.
+
++Additional:
++
++ - GL_WHITELISTNEARBY If set (to any value), the plugin will whitelist
++ a whole /24 (if IPv4) or /112 (if IPv6) after a triple
++ in a subnet is successful.
++
+
+ Status
+ ======
+@@ -114,6 +120,8 @@ Version 1.0 is identical to 0.3
+ Version 1.0.1 fixes a bug when GL_DEBUG and RELAYCLIENT are both set.
+ Thanks to Jacek Trzcinski for the patch!
+
++Version 1.xxx adds support for SQLite version 3 and GL_WHITELISTNEARBY.
++
+
+ Downloading
+ ===========
+@@ -142,9 +150,10 @@ name on your platform. Or not at all.
+
+ By default, the flat-file database implementation will be used. If you want
+ to use one of the other implementations, specify the "DB_IMPL" parameter
+-to the make command, i. e. "make DB_IMPL=bdb" for Berkeley DB or
+-"make DB_IMPL=sqlite" for the SQLite interface. Needless to say, the respective
+-libraries and header files must be present on your system. See
++to the make command, i. e. "make DB_IMPL=bdb" for Berkeley DB,
++"make DB_IMPL=sqlite" for SQLite version 2, "make DB_IMPL=sqlite3" for SQLite
++version 3. Needless to say, the respective libraries and header files must be
++present on your system. See
+
+ README.db-file,
+ README.db-bdb or
+diff -urpN -x ,,build greylisting-spp-1.0.1-stock/doc/README.db-sqlite greylisting-spp-1.0.1/doc/README.db-sqlite
+--- greylisting-spp-1.0.1-stock/doc/README.db-sqlite 2008-04-27 20:10:53.000000000 +0000
++++ greylisting-spp-1.0.1/doc/README.db-sqlite 2008-10-30 17:25:48.000000000 +0000
+@@ -2,8 +2,7 @@ SQLite
+ ======
+
+ This database implementation relies on the "SQLite" library and should work
+-with version 2.x of the libary (which is the "stable" branch at the time
+-this was written).
++with version 2.x and 3.x of the libary.
+ See http://www.sqlite.org/ for more information about SQLite.
+
+ The GL_DATABASE environment variable must be set to the full path of the
+@@ -11,10 +10,11 @@ file containing the greylisting database
+ the plugin will automatically try to create it (which requires appropriate
+ permissions on the directory).
+
+-The database contents can be viewed with the "sqlite" command line utility:
++The database contents can be viewed with the "sqlite"/"sqlite3" command
++line utility:
+
+-$ sqlite ,,build/test/dbdir/testdb
+-SQLite version 2.8.15
++$ sqlite3 ,,build/test/dbdir/testdb
++SQLite version 3.5.9
+ Enter ".help" for instructions
+ sqlite> select * from gl_greylist;
+ 192.168.16.1|junk@tivano.de|junk@tivano.de|+|414868b9
+@@ -25,6 +25,13 @@ sqlite> select * from gl_greylist;
+ 192.168.16.1|bugtraq-return-$-conrad=tivano.de@securityfocus.com|junk01@tivano.de|+|414868bd
+ sqlite>
+
++It is recommended that you periodically vacuum the database to free up
++unused space. Consider adding the following to your /etc/crontab or
++equivalent:
++
++# VACUUM greylisting database daily.
++00 00 * * * root sqlite3 /var/qmail/greylisting/db-file VACUUM
++
+
+ Status
+ ------
+diff -urpN -x ,,build greylisting-spp-1.0.1-stock/doc/README.html greylisting-spp-1.0.1/doc/README.html
+--- greylisting-spp-1.0.1-stock/doc/README.html 2008-04-27 20:28:03.000000000 +0000
++++ greylisting-spp-1.0.1/doc/README.html 2008-10-30 17:38:05.000000000 +0000
+@@ -98,6 +98,14 @@ logging output:
+ output ends up. The output of GL_DEBUG includes that of
+ GL_VERBOSE.
+ </dd></dl>
++<p>
++Additional:
++</p>
++<dl>
++<dt>GL_WHITELISTNEARBY</dt><dd>If set (to any value), the plugin will whitelist
++ a whole /24 (if IPv4) or /112 (if IPv6) after a triple
++ in a subnet is successful.
++</dd></dl>
+
+ <h2>Status</h2>
+ <p>
+@@ -129,6 +137,8 @@ Version 1.0 is identical to 0.3
+ </p><p>
+ Version 1.0.1 fixes a bug when GL_DEBUG and RELAYCLIENT are both set.
+ Thanks to Jacek Trzcinski for the patch!
++</p><p>
++Version 1.xxx adds support for SQLite version 3 and GL_WHITELISTNEARBY.
+ </p>
+
+ <h2>Downloading</h2>
+@@ -157,9 +167,10 @@ name on your platform. Or not at all.
+ </p><p>
+ By default, the flat-file database implementation will be used. If you want
+ to use one of the other implementations, specify the "DB_IMPL" parameter
+-to the make command, i. e. "make DB_IMPL=bdb" for Berkeley DB or
+-"make DB_IMPL=sqlite" for the SQLite interface. Needless to say, the respective
+-libraries and header files must be present on your system. See
++to the make command, i. e. "make DB_IMPL=bdb" for Berkeley DB,
++"make DB_IMPL=sqlite" for SQLite version 2, "make DB_IMPL=sqlite3" for SQLite
++version 3. Needless to say, the respective libraries and header files must be
++present on your system. See
+ </p><p>
+ <a href=README.db-file>README.db-file</a>, <br>
+ <a href=README.db-bdb>README.db-bdb</a> or<br>
+diff -urpN -x ,,build greylisting-spp-1.0.1-stock/src/Makefile greylisting-spp-1.0.1/src/Makefile
+--- greylisting-spp-1.0.1-stock/src/Makefile 2008-04-27 20:10:53.000000000 +0000
++++ greylisting-spp-1.0.1/src/Makefile 2008-10-30 02:08:31.000000000 +0000
+@@ -27,6 +27,9 @@ endif
+ ifeq ($(DB_IMPL),sqlite)
+ LDFLAGS += -lsqlite
+ endif
++ifeq ($(DB_IMPL),sqlite3)
++LDFLAGS += -lsqlite3
++endif
+
+ all: greylisting-spp
+
+diff -urpN -x ,,build greylisting-spp-1.0.1-stock/src/db-sqlite3.c greylisting-spp-1.0.1/src/db-sqlite3.c
+--- greylisting-spp-1.0.1-stock/src/db-sqlite3.c 1970-01-01 00:00:00.000000000 +0000
++++ greylisting-spp-1.0.1/src/db-sqlite3.c 2008-11-06 05:16:42.000000000 +0000
+@@ -0,0 +1,406 @@
++/* greylisting-spp - A qmail-spp plugin implementing greylisting
++ *
++ * db-sqlite3.c
++ *
++ * Copyright (C) 2004 Peter Conrad <conrad@tivano.de>
++ *
++ * Copyright (C) 2008 Chris Caputo <ccaputo@alt.net>
++ * - updated for sqlite3
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License (version 2) as
++ * published by the Free Software Foundation.
++ *
++ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++ */
++
++#include <sqlite3.h>
++#include <unistd.h>
++#include <stdlib.h>
++#include <string.h>
++#include <time.h>
++#include "db-api.h"
++#include "commonstuff.h"
++
++static sqlite3 *db = NULL;
++
++static int result_count;
++static char result_time[8];
++static char result_flag;
++
++static char *parameter[4];
++
++#define ERR_CANT_OPEN_DB "Can't open database file \""
++#define ERR_CANT_CREATE_DB_FN "Can't create DB function!\n"
++#define ERR_VERSION_MISMATCH "Version mismatch in file \""
++#define ERR_WRITING_ENTRY "Couldn't write entry: "
++#define ERR_READING_ENTRY "Couldn't read entry: "
++
++/* This file contains functions for manipulating the greylisting database.
++ * The database is an SQLite style database (see http://sqlite.org/ ).
++ * It consists of two simple tables:
++ * - GL_MGMT contains some key/value pairs for internal use
++ * - GL_GREYLIST contains greylisting data (i. e. IP, sender, recipient,
++ * timestamp and flag).
++ */
++
++/** Closes cursor, transaction, db and handle.
++ */
++void closedb() {
++ if (db) {
++ sqlite3_close(db);
++ db = NULL;
++ }
|