-diff -urN sendmail-8.12.3/Makefile sendmail-8.12.3.patched/Makefile
---- sendmail-8.12.3/Makefile Thu Aug 23 22:44:39 2001
-+++ sendmail-8.12.3.patched/Makefile Fri Apr 26 17:10:37 2002
-@@ -2,7 +2,7 @@
-
- SHELL= /bin/sh
- SUBDIRS= libsm libsmutil libsmdb sendmail editmap mail.local \
-- mailstats makemap praliases rmail smrsh vacation
-+ mailstats rmail smrsh vacation
- # libmilter: requires pthread
- BUILD= ./Build
- OPTIONS= $(CONFIG) $(FLAGS)
-diff -urN sendmail-8.12.3/bluelabs.mc sendmail-8.12.3.patched/bluelabs.mc
---- sendmail-8.12.3/bluelabs.mc Thu Jan 1 01:00:00 1970
-+++ sendmail-8.12.3.patched/bluelabs.mc Fri Apr 26 17:10:37 2002
-@@ -0,0 +1,243 @@
-+######################################################################
-+# This is the Blue Labs m4 file.
-+#
-+# A work-in-progress website for building sendmail with this patch is
-+# at http://blue-labs.org/clue/sendmail.php
-+#
-+# !!! EDIT THE CONFIGURATION SETTINGS TO MATCH YOUR DESIRES !!!
-+#
-+# NOTE: THIS IS A SPECIALISED .cf FOR THE POSTGRESQL PATCH ONLY
-+#
-+VERSIONID(`(#) Blue Labs bluelabs.mc v 9.1 (Blue Labs) 10/13/2001')
-+######################################################################
-+
-+##
-+# See http://blue-labs.org/clue/sendmail.php for detailed instructions
-+#
-+# TODO: replace 'newaliases' and 'makemap' targets with "don't run this"
-+# replace man pages also
-+##
-+
-+# compile options
-+divert(-1)dnl
-+OSTYPE(linux)dnl
-+define(`confBLDVARIANT',`OPTIMIZED') # optimize the binary
-+# note, there will be two -O flags as it compiles. According to the gcc
-+# man page, the last one on the line is used in the compile
-+define(`confCCOPTS',`-O3 -pipe -mcpu=i686 -march=i686')dnl
-+APPENDDEF(`confENVDEF', `-DSM_CONF_SHM -DDNSMAP -DMILTER -DMAP_REGEX')dnl
-+
-+#####################################################################################
-+#
-+# BIG BOLD WARNING. link -lcrypt BEFORE -lcrypto or your md5 salted
-+# passwords will handled as DES passwords and FAIL TO WORK. Thank OpenSSL for
-+# this
-+#
-+#####################################################################################
-+
-+##
-+# SASL, be sure to link -lcrypt FIRST so it overrides the built-in crypt()
-+# in openssl, !@#$!@% that is so frustrating
-+##
-+APPENDDEF(`confENVDEF', `-DSASL')dnl
-+APPENDDEF(`confINCDIRS', `-I/usr/local/include -I/usr/local/include/sasl')dnl
-+APPENDDEF(`confLIBS', `-lsasl -lcrypt')dnl
-+APPENDDEF(`confLIBDIRS', `-L/usr/local/lib/sasl')dnl
-+define(`confDEF_AUTH_INFO', `/etc/mail/auth/auth-info')dnl
-+define(`confAUTH_MECHANISMS', `DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
-+TRUST_AUTH_MECH(`DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
-+
-+##
-+# postgres items
-+##
-+APPENDDEF(`confMAPDEF',`-DPGSQLMAP')dnl
-+APPENDDEF(`confINCDIRS',`-I/usr/local/pgsql/include')dnl
-+APPENDDEF(`confLIBDIRS',`-L/usr/local/pgsql/lib')dnl
-+# if you have compiled/installed BIND, you need to add -lresolv
-+APPENDDEF(`confLIBS',`-lpq -lresolv')dnl
-+
-+##
-+# TLS (ssl) items
-+#
-+# Compile with -D_FFR_SASL_OPTS and set 'p' in AuthOptions. (p not done)
-+#
-+##
-+APPENDDEF(`confENVDEF',`-DSTARTTLS -D_FFR_SASL_OPTS')dnl
-+APPENDDEF(`confLIBS',`-lssl -lcrypto')dnl
-+define(`SSL_DIR', `/usr/ssl')dnl
-+define(`confCACERT_PATH', `SSL_DIR/certs')dnl
-+define(`confCACERT', `SSL_DIR/certs/cacert.pem')dnl
-+define(`confSERVER_CERT', `SSL_DIR/certs/mailcert.pem')dnl
-+define(`confSERVER_KEY', `SSL_DIR/private/mailkey.pem')dnl
-+define(`confCLIENT_CERT', `SSL_DIR/certs/mailcert.pem')dnl
-+define(`confCLIENT_KEY', `SSL_DIR/private/mailkey.pem')dnl
-+define(`confAUTH_OPTIONS',`p')
-+
-+FEclass-E-expose
-+FLclass-L-localusers
-+
-+##
-+# example line:
-+# pgsql [-h <pgsql server>] -c <connection string> -s <query string>
-+##
-+
-+APPENDDEF(`DATABASE_MAP_TYPE', `pgsql')dnl
-+define(`PG_WHERE', where s_in='%s')
-+define(`PG_CONNSTR', "dbname=sendmail user=sendmail")
-+define(`PG_SOUT', "select distinct s_out from)
-+FEATURE(`pg_aliases', pgsql -c `PG_CONNSTR' -s `PG_SOUT' aliases `PG_WHERE'")dnl
-+FEATURE(`pg_virtualusers', pgsql -c `PG_CONNSTR' -s `PG_SOUT' virtualusers `PG_WHERE'")dnl
-+FEATURE(`pg_usersdb', pgsql -c `PG_CONNSTR' -s `PG_SOUT' userrewrite `PG_WHERE'")dnl
-+FEATURE(`pg_accessdb', pgsql -c `PG_CONNSTR' -s `PG_SOUT' access `PG_WHERE'")dnl
-+FEATURE(`pg_domaintable', pgsql -c `PG_CONNSTR' -s `PG_SOUT' domaintable `PG_WHERE'")dnl
-+FEATURE(`pg_generics', pgsql -c `PG_CONNSTR' -s `PG_SOUT' genericstable `PG_WHERE'")dnl
-+FEATURE(`pg_mailer', pgsql -c `PG_CONNSTR' -s `PG_SOUT' mailertable `PG_WHERE'")dnl
-+
-+define(`confPROCESS_TITLE_PREFIX', `[Blue-PgSQL]')dnl
-+define(`confMAX_MESSAGE_SIZE', `52428800')dnl # 50 Megs
-+define(`confFORWARD_PATH', `$z/.forward:/etc/mail/forward-files/$u')dnl
-+define(`confHOST_STATUS_DIRECTORY', `/etc/mail/host-status/')dnl
-+define(`confDEF_USER_ID', `mail')dnl
-+define(`confMAX_DAEMON_CHILDREN', `40')dnl
-+define(`confCONNECTION_RATE_THROTTLE', `20')dnl
-+define(`confSINGLE_LINE_FROM_HEADER', `True')dnl
-+define(`confSMTP_LOGIN_MSG', `$j Sendmail $v/$Z; $b\
-+ \
-+ Spam is prohibited here and any detected spam may be used in prosecution\
-+ against the spammer. This sendmail setup uses PgSQL (postgres) for most of\
-+ it''`s tables, for information on this, see\
-+ http://blue-labs.org/clue/sendmail.php\
-+ \
-+')dnl
-+define(`confDONT_PROBE_INTERFACES', `True')dnl
-+define(`confREJECT_MSG', `550 Your mail is rejected.\
-+ Contact <admin@$m> to have this matter resolved.\
-+ ')dnl
-+define(`confTO_INITIAL', `1m')dnl
-+define(`confTO_CONNECT', `15s')dnl
-+define(`confTO_HELO', `4m')dnl
-+define(`confTO_HOSTSTATUS', `1m')dnl
-+define(`confTO_DATAINIT', `2m')dnl
-+define(`confTO_DATABLOCK', `5m')dnl
-+define(`confTO_DATAFINAL', `5m')dnl
-+define(`confCONNECTION_RATE_THROTTLE', `40')dnl
-+define(`confDIAL_DELAY', `15s')dnl
-+define(`confNO_RCPT_ACTION', `add-apparently-to')dnl
-+define(`confALIAS_WAIT', `0')dnl
-+define(`confMAX_HOP', `35')dnl
-+define(`confQUEUE_LA', `5')dnl
-+define(`confREFUSE_LA', `12')dnl
-+define(`confSEPARATE_PROC', `False')dnl
-+
-+define(`confCON_EXPENSIVE', `true')dnl
-+define(`confWORK_RECIPIENT_FACTOR', `1000')dnl
-+define(`confWORK_TIME_FACTOR', `3000')dnl
-+define(`confQUEUE_SORT_ORDER', `Time')dnl
-+
-+define(`confDEAD_LETTER_DROP', `/var/tmp/dead.letter')dnl
-+define(`confRRT_IMPLIES_DSN', `True')dnl
-+define(`confCONTROL_SOCKET_NAME', `/var/spool/mqueue/.control')dnl
-+define(`confMAX_HEADERS_LENGTH', `16384')dnl
-+define(`confMAX_ALIAS_RECURSION', `10')dnl
-+define(`confMAX_RCPTS_PER_MESSAGE', `50')dnl
-+define(`confSHAREDMEMORYKEY', `42')dnl
-+define(`confMCI_CACHE_SIZE', `4')dnl
-+define(`PROCMAIL_MAILER_PATH', `/usr/bin/procmail')dnl
-+define(`STATUS_FILE', `/etc/mail/sendmail-status')dnl
-+
-+##
-+# queue groups
-+##
-+FEATURE(`queuegroup')dnl
-+define(`QUEUE_DIR', `/var/spool/mqueue')dnl
-+define(`LOCAL_PROG_QGRP', `local')dnl
-+define(`LOCAL_MAILER_QGRP', `local')dnl
-+define(`ESMTP_MAILER_QGRP', `smtp')dnl
-+define(`SMTP8_MAILER_QGRP', `smtp')dnl
-+define(`DSMTP_MAILER_QGRP', `smtp')dnl
-+define(`RELAY_MAILER_QGRP', `smtp')dnl
-+dnl QUEUE_GROUP(`mqueue', `P=/var/spool/mqueue, r=5, F=f, R=2')dnl
-+
-+dnl Nice is the nice(2) increment for queue groups
-+dnl Interval is the tiem between two queue runs
-+dnl Path..
-+dnl Runners is the number of parallel queue runners
-+dnl Jobs is the max number of messages delivered per queue run
-+dnl recipients is the max number of recipients per envelope
-+
-+QUEUE_GROUP(`local', `P=/var/spool/mqueue/local, N=0, I=30s, R=5, J=500, r=100, F=f')dnl
-+QUEUE_GROUP(`smtp', `P=/var/spool/mqueue/smtp, N=5, I=30s, R=10, J=500, r=100, F=f')dnl
-+QUEUE_GROUP(`relay', `P=/var/spool/mqueue/relay, N=10, I=1m, R=2, r=100, F=f')dnl
-+QUEUE_GROUP(`lmtp', `P=/var/spool/mqueue/lmtp, N=0, I=30s, R=2, r=100, F=f')dnl
-+QUEUE_GROUP(`expensive', `P=/var/spool/mqueue/expensive, F=e, N=19 I=5m R=1 r=200')dnl
-+
-+# HoldExpensive [c] If an outgoing mailer is marked as being expensive, don't connect
-+# immediately. This requires that queueing be compiled in, since it will depend on a queue
-+# run process to actually send the mail.
-+
-+##
-+# distinguish case on names, Blu3 is different from blu3
-+##
-+MODIFY_MAILER_FLAGS(`LOCAL', `+u')dnl
-+
-+FEATURE(`always_add_domain')dnl
-+FEATURE(`blacklist_recipients')dnl
-+dnl FEATURE(`dnsbl',`rbl.maps.vix.com',` Mail from $&{client_addr} rejected; see http://mail-abuse.org/rbl/')dnl
-+dnl FEATURE(`dnsbl',`dul.maps.vix.com')dnl
-+
-+FEATURE(`dnsbl',`blackholes.mail-abuse.org', `Mail from $&{client_addr} rejected; see http://mail-abuse.org/rbl/')dnl
-+FEATURE(`dnsbl',`dialups.mail-abuse.org', `Mail from $&{client_addr} rejected; see http://mail-abuse.org/rbl/')dnl
-+FEATURE(`dnsbl',`relays.mail-abuse.org', `Mail from $&{client_addr} rejected; see http://mail-abuse.org/rbl/')dnl
-+
-+FEATURE(`rhsbl',`dsn.rfc-ignorant.org', `550 You do not accept bounces violating RFC 821/2505/2821 - see http://www.rfc-ignorant.org/', `h')dnl
-+FEATURE(`rhsbl',`postmaster.rfc-ignorant.org', `550 Mail rejected as your domain does not have a working postmaster address - see http://www.rfc-ignorant.org/', `h')dnl
-+FEATURE(`rhsbl',`abuse.rfc-ignorant.org', `550 Mail rejected as your domain does not have a working abuse address - see http://www.rfc-ignorant.org/', `h')dnl
-+FEATURE(`rhsbl',`whois.rfc-ignorant.org', `550 Mail rejected as your whois information does not exist or is obviously fictitous - see http://www.rfc-ignorant.org/', `h')dnl
-+
-+FEATURE(`delay_checks')dnl
-+FEATURE(`generics_entire_domain')dnl
-+FEATURE(`local_procmail')dnl
-+FEATURE(`masquerade_envelope')dnl
-+FEATURE(`nouucp',`reject')dnl
-+FEATURE(`redirect')dnl
-+FEATURE(`relay_based_on_MX')dnl
-+FEATURE(`relay_entire_domain')dnl
-+FEATURE(`use_ct_file')dnl
-+FEATURE(`use_cw_file')dnl
-+FEATURE(`virtuser_entire_domain')dnl
-+FEATURE(`delay_checks',`friend')dnl
-+FEATURE(`lookupdotdomain')
-+
-+MASQUERADE_DOMAIN_FILE(`/etc/mail/masquerade-these-as-me')dnl
-+
-+MAILER(local)dnl
-+MAILER(smtp)dnl
-+
-+LOCAL_RULESETS
-+
-+#
-+# snow white
-+#
-+HFrom: $>CheckFrom
-+SCheckFrom
-+# Snow White Virus
-+R$* <hahaha@sexyfun.net> $* $#error $: "553 Delivery blocked: Snow White virus"
-+
-+#
-+# sircam
-+#
-+Kchkcontent regex -a@REJ Outlook_Express_message_boundary
-+HContent-Type: $>CheckContent
-+SCheckContent
-+R$* $: $(chkcontent $&({currHeader} $)
-+R@REJ $error $: "553 Delivery blocked --- SirCam virus detected"
-+
-+#
-+# subject check
-+# subject encodings, non-ascii characters, and trailing numbers in subject
-+# with lots of spaces are spam
-+Kchksubject regex -a@REJ ^=\?|[\80-ÿ]{3,}| {9,}[0-9]{3,}| {9,}\[[A-Za-z0-9]{3,}\]
-+HSubject: $>CheckSubject
-+SCheckSubject
-+R$* $: $(chksubject $&{currHeader} $)
-+R@REJ $#error $: "553 Delivery blocked --- `Subject:' suggests spam"
-diff -urN sendmail-8.12.3/cf/feature/pg_accessdb.m4 sendmail-8.12.3.patched/cf/feature/pg_accessdb.m4
---- sendmail-8.12.3/cf/feature/pg_accessdb.m4 Thu Jan 1 01:00:00 1970
-+++ sendmail-8.12.3.patched/cf/feature/pg_accessdb.m4 Fri Apr 26 17:10:37 2002
-@@ -0,0 +1,19 @@
-+divert(-1)
-+# By using this file, you agree to be cool and share your knowledge
-+#
-+# David, http://blue-labs.org/clue/sendmail.php
-+#
-+
-+divert(0)
-+VERSIONID(`$Id$')
-+divert(-1)
-+
-+define(`_ACCESS_TABLE_', `')
-+define(`_PG_ACCESS_TABLE_', `')
-+define(`_TAG_DELIM_', `:')dnl should be in OperatorChars
-+
-+LOCAL_CONFIG
-+# PostgreSQL based access list
-+Kaccess ifelse(defn(`_ARG_'), `',
-+ DATABASE_MAP_TYPE MAIL_SETTINGS_DIR`access',
-+ `_ARG_')
-diff -urN sendmail-8.12.3/cf/feature/pg_aliases.m4 sendmail-8.12.3.patched/cf/feature/pg_aliases.m4
---- sendmail-8.12.3/cf/feature/pg_aliases.m4 Thu Jan 1 01:00:00 1970
-+++ sendmail-8.12.3.patched/cf/feature/pg_aliases.m4 Fri Apr 26 17:10:37 2002
-@@ -0,0 +1,19 @@
-+divert(-1)
-+# By using this file, you agree to be cool and share your knowledge
-+#
-+# David, http://blue-labs.org/clue/sendmail.php
-+#
-+
-+divert(0)
-+VERSIONID(`$Id$')
-+divert(-1)
-+
-+undefine(`ALIAS_FILE')
-+define(`_ALIASES_TABLE_', `')
-+define(`_PG_ALIASES_TABLE_', `')
-+
-+LOCAL_CONFIG
-+# PostgreSQL based local aliases
-+Kaliases ifelse(defn(`_ARG_'), `',
-+ DATABASE_MAP_TYPE MAIL_SETTINGS_DIR`aliases',
-+ `_ARG_')
-diff -urN sendmail-8.12.3/cf/feature/pg_domaintable.m4 sendmail-8.12.3.patched/cf/feature/pg_domaintable.m4
---- sendmail-8.12.3/cf/feature/pg_domaintable.m4 Thu Jan 1 01:00:00 1970
-+++ sendmail-8.12.3.patched/cf/feature/pg_domaintable.m4 Fri Apr 26 17:10:37 2002
-@@ -0,0 +1,18 @@
-+divert(-1)
-+# By using this file, you agree to be cool and share your knowledge
-+#
-+# David, http://blue-labs.org/clue/sendmail.php
-+#
-+
-+divert(0)
-+VERSIONID(`$Id$')
-+divert(-1)
-+
-+define(`_DOMAIN_TABLE_', `')
-+define(`_PG_DOMAIN_TABLE', `')
-+
-+LOCAL_CONFIG
-+# PostgreSQL based domain rewriting table
-+Kdomaintable ifelse(defn(`_ARG_'), `',
-+ DATABASE_MAP_TYPE MAIL_SETTINGS_DIR`domaintable',
-+ `_ARG_')
-diff -urN sendmail-8.12.3/cf/feature/pg_generics.m4 sendmail-8.12.3.patched/cf/feature/pg_generics.m4
---- sendmail-8.12.3/cf/feature/pg_generics.m4 Thu Jan 1 01:00:00 1970
-+++ sendmail-8.12.3.patched/cf/feature/pg_generics.m4 Fri Apr 26 17:10:37 2002
-@@ -0,0 +1,18 @@
-+divert(-1)
-+# By using this file, you agree to be cool and share your knowledge
-+#
-+# David, http://blue-labs.org/clue/sendmail.php
-+#
-+
-+divert(0)
-+VERSIONID(`$Id$')
-+divert(-1)
-+
-+define(`_GENERICS_TABLE_', `')
-+define(`_PG_GENERICS_TABLE', `')
-+
-+LOCAL_CONFIG
-+# PostgreSQL based generic domain mapping table, similar to userdb
-+Kgenerics ifelse(defn(`_ARG_'), `',
-+ DATABASE_MAP_TYPE MAIL_SETTINGS_DIR`generics',
-+ `_ARG_')
-diff -urN sendmail-8.12.3/cf/feature/pg_mailer.m4 sendmail-8.12.3.patched/cf/feature/pg_mailer.m4
---- sendmail-8.12.3/cf/feature/pg_mailer.m4 Thu Jan 1 01:00:00 1970
-+++ sendmail-8.12.3.patched/cf/feature/pg_mailer.m4 Fri Apr 26 17:10:37 2002
-@@ -0,0 +1,18 @@
-+divert(-1)
-+# By using this file, you agree to be cool and share your knowledge
-+#
-+# David, http://blue-labs.org/clue/sendmail.php
-+#
-+
-+divert(0)
-+VERSIONID(`$Id$')
-+divert(-1)
-+
-+define(`_MAILER_TABLE_', `')
-+define(`_PG_MAILER_TABLE', `')
-+
-+LOCAL_CONFIG
-+# PostgreSQL based mailer table, for overriding domain and MX
-+Kmailertable ifelse(defn(`_ARG_'), `',
-+ DATABASE_MAP_TYPE MAIL_SETTINGS_DIR`mailertable',
-+ `_ARG_')
-diff -urN sendmail-8.12.3/cf/feature/pg_usersdb.m4 sendmail-8.12.3.patched/cf/feature/pg_usersdb.m4
---- sendmail-8.12.3/cf/feature/pg_usersdb.m4 Thu Jan 1 01:00:00 1970
-+++ sendmail-8.12.3.patched/cf/feature/pg_usersdb.m4 Fri Apr 26 17:10:37 2002
-@@ -0,0 +1,18 @@
-+divert(-1)
-+# By using this file, you agree to be cool and share your knowledge
-+#
-+# David, http://blue-labs.org/clue/sendmail.php
-+#
-+
-+divert(0)
-+VERSIONID(`$Id$')
-+divert(-1)
-+
-+define(`_REWRITE_TABLE_', `')
-+define(`_PG_REWRITE_TABLE_', `')
-+
-+LOCAL_CONFIG
-+# PostgreSQL based user rewrite table (can turn "John.Doe" into "jdoe")
-+Kusersdb ifelse(defn(`_ARG_'), `',
-+ DATABASE_MAP_TYPE MAIL_SETTINGS_DIR`usersdb',
-+ `_ARG_')
-diff -urN sendmail-8.12.3/cf/feature/pg_virtualusers.m4 sendmail-8.12.3.patched/cf/feature/pg_virtualusers.m4
---- sendmail-8.12.3/cf/feature/pg_virtualusers.m4 Thu Jan 1 01:00:00 1970
-+++ sendmail-8.12.3.patched/cf/feature/pg_virtualusers.m4 Fri Apr 26 17:10:37 2002
-@@ -0,0 +1,18 @@
-+divert(-1)
-+# By using this file, you agree to be cool and share your knowledge
-+#
-+# David, http://blue-labs.org/clue/sendmail.php
-+#
-+
-+divert(0)
-+VERSIONID(`$Id$')
-+divert(-1)
-+
-+define(`_VIRTUSER_TABLE_', `')
-+define(`_PG_VIRTUSER_TABLE_', `')
-+
-+LOCAL_CONFIG
-+# PostgreSQL based virtual user table (maps incoming users)
-+Kvirtuser ifelse(defn(`_ARG_'), `',
-+ DATABASE_MAP_TYPE MAIL_SETTINGS_DIR`virtusertable',
-+ `_ARG_')
-diff -urN sendmail-8.12.3/cf/feature/rhsbl.m4 sendmail-8.12.3.patched/cf/feature/rhsbl.m4
---- sendmail-8.12.3/cf/feature/rhsbl.m4 Thu Jan 1 01:00:00 1970
-+++ sendmail-8.12.3.patched/cf/feature/rhsbl.m4 Fri Apr 26 17:10:37 2002
-@@ -0,0 +1,43 @@
-+divert(-1)
-+#
-+# Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers.
-+# All rights reserved.
-+#
-+# By using this file, you agree to the terms and conditions set
-+# forth in the LICENSE file which can be found at the top level of
-+# the sendmail distribution.
-+#
-+#
-+
-+divert(0)
-+ifdef(`_DNSBL_R_',`dnl',`dnl
-+VERSIONID(`$Id$')
-+define(`_DNSBL_R_',`')
-+LOCAL_CONFIG
-+# map for DNS based blacklist lookups
-+Kdnsbl host -T<TMP>')
-+divert(-1)
-+define(`_DNSBL_SRV_', `ifelse(len(X`'_ARG_),`1',`blackholes.mail-abuse.org',_ARG_)')dnl
-+
-+define(`_DNSBL_LOOKUP_', `ifelse(_ARG4_,`h',`client_name',`client_addr')')dnl
-+
-+define(`_DNSBL_MSG_TMP_', `ifelse(_ARG3_,`t',`"451 Temporary lookup failure of "$`'&{_DNSBL_LOOKUP_} " at '_DNSBL_SRV_`"',`_ARG2_')')dnl
-+define(`_DNSBL_MSG_', `ifelse(len(X`'_ARG2_),`1',`"550 Mail from " $`'&{_DNSBL_LOOKUP_} " refused by blackhole site '_DNSBL_SRV_`"',`_ARG2_')')dnl
-+divert(8)
-+
-+dnl
-+dnl the "dnsbl" listed below should be replaced with "host" on 8.11 systems
-+dnl
-+
-+ifelse(_ARG4_,`h',
-+`R$* $: $&{client_name}
-+R[ $* ] $: $1 Get rid of square brackets
-+R$* $: <?> $(dnsbl $1.'_DNSBL_SRV_`. $: OK $)',
-+`R$* $: $&{client_addr}
-+R$-.$-.$-.$- $: <?> $(dnsbl $4.$3.$2.$1.'_DNSBL_SRV_`. $: OK $)')
-+R<?>OK $: OKSOFAR
-+ifelse(len(X`'_ARG3_),`1',
-+`R<?>$+<TMP> $: TMPOK',
-+`R<?>$+<TMP> $#error $@ 4.7.1 $: _DNSBL_MSG_TMP_')
-+R<?>$+ $#error $@ 5.7.1 $: _DNSBL_MSG_
-+divert(-1)
-diff -urN sendmail-8.12.3/include/libsmdb/smdb.h sendmail-8.12.3.patched/include/libsmdb/smdb.h
---- sendmail-8.12.3/include/libsmdb/smdb.h Mon Nov 19 20:30:03 2001
-+++ sendmail-8.12.3.patched/include/libsmdb/smdb.h Fri Apr 26 17:10:37 2002
-@@ -18,6 +18,14 @@
- # include <sm/gen.h>
- # include <sm/errstring.h>
-
-+# ifndef PGSQLMAP
-+# ifndef NDBM
-+# ifndef NEWDB
-+ ERROR NDBM or NEWDB must be defined.
-+# endif /* ! NEWDB */
-+# endif /* ! NDBM */
-+# endif /* ! PGSQLMAP */
-+
- # ifdef NDBM
- # include <ndbm.h>
- # endif /* NDBM */
-diff -urN sendmail-8.12.3/sendmail/Makefile.m4 sendmail-8.12.3.patched/sendmail/Makefile.m4
---- sendmail-8.12.3/sendmail/Makefile.m4 Sat Dec 1 00:32:02 2001
-+++ sendmail-8.12.3.patched/sendmail/Makefile.m4 Fri Apr 26 17:10:37 2002
-@@ -13,7 +13,7 @@
- define(`bldTARGET_INST_DEP', ifdef(`confINST_DEP', `confINST_DEP',
- `${DESTDIR}/etc/mail/submit.cf ${DESTDIR}${MSPQ}'))dnl
- define(`bldTARGET_LINKS', ifdef(`confLINKS', `confLINKS',
--`${DESTDIR}${UBINDIR}/newaliases ${DESTDIR}${UBINDIR}/mailq ${DESTDIR}${UBINDIR}/hoststat ${DESTDIR}${UBINDIR}/purgestat')
-+`${DESTDIR}${UBINDIR}/mailq ${DESTDIR}${UBINDIR}/hoststat ${DESTDIR}${UBINDIR}/purgestat')
- )dnl
-
- # location of sendmail statistics file (usually /etc/mail/ or /var/log)
-diff -urN sendmail-8.12.3/sendmail/README sendmail-8.12.3.patched/sendmail/README
---- sendmail-8.12.3/sendmail/README Thu Apr 4 23:39:33 2002
-+++ sendmail-8.12.3.patched/sendmail/README Fri Apr 26 17:10:37 2002
-@@ -117,6 +117,10 @@
- have to install the UMich or OpenLDAP
- (http://www.openldap.org/) ldap and lber libraries to use
- this flag.
-+PGSQLMAP PostgreSQL SQL query support. You will need to have
-+ PostgreSQL include files and libraries installed to use this
-+ feature. Information on PostgreSQL can be found at
-+ http://www.postgresql.org
- MAP_REGEX Regular Expression support. You will need to use an
- operating system which comes with the POSIX regex()
- routines or install a regexp library such as libregex from
-diff -urN sendmail-8.12.3/sendmail/conf.c sendmail-8.12.3.patched/sendmail/conf.c
---- sendmail-8.12.3/sendmail/conf.c Thu Apr 4 23:32:14 2002
-+++ sendmail-8.12.3.patched/sendmail/conf.c Fri Apr 26 17:10:37 2002
-@@ -491,6 +491,12 @@
- ldapmap_lookup, null_map_store);
- #endif /* LDAPMAP */
-
-+#ifdef PGSQLMAP
-+ MAPDEF("pgsql", NULL, MCF_ALIASOK|MCF_NOTPERSIST,
-+ pgsql_map_parseargs, pgsql_map_open, pgsql_map_close,
-+ pgsql_map_lookup, null_map_store);
-+#endif
-+
- #if PH_MAP
- MAPDEF("ph", NULL, MCF_NOTPERSIST,
- ph_map_parseargs, ph_map_open, ph_map_close,
-@@ -5484,6 +5490,9 @@
- #if LDAPMAP
- "LDAPMAP",
- #endif /* LDAPMAP */
-+#if PGSQL
-+ "PGSQL",
-+#endif /* PGSQL */
- #if LOG
- "LOG",
- #endif /* LOG */
-diff -urN sendmail-8.12.3/sendmail/map.c sendmail-8.12.3.patched/sendmail/map.c
---- sendmail-8.12.3/sendmail/map.c Tue Mar 26 23:56:36 2002
-+++ sendmail-8.12.3.patched/sendmail/map.c Fri Apr 26 17:10:37 2002
-@@ -4839,6 +4839,482 @@
- }
- }
- #endif /* LDAPMAP */
-+
-+#ifdef PGSQLMAP
-+#include <libpq-fe.h>
-+
-+struct pgsqlmap {
-+ struct pgsqlmap *p,*n;
-+ char *host;
-+ char *connstr;
-+ PGconn *conn;
-+ pid_t pid;
-+} *pgsqlmap=NULL;
-+
-+/*
-+ * search our structure for matching entries/add entry to struct
-+ */
-+
-+PGconn *getconn(char *host, char *connstr)
-+{
-+ pid_t p=getpid();
-+
-+ if(!pgsqlmap)
-+ return NULL;
-+
-+ while(pgsqlmap->p)
-+ pgsqlmap=pgsqlmap->p;
-+
-+#if (PGSQLDEBUG)
-+ sm_syslog(LOG_MAIL, NOQID, " HostSearch (host:%s, cstr:%s, pid:%i)",
-+ host, connstr, p);
-+#endif
-+
-+ // only return connections that match everything
-+ do {
-+ if(pgsqlmap->conn) {
-+ if (!strncmp(connstr, pgsqlmap->connstr, strlen(connstr)+1)) {
-+ if ((!host && !pgsqlmap->host) || !strncmp(host, pgsqlmap->host, strlen(host)+1)) {
-+ if (pgsqlmap->pid == p) {
-+ return pgsqlmap->conn;
-+ }
-+ }
-+ }
-+ }
-+
-+ if (pgsqlmap->n)
-+ pgsqlmap=pgsqlmap->n;
-+ else
-+ break;
-+ } while(1);
-+
-+ return NULL;
-+}
-+
-+void addconn(char *host, char *connstr, PGconn *conn)
-+{
-+ if(pgsqlmap) {
-+ // advance, then alloc
-+ while(pgsqlmap->n)
-+ pgsqlmap=pgsqlmap->n;
-+ pgsqlmap->n= (struct pgsqlmap *) xalloc(sizeof(struct pgsqlmap));
-+ bzero(pgsqlmap->n, sizeof(struct pgsqlmap));
-+ pgsqlmap->n->p=pgsqlmap;
-+ pgsqlmap=pgsqlmap->n;
-+ } else {
-+ // create
-+ pgsqlmap= (struct pgsqlmap *) xalloc(sizeof(struct pgsqlmap));
-+ bzero(pgsqlmap, sizeof(struct pgsqlmap));
-+ }
-+
-+ pgsqlmap->host=host;
-+ pgsqlmap->connstr=connstr;
-+ pgsqlmap->conn=conn;
-+ pgsqlmap->pid=getpid();
-+
-+#if (PGSQLDEBUG)
-+ sm_syslog(LOG_MAIL, NOQID, " HostAdd (host:%s, cstr:%s, conn:%p, pid:%i)",
-+ host, connstr, conn, pgsqlmap->pid);
-+#endif
-+}
-+
-+int removeconn(PGconn *conn)
-+{
-+ if(!pgsqlmap)
-+ return 0;
-+
-+ while(pgsqlmap->p)
-+ pgsqlmap=pgsqlmap->p;
-+
-+ do {
-+ if (pgsqlmap->conn==conn) {
-+ /*
-+ * no pressing desire to remove it from the structure, sendmail will
-+ * exit soon enough. just free the data and null the conn value
-+ */
-+ if(pgsqlmap->host) {
-+ pgsqlmap->host=NULL;
-+ }
-+ if(pgsqlmap->connstr) {
-+ pgsqlmap->connstr=NULL;
-+ }
-+ pgsqlmap->conn=NULL;
-+ pgsqlmap->pid=0;
-+ return 1;
-+ }
-+
-+ if (pgsqlmap->n)
-+ pgsqlmap=pgsqlmap->n;
-+ else
-+ break;
-+ } while(1);
-+
-+ return 0;
-+}
-+
-+/*
-+ * PostgreSQL map functionality for Sendmail 8.12.0
-+ * Portions Copyright (C) 2000 Jonathan Yarden <jyarden@bluegrass.net>
-+ * Remainder copyright (c) 2000,2001 David Ford <david@blue-labs.org>
-+ *
-+ * For information on PostgreSQL, visit http://www.pgsql.com/
-+ * Information on this patch and setup is at http://blue-labs.org/ under
-+ * sendmail link.
-+ *
-+ * This patch, because it integrates with and is based on the existing
-+ * prior work of Sendmail, is considered by me to be a "derivative
-+ * work" subject to the Sendmail licensing terms. Sendmail, Inc. in not
-+ * responsable for this code.
-+ *
-+ * USE AT YOUR OWN RISK. NO WARRANTY OF ANY KIND IS PROVIDED. PLEASE
-+ * READ THE INSTRUCTIONS FOR USE OF THIS PATCH BEFORE CONTACTING THE
-+ * AUTHOR OR SENDMAIL, INC. NO SUPPORT OF ANY KIND WILL BE PROVIDED
-+ * BY SENDMAIL, INC. FOR THIS PATCH.
-+ */
-+
-+char *skip_quotes(char *p)
-+{
-+ p = strchr(p,'"');
-+ if (p) {
-+ p++;
-+ p = strchr(p,'"');
-+ if (p) p++;
-+ }
-+ return p;
-+}
-+/*
-+ * Parse PostgreSQL map definition args.
-+ *
-+ * Nothing really special here, since to be perfectly honest, I have never
-+ * seen or used almost all of these options. Most of this code was taken
-+ * directly from existing Sendmail source code.
-+ */
-+bool
-+pgsql_map_parseargs(map,args)
-+ MAP *map;
-+ char *args;
-+{
-+ register char *p = args;
-+ register int done;
-+
-+ map->map_mflags |= MF_TRY0NULL | MF_TRY1NULL;
-+ for (;;) {
-+ while (isascii(*p) && isspace(*p))
-+ p++;
-+ if (*p != '-')
-+ break;
-+ switch (*++p) {
-+ case 'N':
-+ map->map_mflags |= MF_INCLNULL;
-+ map->map_mflags &= ~MF_TRY0NULL;
-+ break;
-+
-+ case 'O':
-+ map->map_mflags &= ~MF_TRY1NULL;
-+ break;
-+
-+ case 'o':
-+ map->map_mflags |= MF_OPTIONAL;
-+ break;
-+
-+ case 'f':
-+ map->map_mflags |= MF_NOFOLDCASE;
-+ break;
-+
-+ case 'm':
-+ map->map_mflags |= MF_MATCHONLY;
-+ break;
-+
-+ case 'A':
-+ map->map_mflags |= MF_APPEND;
-+ break;
-+
-+ case 'q':
-+ map->map_mflags |= MF_KEEPQUOTES;
-+ break;
-+
-+ case 't':
-+ map->map_mflags |= MF_NODEFER;
-+ break;
-+
-+ case 'a':
-+ map->map_app = ++p;
-+ break;
-+
-+ case 'T':
-+ map->map_tapp = ++p;
-+ break;
-+
-+/*
-+ * Start of PostgreSQL specific args. I cheat and use some existing
-+ * Sendmail variables here since this map class makes no other use of them.
-+ */
-+
-+ case 'c': /* connection string */
-+ map->map_keycolnm = ++p;
-+ p = skip_quotes(p);
-+ break;
-+
-+ case 'h': /* host string */
-+ map->map_db2 = ++p;
-+ p = skip_quotes(p);
-+ break;
-+
-+ case 's': /* select statement */
-+ map->map_valcolnm = ++p;
-+ p = skip_quotes(p);
-+ break;
-+ }
-+
-+ if (*p != '\0')
-+ *p++ = '\0';
-+ }
-+
-+ if (map->map_app != NULL)
-+ map->map_app = newstr(map->map_app);
-+
-+ if (map->map_tapp != NULL)
-+ map->map_tapp = newstr(map->map_tapp);
-+
-+ if(map->map_db2 != NULL) {
-+ map->map_db2 = newstr(map->map_db2);
-+ stripquotes(map->map_db2);
-+ p=map->map_db2;
-+ while(*p==' ')
-+ p++;
-+ map->map_db2=p;
-+ }
-+
-+ if (map->map_keycolnm != NULL) { /* database connect string */
-+ map->map_keycolnm = newstr(map->map_keycolnm);
-+ stripquotes(map->map_keycolnm);
-+ p=map->map_keycolnm;
-+ while(*p==' ')
-+ p++;
-+ map->map_keycolnm=p;
-+ } else {
-+ syserr("No PostgreSQL connect string for %s map %s",
-+ map->map_class->map_cname, map->map_mname);
-+ return false;
-+ }
-+
-+ if (map->map_valcolnm != NULL) { /* select statement */
-+ map->map_valcolnm = newstr(map->map_valcolnm);
-+ stripquotes(map->map_valcolnm);
-+ p=map->map_valcolnm;
-+ while(*p==' ')
-+ p++;
-+ map->map_valcolnm=p;
-+ } else {
-+ syserr("No PostgreSQL select statement for %s map %s",
-+ map->map_class->map_cname, map->map_mname);
-+ return false;
-+ }
-+
-+#if (PGSQLDEBUG)
-+ sm_syslog(LOG_MAIL, NOQID, "psqlinfo(%s, %s, %s)",
-+ map->map_db2, map->map_keycolnm, map->map_valcolnm);
-+#endif
-+ return true;
-+}
-+
-+/*
-+ * Open a PostgreSQL database connection using the connection string.
-+ *
-+ * Returns TRUE if the database was opened or FALSE if it choked.
-+ *
-+ * - Changed to check return status better on open and save
-+ * PID to fix Broken pipes from child processes closing the
-+ * connection on us.
-+ */
-+bool
-+pgsql_map_open(map, mode)
-+ MAP *map;
-+ int mode;
-+{
-+ PGconn *conn;
-+ char *s;
-+ int n=0;
-+
-+ conn=(PGconn *) map->map_db1;
-+
-+ /*
-+ * check our list for an already established connection that
-+ * matches both the host and connection string
-+ * keycolnm is the connection string
-+ * file is the hostname
-+ */
-+ conn=getconn(map->map_db2, map->map_keycolnm);
-+
-+ /*
-+ * we already have a connection to the server
-+ */
-+ if (PQstatus(conn) == CONNECTION_OK) {
-+#if (PGSQLDEBUG)
-+ sm_syslog(LOG_MAIL, NOQID, "AlreadyExists (host:%s, cstr:%s, conn:%p)",
-+ map->map_db2, map->map_keycolnm, conn);
-+#endif
-+ map->map_db1 = (ARBPTR_T) conn;
-+ return true;
-+ }
-+
-+ if(map->map_db2)
-+ n+=strlen(map->map_db2);
-+ if(map->map_keycolnm)
-+ n+=strlen(map->map_keycolnm);
-+
-+ s=malloc(n+2);
-+ sprintf(s, "%s %s",
-+ map->map_db2? map->map_db2:"",
-+ map->map_keycolnm? map->map_keycolnm:"");
-+
-+ conn=PQconnectdb(s);
-+ if (!conn || PQstatus(conn) == CONNECTION_BAD) {
-+ if (conn)
-+ PQfinish(conn);
-+ syserr("Cannot open %s map \'%s\' using \"%s\" (%s)",
-+ map->map_class->map_cname,
-+ map->map_mname,
-+ s,
-+ PQerrorMessage(conn));
-+ free(s);
-+ return false;
-+ }
-+ free(s);
-+
-+ addconn(map->map_db2, map->map_keycolnm, conn);
-+ map->map_db1 = (ARBPTR_T) conn;
-+ map->map_pid = getpid(); /* save PID for check on close */
-+ return true;
-+}
-+
-+/*
-+ * Close the PostgreSQL database connection, check that the opening process
-+ * is the closing process; ignore if not.
-+ */
-+void
-+pgsql_map_close(map)
-+ MAP *map;
-+{
-+ PGconn *conn;
-+ int r;
-+
-+ if (map->map_pid == getpid()) {
-+ conn= (PGconn *) map->map_db1;
-+ r=removeconn(conn);
-+ if(r)
-+ PQfinish(conn);
-+#if (PGSQLDEBUG)
-+ sm_syslog(LOG_MAIL, NOQID, "Closed map %s", map->map_mname);
-+#endif
-+ }
-+}
-+
-+/*
-+** PGSQL_MAP_LOOKUP -- look up a datum in a PGSQL map
-+**
-+** Attempt to map an incoming key value with a PostgreSQL query.
-+**
-+** This performs the query specified in the Sendmail config file and
-+** uses the value of the first row and column as the map data value.
-+** All other rows and columns are ignored.
-+**
-+** July 8, 2000
-+**
-+** - Modified to check the status of the PostgreSQL connection and reset it
-+** if it looks like it has dropped. This was done to flush out an error,
-+** but it's a good idea to do this anyway just in case.
-+**
-+*/
-+char *
-+pgsql_map_lookup(map, name, av, statp)
-+ MAP *map;
-+ char *name;
-+ char **av;
-+ int *statp;
-+{
-+ int len,ntuples,r;
-+ char *sbuf;
-+ char sname[MAXNAME+1];
-+ char resbuf[MAXNAME+1];
-+ PGconn *conn = (PGconn *) map->map_db1;
-+ PGresult *res;
-+
-+ bzero(sname,sizeof sname);
-+ bzero(resbuf,sizeof resbuf);
-+
-+ /* Buffer overflow check. */
-+ len = strlen(name);
-+ if (len > MAXNAME)
-+ len=MAXNAME;
-+ bcopy(name,sname,len);
-+
-+ if (!bitset(MF_NOFOLDCASE, map->map_mflags))
-+ makelower(sname);
-+
-+ /* Allocate query buffer (select statement + key value) */
-+ len = strlen(map->map_valcolnm) + strlen(sname);
-+ sbuf = xalloc(len);
-+ bzero(sbuf,len);
-+
-+/*
-+ * Check the backend to make sure it's still valid. If it's not, try and
-+ * reset the connection. This is a good idea anyway, just in case
-+ * the backend died. BTW this is how I discovered the "child close" bug.
-+ */
-+ r=PQstatus(conn);
-+ if (r == CONNECTION_BAD) {
-+#if (PGSQLDEBUG)
-+ sm_syslog(LOG_MAIL, NOQID, "CNX Bad, resetting (%i)", r);
-+#endif
-+ PQreset(conn); /* does this block? I hope so */
-+ if (PQstatus(conn) == CONNECTION_BAD) {
-+ PQfinish(conn);
-+ syserr("Unable to reestablish closed PGSQL connection %s",map->map_keycolnm);
-+ return NULL;
-+ }
-+ }
-+
-+ /* Create SQL query statement and execute it */
-+ sprintf(sbuf,map->map_valcolnm,sname);
-+
-+ /*syserr("starting map lookup, pid: %i", map->map_pid);*/
-+ res = PQexec(conn,sbuf);
-+ if (PQresultStatus(res) != PGRES_TUPLES_OK) {
-+ PQclear(res);
-+ syserr("Cannot query PGSQL database %s using %s",map->map_keycolnm,sbuf);
-+ return NULL;
-+ }
-+
-+/*
-+ * See if anything came back. If no rows were returned, nothing there for
-+ * this query.
-+ */
-+ ntuples = PQntuples(res);
-+ if (ntuples <= 0) {
-+ PQclear(res);
-+ return NULL;
-+ }
-+
-+/*
-+ * Get the result from column 0 and clear the rest of the result.
-+ * If the result data is too big, then it's truncated.
-+ */
-+ len = PQgetlength(res,0,0);
-+ if (len > MAXNAME) len=MAXNAME;
-+ bcopy(PQgetvalue(res,0,0),resbuf,len);
-+ PQclear(res);
-+
-+/*
-+ * Process results like the other map classes do.
-+ */
-+ /*syserr("finishing map lookup, pid: %i", map->map_pid);*/
-+ if (bitset(MF_MATCHONLY, map->map_mflags))
-+ return map_rewrite(map, name, strlen(name), NULL);
-+ else
-+ return map_rewrite(map, resbuf, len, av);
-+}
-+#endif /* PGSQLMAP */
- /*
- ** PH map
- */