head 1.6; access; symbols pkgsrc-2013Q2:1.6.0.8 pkgsrc-2013Q2-base:1.6 pkgsrc-2012Q4:1.6.0.6 pkgsrc-2012Q4-base:1.6 pkgsrc-2011Q4:1.6.0.4 pkgsrc-2011Q4-base:1.6 pkgsrc-2011Q2:1.6.0.2 pkgsrc-2011Q2-base:1.6 pkgsrc-2010Q4:1.5.0.14 pkgsrc-2010Q4-base:1.5 pkgsrc-2010Q3:1.5.0.12 pkgsrc-2010Q3-base:1.5 pkgsrc-2010Q2:1.5.0.10 pkgsrc-2010Q2-base:1.5 pkgsrc-2010Q1:1.5.0.8 pkgsrc-2010Q1-base:1.5 pkgsrc-2009Q4:1.5.0.6 pkgsrc-2009Q4-base:1.5 pkgsrc-2009Q3:1.5.0.4 pkgsrc-2009Q3-base:1.5 pkgsrc-2009Q2:1.5.0.2 pkgsrc-2009Q2-base:1.5 pkgsrc-2009Q1:1.4.0.4 pkgsrc-2009Q1-base:1.4 pkgsrc-2008Q4:1.4.0.2 pkgsrc-2008Q4-base:1.4 pkgsrc-2008Q3:1.2.0.42 pkgsrc-2008Q3-base:1.2 cube-native-xorg:1.2.0.40 cube-native-xorg-base:1.2 pkgsrc-2008Q2:1.2.0.38 pkgsrc-2008Q2-base:1.2 pkgsrc-2008Q1:1.2.0.36 pkgsrc-2008Q1-base:1.2 pkgsrc-2007Q4:1.2.0.34 pkgsrc-2007Q4-base:1.2 pkgsrc-2007Q3:1.2.0.32 pkgsrc-2007Q3-base:1.2 pkgsrc-2007Q2:1.2.0.30 pkgsrc-2007Q2-base:1.2 pkgsrc-2007Q1:1.2.0.28 pkgsrc-2007Q1-base:1.2 pkgsrc-2006Q4:1.2.0.26 pkgsrc-2006Q4-base:1.2 pkgsrc-2006Q3:1.2.0.24 pkgsrc-2006Q3-base:1.2 pkgsrc-2006Q2:1.2.0.22 pkgsrc-2006Q2-base:1.2 pkgsrc-2006Q1:1.2.0.20 pkgsrc-2006Q1-base:1.2 pkgsrc-2005Q4:1.2.0.18 pkgsrc-2005Q4-base:1.2 pkgsrc-2005Q3:1.2.0.16 pkgsrc-2005Q3-base:1.2 pkgsrc-2005Q2:1.2.0.14 pkgsrc-2005Q2-base:1.2 pkgsrc-2005Q1:1.2.0.12 pkgsrc-2005Q1-base:1.2 pkgsrc-2004Q4:1.2.0.10 pkgsrc-2004Q4-base:1.2 pkgsrc-2004Q3:1.2.0.8 pkgsrc-2004Q3-base:1.2 pkgsrc-2004Q2:1.2.0.6 pkgsrc-2004Q2-base:1.2 pkgsrc-2004Q1:1.2.0.4 pkgsrc-2004Q1-base:1.2 pkgsrc-2003Q4:1.2.0.2 pkgsrc-2003Q4-base:1.2 buildlink2-base:1.2 NetBSD-current-20000814:1.1.1.1 TNF:1.1.1; locks; strict; comment @# @; 1.6 date 2011.02.26.09.01.36; author tron; state dead; branches; next 1.5; 1.5 date 2009.05.13.10.34.06; author martti; state Exp; branches 1.5.14.1; next 1.4; 1.4 date 2008.10.16.09.56.58; author martti; state Exp; branches; next 1.3; 1.3 date 2008.10.16.09.45.12; author martti; state Exp; branches; next 1.2; 1.2 date 2000.08.14.04.40.01; author itojun; state dead; branches; next 1.1; 1.1 date 2000.08.14.04.33.24; author itojun; state Exp; branches 1.1.1.1; next ; 1.5.14.1 date 2011.03.11.10.54.03; author tron; state dead; branches; next ; 1.1.1.1 date 2000.08.14.04.33.24; author itojun; state Exp; branches; next ; desc @@ 1.6 log @Remove outdated and unmaintained "postfix-current" package. Please use the "postfix" package instead which contains a more recent version. @ text @$NetBSD: patch-at,v 1.5 2009/05/13 10:34:06 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 *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 +/*--*/ + +/* System library. */ +#include "sys_defs.h" + +#ifdef HAS_SQLITE +#include + +/* 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); + dict_errno = DICT_ERR_RETRY; + break; + } + } + + if(sqlite3_finalize(sql)){ + msg_fatal("%s: sql finalize for %s; %s\n",myname,vstring_str(query),sqlite3_errmsg(dict_sqlite->db)); + return(0); + } + + + r = vstring_str(result); + return ((dict_errno == 0 && *r) ? r : 0); +} + +/* sqlite_parse_config - parse sqlite configuration file */ + +static void sqlite_parse_config(DICT_SQLITE *dict_sqlite, const char *sqlitecf) { + CFG_PARSER *p; + VSTRING *buf; + + p = dict_sqlite->parser = cfg_parser_alloc(sqlitecf); + dict_sqlite->dbpath = cfg_get_str(p, "dbpath", "", 1, 0); + dict_sqlite->result_format = cfg_get_str(p, "result_format", "%s", 1, 0); + + if ((dict_sqlite->query = cfg_get_str(p, "query", NULL, 0, 0)) == 0) { + buf = vstring_alloc(64); + db_common_sql_build_query(buf, p); + dict_sqlite->query = vstring_export(buf); + } + dict_sqlite->expansion_limit = cfg_get_int(p,"expansion_limit", 0, 0, 0); + dict_sqlite->ctx = 0; + + (void) db_common_parse(&dict_sqlite->dict, &dict_sqlite->ctx, dict_sqlite->query, 1); + (void) db_common_parse(0, &dict_sqlite->ctx, dict_sqlite->result_format, 0); + + db_common_parse_domain(p, dict_sqlite->ctx); + + if (db_common_dict_partial(dict_sqlite->ctx)) + dict_sqlite->dict.flags |= DICT_FLAG_PATTERN; + else + dict_sqlite->dict.flags |= DICT_FLAG_FIXED; + + if (dict_sqlite->dict.flags & DICT_FLAG_FOLD_FIX) + dict_sqlite->dict.fold_buf = vstring_alloc(10); +} + +/* dict_sqlite_open - open sqlite database */ + +DICT *dict_sqlite_open(const char *name, int open_flags, int dict_flags) { + DICT_SQLITE *dict_sqlite; + + /* + * Sanity checks. + */ + if (open_flags != O_RDONLY) + msg_fatal("%s:%s map requires O_RDONLY access mode", DICT_TYPE_SQLITE, name); + + dict_sqlite = (DICT_SQLITE *) dict_alloc(DICT_TYPE_SQLITE, name, sizeof(DICT_SQLITE)); + dict_sqlite->dict.lookup = dict_sqlite_lookup; + dict_sqlite->dict.close = dict_sqlite_close; + dict_sqlite->dict.flags = dict_flags; + sqlite_parse_config(dict_sqlite, name); + + if (sqlite3_open(dict_sqlite->dbpath, &dict_sqlite->db)) { + msg_fatal("Can't open database: %s\n", sqlite3_errmsg(dict_sqlite->db)); + sqlite3_close(dict_sqlite->db); + } + + return (DICT_DEBUG (&dict_sqlite->dict)); +} +#endif @ 1.5 log @Updated mail/postfix-current to 2.7.20090511 This same as 2.6.0... @ text @d1 1 a1 1 $NetBSD: patch-at,v 1.4 2008/10/16 09:40:20 martti Exp $ @ 1.5.14.1 log @Pullup ticket #3385 - requested by taca mail/postfix-current: security update Revisions pulled up: - mail/postfix-current/MESSAGE patch - mail/postfix-current/MESSAGE.sasl patch - mail/postfix-current/Makefile patch - mail/postfix-current/PLIST patch - mail/postfix-current/distinfo patch - mail/postfix-current/files/mailer.conf patch - mail/postfix-current/patches/patch-aa patch - mail/postfix-current/patches/patch-ag patch - mail/postfix-current/patches/patch-ai patch - mail/postfix-current/patches/patch-as patch - mail/postfix-current/patches/patch-at deleted - mail/postfix-current/patches/patch-au deleted - mail/postfix-current/patches/patch-av deleted --- Update "postfix-current" package to version 2.8.1: Postfix stable release 2.8.0 is available. This release continues the move towards improving code and documentation, and making the system better prepared for changes in the threat environment. The postscreen daemon (a zombie blocker in front of Postfix) is now included with the stable release. postscreen now supports TLS and can log the rejected sender, recipient and helo information. See the POSTSCREEN_README file for recommended usage scenarios. Support for DNS whitelisting (permit_rhswl_client), and for pattern matching to filter the responses from DNS white/blacklist servers (e.g., reject_rhsbl_client zen.spamhaus.org=127.0.0.[1..10]). Improved message tracking across SMTP-based content filters; the after-filter SMTP server can log the before-filter queue ID (the XCLIENT protocol was extended). Read-only support for sqlite databases. See sqlite_table(5) and SQLITE_README. Support for 'footers' that are appended to SMTP server "reject" responses. See "smtpd_reject_footer" in the postconf(5) manpage. @ text @d1 1 a1 1 $NetBSD: patch-at,v 1.5 2009/05/13 10:34:06 martti Exp $ @ 1.4 log @Use the correct patch set for postfix-2.6-xxxxxxxx. @ text @d1 1 a1 1 $NetBSD: patch-at,v 1.3 2008/10/16 09:45:12 martti Exp $ d7 1 a7 1 @@@@ -0,0 +1,278 @@@@ d49 1 a49 1 +/* dbpath, query, result_format and expansion_limit: d53 5 a57 2 +/* Query template, before the query is actually issued, variable +/* substitutions are performed. See sqlite_table(5) for details. d59 2 a60 2 +/* The format used to expand results from queries. Substitutions +/* are performed as described in sqlite_table(5). Defaults to returning a80 4 +#if !defined(SQLITE_VERSION_NUMBER) || (SQLITE_VERSION_NUMBER < 3005004) +#error "Your SQLite version is too old" +#endif + a86 1 +#include "mymalloc.h" a116 18 +/* dict_sqlite_quote - escape SQL metacharacters in input string */ + +static void dict_sqlite_quote(DICT *dict, const char *name, VSTRING *result) { + DICT_SQLITE *dict_sqlite = (DICT_SQLITE *) dict; + int len = strlen(name); + int buflen = 2*len + 1; + char *q; + + if (buflen < len) + msg_panic("dict_sqlite_quote: integer overflow in 2*%d+1", len); + + VSTRING_SPACE(result, buflen); + q = sqlite3_mprintf("%q",name); + vstring_strncat(result,q, strlen(q)); + sqlite3_free(q); + VSTRING_SKIP(result); +} + a128 5 + myfree(dict_sqlite->dbpath); + myfree(dict_sqlite->query); + myfree(dict_sqlite->result_format); + if (dict_sqlite->ctx) + db_common_free_ctx(dict_sqlite->ctx); d150 1 a150 3 + if (dict->flags & DICT_FLAG_FOLD_FIX) { + if (dict->fold_buf == 0) + dict->fold_buf = vstring_alloc(10); d171 1 a171 1 + name, 0, query, dict_sqlite_quote)) d227 6 a232 1 + d234 1 a234 2 + dict_sqlite->dict.fold_buf = vstring_alloc(10); + a251 1 + dict_sqlite->dict.flags |= DICT_FLAG_FIXED; @ 1.3 log @Updated mail/postfix-current to 2.6.20081012 * Bug fixes. * Added support for SQLite (pkg/39745) @ text @d1 1 a1 1 $NetBSD$ d7 1 a7 1 @@@@ -0,0 +1,254 @@@@ d49 1 a49 1 +/* dbpath, query, table, select_field and where_field: d53 2 a54 5 +/* 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. d56 2 a57 2 +/* The format used to expand results from queries. Substitutions +/* are performed as described in sqlite_table(5). Defaults to returning d78 4 d88 1 d119 18 d149 5 d175 3 a177 1 + if (dict->fold_buf) { d198 1 a198 1 + name, 0, query, NULL)) d254 3 a257 7 + if (db_common_dict_partial(dict_sqlite->ctx)) + dict_sqlite->dict.flags |= DICT_FLAG_PATTERN; + else + dict_sqlite->dict.flags |= DICT_FLAG_FIXED; + + if (dict_sqlite->dict.flags & DICT_FLAG_FOLD_FIX) + dict_sqlite->dict.fold_buf = vstring_alloc(10); d275 1 @ 1.2 log @postfix 20000531 + IPv6 patch (not sure if it works right - please test). uses postfix Makefiles, not patches/*. experimental. @ text @d1 1 a1 1 $NetBSD: patch-at,v 1.1 2000/08/14 04:33:24 itojun Exp $ d3 238 a240 7 --- postcat/Makefile.orig Wed Apr 26 20:25:55 2000 +++ postcat/Makefile Wed Apr 26 20:38:55 2000 @@@@ -0,0 +1,12 @@@@ +# $NetBSD: patch-at,v 1.1 2000/08/14 04:33:24 itojun Exp $ +.include "../conf/main.cf" +PROG= postcat +BINDIR=${command_directory} d242 5 a246 2 +DPADD+= ${LIBPGLOBAL} ${LIBPUTIL} +LDADD+= ${LIBPGLOBAL} ${LIBPUTIL} ${AUXLIBS} d248 5 a252 2 +# XXX +NOMAN=1 d254 8 a261 1 +.include @ 1.1 log @Initial revision @ text @d1 1 a1 1 $NetBSD: patch-at,v 1.2 2000/04/27 01:05:07 kim Exp $ d6 1 a6 1 +# $NetBSD: patch-at,v 1.2 2000/04/27 01:05:07 kim Exp $ @ 1.1.1.1 log @mail/postfix-current, for experimental postfix code - based on mail/postfix @ text @@