pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mail/postfix Added support for SQLite (pkg/39745 by Sé...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/07a2b3c7a461
branches:  trunk
changeset: 548449:07a2b3c7a461
user:      martti <martti%pkgsrc.org@localhost>
date:      Thu Oct 16 09:40:20 2008 +0000

description:
Added support for SQLite (pkg/39745 by Sébastien BOCAHU.

No existing binary packages are affected so I didn't bump the revision...

diffstat:

 mail/postfix/distinfo         |    6 +-
 mail/postfix/options.mk       |   13 +-
 mail/postfix/patches/patch-as |   55 ++++++++
 mail/postfix/patches/patch-at |  261 ++++++++++++++++++++++++++++++++++++++++++
 mail/postfix/patches/patch-au |   39 ++++++
 mail/postfix/patches/patch-av |   24 +++
 6 files changed, 395 insertions(+), 3 deletions(-)

diffs (truncated from 443 to 300 lines):

diff -r d224896763fd -r 07a2b3c7a461 mail/postfix/distinfo
--- a/mail/postfix/distinfo     Thu Oct 16 09:08:21 2008 +0000
+++ b/mail/postfix/distinfo     Thu Oct 16 09:40:20 2008 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.120 2008/09/17 13:21:19 joerg Exp $
+$NetBSD: distinfo,v 1.121 2008/10/16 09:40:20 martti Exp $
 
 SHA1 (postfix/postfix-2.5.5.tar.gz) = 7240be9e362b991bacfcf7e3771ab611e872ac12
 RMD160 (postfix/postfix-2.5.5.tar.gz) = 2118fa61710bdb266d4fb8b7a0f60cf0f633c801
@@ -6,3 +6,7 @@
 SHA1 (patch-aa) = 5b4923402c80957e47b8a4e16c897287b88544bb
 SHA1 (patch-ag) = b77081a61bc2b95a40963fb1d3ac5818d55a778b
 SHA1 (patch-ai) = aedee357d43321d2c3557679d796814455ae0ea6
+SHA1 (patch-as) = 531d372fd2e51781616202b9c704b621b96770c4
+SHA1 (patch-at) = b0abf2c49bfe94153f7a3845b5709ff8e0027a03
+SHA1 (patch-au) = 60396f5f182e0f247b06974dc5cf912dbcf84bbf
+SHA1 (patch-av) = 98073186738e1a4fcd0f620096f4be83a9ff9e73
diff -r d224896763fd -r 07a2b3c7a461 mail/postfix/options.mk
--- a/mail/postfix/options.mk   Thu Oct 16 09:08:21 2008 +0000
+++ b/mail/postfix/options.mk   Thu Oct 16 09:40:20 2008 +0000
@@ -1,9 +1,9 @@
-# $NetBSD: options.mk,v 1.32 2008/06/03 10:30:51 ghen Exp $
+# $NetBSD: options.mk,v 1.33 2008/10/16 09:40:20 martti Exp $
 
 # Global and legacy options
 
 PKG_OPTIONS_VAR=       PKG_OPTIONS.postfix
-PKG_SUPPORTED_OPTIONS= bdb ldap mysql mysql4 pcre pgsql sasl tls
+PKG_SUPPORTED_OPTIONS= bdb ldap mysql mysql4 pcre pgsql sasl sqlite tls
 PKG_SUGGESTED_OPTIONS= tls
 
 .include "../../mk/bsd.options.mk"
@@ -83,6 +83,15 @@
 .endif
 
 ###
+### Support using a SQLite database for table lookups.
+###
+.if !empty(PKG_OPTIONS:Msqlite)
+.  include "../../databases/sqlite3/buildlink3.mk"
+CCARGS+=       -DHAS_SQLITE  -I${SQLITE3_PREFIX}/include/sqlite3
+AUXLIBS+=      -L${SQLITE3_PREFIX}/lib -lsqlite3
+.endif
+
+###
 ### Cyrus SASL support for SMTP authentication.
 ### (Dovecot SASL support is built in by default.)
 ###
diff -r d224896763fd -r 07a2b3c7a461 mail/postfix/patches/patch-as
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/postfix/patches/patch-as     Thu Oct 16 09:40:20 2008 +0000
@@ -0,0 +1,55 @@
+$NetBSD: patch-as,v 1.4 2008/10/16 09:40:20 martti Exp $
+
+Support for sqlite.
+
+--- src/global/Makefile.in.orig        2007-12-06 14:49:03.000000000 +0100
++++ src/global/Makefile.in
+@@ -4,7 +4,7 @@ SRCS   = abounce.c anvil_clnt.c been_here.
+       clnt_stream.c conv_time.c db_common.c debug_peer.c debug_process.c \
+       defer.c deliver_completed.c deliver_flock.c deliver_pass.c \
+       deliver_request.c dict_ldap.c dict_mysql.c dict_pgsql.c \
+-      dict_proxy.c domain_list.c dot_lockfile.c dot_lockfile_as.c \
++      dict_proxy.c dict_sqlite.c  domain_list.c dot_lockfile.c dot_lockfile_as.c \
+       dsb_scan.c dsn.c dsn_buf.c dsn_mask.c dsn_print.c dsn_util.c \
+       ehlo_mask.c ext_prop.c file_id.c flush_clnt.c header_opts.c \
+       header_token.c input_transp.c int_filt.c is_header.c log_adhoc.c \
+@@ -34,7 +34,7 @@ OBJS = abounce.o anvil_clnt.o been_here.
+       clnt_stream.o conv_time.o db_common.o debug_peer.o debug_process.o \
+       defer.o deliver_completed.o deliver_flock.o deliver_pass.o \
+       deliver_request.o dict_ldap.o dict_mysql.o dict_pgsql.o \
+-      dict_proxy.o domain_list.o dot_lockfile.o dot_lockfile_as.o \
++      dict_proxy.o dict_sqlite.o domain_list.o dot_lockfile.o dot_lockfile_as.o \
+       dsb_scan.o dsn.o dsn_buf.o dsn_mask.o dsn_print.o dsn_util.o \
+       ehlo_mask.o ext_prop.o file_id.o flush_clnt.o header_opts.o \
+       header_token.o input_transp.o int_filt.o is_header.o log_adhoc.o \
+@@ -63,7 +63,7 @@ HDRS = abounce.h anvil_clnt.h been_here.
+       canon_addr.h cfg_parser.h cleanup_user.h clnt_stream.h config.h \
+       conv_time.h db_common.h debug_peer.h debug_process.h defer.h \
+       deliver_completed.h deliver_flock.h deliver_pass.h deliver_request.h \
+-      dict_ldap.h dict_mysql.h dict_pgsql.h dict_proxy.h domain_list.h \
++      dict_ldap.h dict_mysql.h dict_pgsql.h dict_proxy.h dict_sqlite.h domain_list.h \
+       dot_lockfile.h dot_lockfile_as.h dsb_scan.h dsn.h dsn_buf.h \
+       dsn_mask.h dsn_print.h dsn_util.h ehlo_mask.h ext_prop.h \
+       file_id.h flush_clnt.h header_opts.h header_token.h input_transp.h \
+@@ -860,6 +860,13 @@ dict_proxy.o: dict_proxy.c
+ dict_proxy.o: dict_proxy.h
+ dict_proxy.o: mail_params.h
+ dict_proxy.o: mail_proto.h
++dict_sqlite.o: ../../include/dict.h
++dict_sqlite.o: ../../include/msg.h
++dict_sqlite.o: ../../include/sys_defs.h
++dict_sqlite.o: cfg_parser.h
++dict_sqlite.o: db_common.h
++dict_sqlite.o: dict_sqlite.c
++dict_sqlite.o: dict_sqlite.h
+ domain_list.o: ../../include/match_list.h
+ domain_list.o: ../../include/match_ops.h
+ domain_list.o: ../../include/sys_defs.h
+@@ -1219,6 +1226,7 @@ mail_dict.o: dict_ldap.h
+ mail_dict.o: dict_mysql.h
+ mail_dict.o: dict_pgsql.h
+ mail_dict.o: dict_proxy.h
++mail_dict.o: dict_sqlite.h
+ mail_dict.o: mail_dict.c
+ mail_dict.o: mail_dict.h
+ mail_error.o: ../../include/name_mask.h
diff -r d224896763fd -r 07a2b3c7a461 mail/postfix/patches/patch-at
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mail/postfix/patches/patch-at     Thu Oct 16 09:40:20 2008 +0000
@@ -0,0 +1,261 @@
+$NetBSD: patch-at,v 1.4 2008/10/16 09:40:20 martti Exp $
+
+Support for sqlite.
+
+--- src/global/dict_sqlite.c.orig      2008-10-17 00:40:21.000000000 +0200
++++ src/global/dict_sqlite.c
+@@ -0,0 +1,254 @@
++/*++
++/* NAME
++/*    dict_sqlite 3
++/* SUMMARY
++/*    dictionary manager interface to SQLite3 databases
++/* SYNOPSIS
++/*    #include <dict_sqlite.h>
++/*
++/*    DICT    *dict_sqlite_open(name, open_flags, dict_flags)
++/*    const char *name;
++/*    int     open_flags;
++/*    int     dict_flags;
++/* DESCRIPTION
++/*    dict_sqlite_open() creates a dictionary of type 'sqlite'.  This
++/*    dictionary is an interface for the postfix key->value mappings
++/*    to SQLite.  The result is a pointer to the installed dictionary,
++/*    or a null pointer in case of problems.
++/* .PP
++/*    Arguments:
++/* .IP name
++/*    Either the path to the SQLite configuration file (if it starts
++/*    with '/' or '.'), or the prefix which will be used to obtain
++/*    main.cf configuration parameters for this search.
++/*
++/*    In the first case, the configuration parameters below are
++/*    specified in the file as \fIname\fR=\fBvalue\fR pairs.
++/*
++/*    In the second case, the configuration parameters are
++/*    prefixed with the value of \fIname\fR and an underscore,
++/*    and they are specified in main.cf.  For example, if this
++/*    value is \fIsqlitecon\fR, the parameters would look like
++/*    \fIsqlitecon_user\fR, \fIsqlitecon_table\fR, and so on.
++/*
++/* .IP open_flags
++/*    Must be O_RDONLY.
++/* .IP dict_flags
++/*    See dict_open(3).
++/* .PP
++/*    Configuration parameters:
++/*
++/*    The parameters encodes a number of pieces of information:
++/*    dbpath, query, table, select_field and where_field:
++/* .IP \fIdbpath\fR
++/*    Path to SQLite database
++/* .IP \fIquery\fR
++/*      Query template, before the query is actually issued, variable
++/*    substitutions are performed. See sqlite_table(5) for details. If
++/*    No query is specified, the legacy variables \fItable\fR,
++/*    \fIselect_field\fR, \fIwhere_field\fR and \fIadditional_conditions\fR
++/*    are used to construct the query template.
++/* .IP \fIresult_format\fR
++/*      The format used to expand results from queries.  Substitutions
++/*      are performed as described in sqlite_table(5). Defaults to returning
++/*    the lookup result unchanged.
++/* .IP expansion_limit
++/*    Limit (if any) on the total number of lookup result values. Lookups which
++/*    exceed the limit fail with dict_errno=DICT_ERR_RETRY. Note that each
++/*    non-empty (and non-NULL) column of a multi-column result row counts as
++/*    one result.
++/*
++/* SEE ALSO
++/*    dict(3) generic dictionary manager
++/* AUTHOR(S)
++/*    Axel Steiner
++/*    ast%treibsand.com@localhost
++/*--*/
++
++/* System library. */
++#include "sys_defs.h"
++ 
++#ifdef HAS_SQLITE
++#include <sqlite3.h> 
++
++/* Utility library. */
++
++#include "msg.h"
++#include "dict.h"
++#include "vstring.h"
++#include "stringops.h"
++
++/* Global library. */
++
++#include "cfg_parser.h"
++#include "db_common.h"
++
++/* Application-specific. */
++
++#include "dict_sqlite.h"
++
++typedef struct {
++      DICT dict;
++      CFG_PARSER *parser;
++      sqlite3 *db;
++      char *dbpath;
++      char *query;
++      char *result_format;
++      int expansion_limit;
++      void *ctx;
++} DICT_SQLITE;
++
++typedef sqlite3_stmt *SQL;
++
++/* internal function declarations */
++
++static const char *dict_sqlite_lookup(DICT *, const char *);
++DICT   *dict_sqlite_open(const char *, int, int);
++static void dict_sqlite_close(DICT *);
++static void sqlite_parse_config(DICT_SQLITE *, const char *);
++
++
++/* dict_sqlite_close - close the database */
++
++static void dict_sqlite_close(DICT *dict) {
++      const char *myname = "dict_sqlite_close";
++      DICT_SQLITE *dict_sqlite = (DICT_SQLITE *) dict;
++
++      if (msg_verbose)
++              msg_info("%s: dict_sqlite_close", myname);
++      if (sqlite3_close(dict_sqlite->db) != SQLITE_OK)
++              msg_fatal("%s: DB close failed", myname);
++      cfg_parser_free(dict_sqlite->parser);
++      if (dict->fold_buf)
++              vstring_free(dict->fold_buf);
++      dict_free(dict);
++}
++
++
++/* dict_sqlite_lookup - find database entry */
++
++static const char *dict_sqlite_lookup(DICT *dict, const char *name) {
++      const char *myname = "dict_sqlite_lookup";
++      DICT_SQLITE *dict_sqlite = (DICT_SQLITE *) dict;
++      SQL sql;
++      const char *zErrMsg;
++      static VSTRING *query;
++      static VSTRING *result;
++      const char *r;
++      int expansion = 0;
++      
++      /*
++       * Optionally fold the key.
++       */
++      if (dict->fold_buf) {
++              vstring_strcpy(dict->fold_buf, name);
++              name = lowercase(vstring_str(dict->fold_buf));
++      }
++
++      if (db_common_check_domain(dict_sqlite->ctx, name) == 0) {
++              if (msg_verbose)
++                      msg_info("%s: Skipping lookup of '%s'", myname, name);
++              return (0);
++      }
++
++#define INIT_VSTR(buf, len) do { \
++      if (buf == 0) \
++              buf = vstring_alloc(len); \
++      VSTRING_RESET(buf); \
++      VSTRING_TERMINATE(buf); \
++    } while (0)
++
++      INIT_VSTR(query, 10);
++
++      if (!db_common_expand(dict_sqlite->ctx, dict_sqlite->query,
++                      name, 0, query, NULL))
++              return (0); 
++
++      if (msg_verbose)
++              msg_info("%s: %s: Searching with query %s", myname,
++                              dict_sqlite->parser->name, vstring_str(query));
++
++      if(sqlite3_prepare_v2(dict_sqlite->db,vstring_str(query),-1,&sql,&zErrMsg)!=SQLITE_OK) {
++              msg_fatal("%s: sql prepare %s\n",myname,sqlite3_errmsg(dict_sqlite->db));
++      }
++
++      INIT_VSTR(result, 10);
++      while (sqlite3_step(sql) == SQLITE_ROW ) {
++              if (db_common_expand(dict_sqlite->ctx, dict_sqlite->result_format,
++                                      sqlite3_column_text(sql, 0), name, result, 0)
++                      && dict_sqlite->expansion_limit > 0
++                      && ++expansion > dict_sqlite->expansion_limit) {
++                      msg_warn("%s: %s: Expansion limit exceeded for key: '%s'",
++                              myname, dict_sqlite->parser->name, name);



Home | Main Index | Thread Index | Old Index