1e0b05ad794955de51c76fa9a616f32eedb0a062
[packages/sendmail.git] / bluelabs.patch-8.12.3
1 diff -urN sendmail-8.12.3/Makefile sendmail-8.12.3.patched/Makefile
2 --- sendmail-8.12.3/Makefile    Thu Aug 23 22:44:39 2001
3 +++ sendmail-8.12.3.patched/Makefile    Fri Apr 26 17:10:37 2002
4 @@ -2,7 +2,7 @@
5  
6  SHELL= /bin/sh
7  SUBDIRS= libsm libsmutil libsmdb sendmail editmap mail.local \
8 -        mailstats makemap praliases rmail smrsh vacation
9 +        mailstats rmail smrsh vacation
10  # libmilter: requires pthread
11  BUILD=   ./Build
12  OPTIONS= $(CONFIG) $(FLAGS)
13 diff -urN sendmail-8.12.3/bluelabs.mc sendmail-8.12.3.patched/bluelabs.mc
14 --- sendmail-8.12.3/bluelabs.mc Thu Jan  1 01:00:00 1970
15 +++ sendmail-8.12.3.patched/bluelabs.mc Fri Apr 26 17:10:37 2002
16 @@ -0,0 +1,243 @@
17 +######################################################################
18 +# This is the Blue Labs m4 file.
19 +#
20 +# A work-in-progress website for building sendmail with this patch is
21 +# at http://blue-labs.org/clue/sendmail.php
22 +#
23 +# !!! EDIT THE CONFIGURATION SETTINGS TO MATCH YOUR DESIRES !!!
24 +#
25 +# NOTE: THIS IS A SPECIALISED .cf FOR THE POSTGRESQL PATCH ONLY
26 +#
27 +VERSIONID(`(#) Blue Labs bluelabs.mc   v 9.1 (Blue Labs) 10/13/2001')
28 +######################################################################
29 +
30 +##
31 +# See http://blue-labs.org/clue/sendmail.php for detailed instructions
32 +#
33 +# TODO: replace 'newaliases' and 'makemap' targets with "don't run this"
34 +#       replace man pages also
35 +##
36 +
37 +# compile options
38 +divert(-1)dnl
39 +OSTYPE(linux)dnl
40 +define(`confBLDVARIANT',`OPTIMIZED') # optimize the binary
41 +# note, there will be two -O flags as it compiles.  According to the gcc
42 +# man page, the last one on the line is used in the compile
43 +define(`confCCOPTS',`-O3 -pipe -mcpu=i686 -march=i686')dnl
44 +APPENDDEF(`confENVDEF', `-DSM_CONF_SHM -DDNSMAP -DMILTER -DMAP_REGEX')dnl
45 +
46 +#####################################################################################
47 +#
48 +# BIG BOLD WARNING.  link -lcrypt BEFORE -lcrypto or your md5 salted
49 +# passwords will handled as DES passwords and FAIL TO WORK.  Thank OpenSSL for
50 +# this
51 +#
52 +#####################################################################################
53 +
54 +##
55 +# SASL, be sure to link -lcrypt FIRST so it overrides the built-in crypt()
56 +# in openssl, !@#$!@% that is so frustrating
57 +##
58 +APPENDDEF(`confENVDEF', `-DSASL')dnl
59 +APPENDDEF(`confINCDIRS', `-I/usr/local/include -I/usr/local/include/sasl')dnl
60 +APPENDDEF(`confLIBS', `-lsasl -lcrypt')dnl
61 +APPENDDEF(`confLIBDIRS', `-L/usr/local/lib/sasl')dnl
62 +define(`confDEF_AUTH_INFO', `/etc/mail/auth/auth-info')dnl
63 +define(`confAUTH_MECHANISMS', `DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
64 +TRUST_AUTH_MECH(`DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
65 +
66 +##
67 +# postgres items
68 +##
69 +APPENDDEF(`confMAPDEF',`-DPGSQLMAP')dnl
70 +APPENDDEF(`confINCDIRS',`-I/usr/local/pgsql/include')dnl
71 +APPENDDEF(`confLIBDIRS',`-L/usr/local/pgsql/lib')dnl
72 +# if you have compiled/installed BIND, you need to add -lresolv
73 +APPENDDEF(`confLIBS',`-lpq -lresolv')dnl
74 +
75 +##
76 +# TLS (ssl) items
77 +#
78 +# Compile with -D_FFR_SASL_OPTS and set 'p' in AuthOptions. (p not done)
79 +#
80 +##
81 +APPENDDEF(`confENVDEF',`-DSTARTTLS -D_FFR_SASL_OPTS')dnl
82 +APPENDDEF(`confLIBS',`-lssl -lcrypto')dnl
83 +define(`SSL_DIR', `/usr/ssl')dnl
84 +define(`confCACERT_PATH', `SSL_DIR/certs')dnl
85 +define(`confCACERT', `SSL_DIR/certs/cacert.pem')dnl
86 +define(`confSERVER_CERT', `SSL_DIR/certs/mailcert.pem')dnl
87 +define(`confSERVER_KEY', `SSL_DIR/private/mailkey.pem')dnl
88 +define(`confCLIENT_CERT', `SSL_DIR/certs/mailcert.pem')dnl
89 +define(`confCLIENT_KEY', `SSL_DIR/private/mailkey.pem')dnl
90 +define(`confAUTH_OPTIONS',`p')
91 +
92 +FEclass-E-expose
93 +FLclass-L-localusers
94 +
95 +##
96 +# example line:
97 +#  pgsql [-h <pgsql server>] -c <connection string> -s <query string>
98 +##
99 +
100 +APPENDDEF(`DATABASE_MAP_TYPE', `pgsql')dnl
101 +define(`PG_WHERE', where s_in='%s')
102 +define(`PG_CONNSTR', "dbname=sendmail user=sendmail")
103 +define(`PG_SOUT', "select distinct s_out from)
104 +FEATURE(`pg_aliases', pgsql -c `PG_CONNSTR' -s `PG_SOUT' aliases `PG_WHERE'")dnl
105 +FEATURE(`pg_virtualusers', pgsql -c `PG_CONNSTR' -s `PG_SOUT' virtualusers `PG_WHERE'")dnl
106 +FEATURE(`pg_usersdb', pgsql -c `PG_CONNSTR' -s `PG_SOUT' userrewrite `PG_WHERE'")dnl
107 +FEATURE(`pg_accessdb', pgsql -c `PG_CONNSTR' -s `PG_SOUT' access `PG_WHERE'")dnl
108 +FEATURE(`pg_domaintable', pgsql -c `PG_CONNSTR' -s `PG_SOUT' domaintable `PG_WHERE'")dnl
109 +FEATURE(`pg_generics', pgsql -c `PG_CONNSTR' -s `PG_SOUT' genericstable `PG_WHERE'")dnl
110 +FEATURE(`pg_mailer', pgsql -c `PG_CONNSTR' -s `PG_SOUT' mailertable `PG_WHERE'")dnl
111 +
112 +define(`confPROCESS_TITLE_PREFIX', `[Blue-PgSQL]')dnl
113 +define(`confMAX_MESSAGE_SIZE', `52428800')dnl  # 50 Megs
114 +define(`confFORWARD_PATH', `$z/.forward:/etc/mail/forward-files/$u')dnl
115 +define(`confHOST_STATUS_DIRECTORY', `/etc/mail/host-status/')dnl
116 +define(`confDEF_USER_ID', `mail')dnl
117 +define(`confMAX_DAEMON_CHILDREN', `40')dnl
118 +define(`confCONNECTION_RATE_THROTTLE', `20')dnl
119 +define(`confSINGLE_LINE_FROM_HEADER', `True')dnl
120 +define(`confSMTP_LOGIN_MSG', `$j Sendmail $v/$Z; $b\
121 + \
122 + Spam is prohibited here and any detected spam may be used in prosecution\
123 + against the spammer. This sendmail setup uses PgSQL (postgres) for most of\
124 + it''`s tables, for information on this, see\
125 + http://blue-labs.org/clue/sendmail.php\
126 + \
127 +')dnl
128 +define(`confDONT_PROBE_INTERFACES', `True')dnl
129 +define(`confREJECT_MSG', `550 Your mail is rejected.\
130 +    Contact <admin@$m> to have this matter resolved.\
131 + ')dnl
132 +define(`confTO_INITIAL', `1m')dnl
133 +define(`confTO_CONNECT', `15s')dnl
134 +define(`confTO_HELO', `4m')dnl
135 +define(`confTO_HOSTSTATUS', `1m')dnl
136 +define(`confTO_DATAINIT', `2m')dnl
137 +define(`confTO_DATABLOCK', `5m')dnl
138 +define(`confTO_DATAFINAL', `5m')dnl
139 +define(`confCONNECTION_RATE_THROTTLE', `40')dnl
140 +define(`confDIAL_DELAY', `15s')dnl
141 +define(`confNO_RCPT_ACTION', `add-apparently-to')dnl
142 +define(`confALIAS_WAIT', `0')dnl
143 +define(`confMAX_HOP', `35')dnl
144 +define(`confQUEUE_LA', `5')dnl
145 +define(`confREFUSE_LA', `12')dnl
146 +define(`confSEPARATE_PROC', `False')dnl
147 +
148 +define(`confCON_EXPENSIVE', `true')dnl
149 +define(`confWORK_RECIPIENT_FACTOR', `1000')dnl
150 +define(`confWORK_TIME_FACTOR', `3000')dnl
151 +define(`confQUEUE_SORT_ORDER', `Time')dnl
152 +
153 +define(`confDEAD_LETTER_DROP', `/var/tmp/dead.letter')dnl
154 +define(`confRRT_IMPLIES_DSN', `True')dnl
155 +define(`confCONTROL_SOCKET_NAME', `/var/spool/mqueue/.control')dnl
156 +define(`confMAX_HEADERS_LENGTH', `16384')dnl
157 +define(`confMAX_ALIAS_RECURSION', `10')dnl
158 +define(`confMAX_RCPTS_PER_MESSAGE', `50')dnl
159 +define(`confSHAREDMEMORYKEY', `42')dnl
160 +define(`confMCI_CACHE_SIZE', `4')dnl
161 +define(`PROCMAIL_MAILER_PATH', `/usr/bin/procmail')dnl
162 +define(`STATUS_FILE', `/etc/mail/sendmail-status')dnl
163 +
164 +##
165 +# queue groups
166 +##
167 +FEATURE(`queuegroup')dnl
168 +define(`QUEUE_DIR', `/var/spool/mqueue')dnl
169 +define(`LOCAL_PROG_QGRP', `local')dnl
170 +define(`LOCAL_MAILER_QGRP', `local')dnl
171 +define(`ESMTP_MAILER_QGRP', `smtp')dnl
172 +define(`SMTP8_MAILER_QGRP', `smtp')dnl
173 +define(`DSMTP_MAILER_QGRP', `smtp')dnl
174 +define(`RELAY_MAILER_QGRP', `smtp')dnl
175 +dnl QUEUE_GROUP(`mqueue', `P=/var/spool/mqueue, r=5, F=f, R=2')dnl
176 +
177 +dnl Nice is the nice(2) increment for queue groups
178 +dnl Interval is the tiem between two queue runs
179 +dnl Path..
180 +dnl Runners is the number of parallel queue runners
181 +dnl Jobs is the max number of messages delivered per queue run
182 +dnl recipients is the max number of recipients per envelope
183 +
184 +QUEUE_GROUP(`local', `P=/var/spool/mqueue/local, N=0, I=30s, R=5, J=500, r=100, F=f')dnl
185 +QUEUE_GROUP(`smtp', `P=/var/spool/mqueue/smtp, N=5, I=30s, R=10, J=500, r=100, F=f')dnl
186 +QUEUE_GROUP(`relay', `P=/var/spool/mqueue/relay, N=10, I=1m, R=2, r=100, F=f')dnl
187 +QUEUE_GROUP(`lmtp', `P=/var/spool/mqueue/lmtp, N=0, I=30s, R=2, r=100, F=f')dnl
188 +QUEUE_GROUP(`expensive', `P=/var/spool/mqueue/expensive, F=e, N=19 I=5m R=1 r=200')dnl
189 +
190 +# HoldExpensive  [c] If an outgoing mailer is marked as being expensive, don't connect
191 +# immediately. This requires that queueing be compiled in, since it will depend on a queue
192 +# run process to actually send the mail.
193 +
194 +##
195 +# distinguish case on names, Blu3 is different from blu3
196 +##
197 +MODIFY_MAILER_FLAGS(`LOCAL', `+u')dnl
198 +
199 +FEATURE(`always_add_domain')dnl
200 +FEATURE(`blacklist_recipients')dnl
201 +dnl FEATURE(`dnsbl',`rbl.maps.vix.com',` Mail from $&{client_addr} rejected; see http://mail-abuse.org/rbl/')dnl
202 +dnl FEATURE(`dnsbl',`dul.maps.vix.com')dnl
203 +
204 +FEATURE(`dnsbl',`blackholes.mail-abuse.org',  `Mail from $&{client_addr} rejected; see http://mail-abuse.org/rbl/')dnl
205 +FEATURE(`dnsbl',`dialups.mail-abuse.org',  `Mail from $&{client_addr} rejected; see http://mail-abuse.org/rbl/')dnl
206 +FEATURE(`dnsbl',`relays.mail-abuse.org',  `Mail from $&{client_addr} rejected; see http://mail-abuse.org/rbl/')dnl
207 +
208 +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
209 +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
210 +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
211 +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
212 +
213 +FEATURE(`delay_checks')dnl
214 +FEATURE(`generics_entire_domain')dnl
215 +FEATURE(`local_procmail')dnl
216 +FEATURE(`masquerade_envelope')dnl
217 +FEATURE(`nouucp',`reject')dnl
218 +FEATURE(`redirect')dnl
219 +FEATURE(`relay_based_on_MX')dnl
220 +FEATURE(`relay_entire_domain')dnl
221 +FEATURE(`use_ct_file')dnl
222 +FEATURE(`use_cw_file')dnl
223 +FEATURE(`virtuser_entire_domain')dnl
224 +FEATURE(`delay_checks',`friend')dnl
225 +FEATURE(`lookupdotdomain')
226 +
227 +MASQUERADE_DOMAIN_FILE(`/etc/mail/masquerade-these-as-me')dnl
228 +
229 +MAILER(local)dnl
230 +MAILER(smtp)dnl
231 +
232 +LOCAL_RULESETS
233 +
234 +#
235 +# snow white
236 +#
237 +HFrom: $>CheckFrom
238 +SCheckFrom
239 +# Snow White Virus
240 +R$* <hahaha@sexyfun.net> $*    $#error $: "553 Delivery blocked: Snow White virus"
241 +
242 +#
243 +# sircam
244 +#
245 +Kchkcontent regex -a@REJ Outlook_Express_message_boundary
246 +HContent-Type: $>CheckContent
247 +SCheckContent
248 +R$*            $: $(chkcontent $&({currHeader} $)
249 +R@REJ          $error $: "553 Delivery blocked  ---  SirCam virus detected"
250 +
251 +#
252 +# subject check
253 +# subject encodings, non-ascii characters, and trailing numbers in subject
254 +# with lots of spaces are spam
255 +Kchksubject regex -a@REJ ^=\?|[\80-ΓΏ]{3,}| {9,}[0-9]{3,}| {9,}\[[A-Za-z0-9]{3,}\]
256 +HSubject: $>CheckSubject
257 +SCheckSubject
258 +R$*            $: $(chksubject $&{currHeader} $)
259 +R@REJ          $#error $: "553 Delivery blocked  ---  `Subject:' suggests spam"
260 diff -urN sendmail-8.12.3/cf/feature/pg_accessdb.m4 sendmail-8.12.3.patched/cf/feature/pg_accessdb.m4
261 --- sendmail-8.12.3/cf/feature/pg_accessdb.m4   Thu Jan  1 01:00:00 1970
262 +++ sendmail-8.12.3.patched/cf/feature/pg_accessdb.m4   Fri Apr 26 17:10:37 2002
263 @@ -0,0 +1,19 @@
264 +divert(-1)
265 +# By using this file, you agree to be cool and share your knowledge
266 +#
267 +# David, http://blue-labs.org/clue/sendmail.php
268 +#
269 +
270 +divert(0)
271 +VERSIONID(`$Id$')
272 +divert(-1)
273 +
274 +define(`_ACCESS_TABLE_', `')
275 +define(`_PG_ACCESS_TABLE_', `')
276 +define(`_TAG_DELIM_', `:')dnl should be in OperatorChars
277 +
278 +LOCAL_CONFIG
279 +# PostgreSQL based access list
280 +Kaccess ifelse(defn(`_ARG_'), `',
281 +                DATABASE_MAP_TYPE MAIL_SETTINGS_DIR`access',
282 +                `_ARG_')
283 diff -urN sendmail-8.12.3/cf/feature/pg_aliases.m4 sendmail-8.12.3.patched/cf/feature/pg_aliases.m4
284 --- sendmail-8.12.3/cf/feature/pg_aliases.m4    Thu Jan  1 01:00:00 1970
285 +++ sendmail-8.12.3.patched/cf/feature/pg_aliases.m4    Fri Apr 26 17:10:37 2002
286 @@ -0,0 +1,19 @@
287 +divert(-1)
288 +# By using this file, you agree to be cool and share your knowledge
289 +#
290 +# David, http://blue-labs.org/clue/sendmail.php
291 +#
292 +
293 +divert(0)
294 +VERSIONID(`$Id$')
295 +divert(-1)
296 +
297 +undefine(`ALIAS_FILE')
298 +define(`_ALIASES_TABLE_', `')
299 +define(`_PG_ALIASES_TABLE_', `')
300 +
301 +LOCAL_CONFIG
302 +# PostgreSQL based local aliases
303 +Kaliases ifelse(defn(`_ARG_'), `',
304 +                DATABASE_MAP_TYPE MAIL_SETTINGS_DIR`aliases',
305 +                `_ARG_')
306 diff -urN sendmail-8.12.3/cf/feature/pg_domaintable.m4 sendmail-8.12.3.patched/cf/feature/pg_domaintable.m4
307 --- sendmail-8.12.3/cf/feature/pg_domaintable.m4        Thu Jan  1 01:00:00 1970
308 +++ sendmail-8.12.3.patched/cf/feature/pg_domaintable.m4        Fri Apr 26 17:10:37 2002
309 @@ -0,0 +1,18 @@
310 +divert(-1)
311 +# By using this file, you agree to be cool and share your knowledge
312 +#
313 +# David, http://blue-labs.org/clue/sendmail.php
314 +#
315 +
316 +divert(0)
317 +VERSIONID(`$Id$')
318 +divert(-1)
319 +
320 +define(`_DOMAIN_TABLE_', `')
321 +define(`_PG_DOMAIN_TABLE', `')
322 +
323 +LOCAL_CONFIG
324 +# PostgreSQL based domain rewriting table
325 +Kdomaintable ifelse(defn(`_ARG_'), `',
326 +                DATABASE_MAP_TYPE MAIL_SETTINGS_DIR`domaintable',
327 +                `_ARG_')
328 diff -urN sendmail-8.12.3/cf/feature/pg_generics.m4 sendmail-8.12.3.patched/cf/feature/pg_generics.m4
329 --- sendmail-8.12.3/cf/feature/pg_generics.m4   Thu Jan  1 01:00:00 1970
330 +++ sendmail-8.12.3.patched/cf/feature/pg_generics.m4   Fri Apr 26 17:10:37 2002
331 @@ -0,0 +1,18 @@
332 +divert(-1)
333 +# By using this file, you agree to be cool and share your knowledge
334 +#
335 +# David, http://blue-labs.org/clue/sendmail.php
336 +#
337 +
338 +divert(0)
339 +VERSIONID(`$Id$')
340 +divert(-1)
341 +
342 +define(`_GENERICS_TABLE_', `')
343 +define(`_PG_GENERICS_TABLE', `')
344 +
345 +LOCAL_CONFIG
346 +# PostgreSQL based generic domain mapping table, similar to userdb
347 +Kgenerics ifelse(defn(`_ARG_'), `',
348 +                DATABASE_MAP_TYPE MAIL_SETTINGS_DIR`generics',
349 +                `_ARG_')
350 diff -urN sendmail-8.12.3/cf/feature/pg_mailer.m4 sendmail-8.12.3.patched/cf/feature/pg_mailer.m4
351 --- sendmail-8.12.3/cf/feature/pg_mailer.m4     Thu Jan  1 01:00:00 1970
352 +++ sendmail-8.12.3.patched/cf/feature/pg_mailer.m4     Fri Apr 26 17:10:37 2002
353 @@ -0,0 +1,18 @@
354 +divert(-1)
355 +# By using this file, you agree to be cool and share your knowledge
356 +#
357 +# David, http://blue-labs.org/clue/sendmail.php
358 +#
359 +
360 +divert(0)
361 +VERSIONID(`$Id$')
362 +divert(-1)
363 +
364 +define(`_MAILER_TABLE_', `')
365 +define(`_PG_MAILER_TABLE', `')
366 +
367 +LOCAL_CONFIG
368 +# PostgreSQL based mailer table, for overriding domain and MX
369 +Kmailertable ifelse(defn(`_ARG_'), `',
370 +                DATABASE_MAP_TYPE MAIL_SETTINGS_DIR`mailertable',
371 +                `_ARG_')
372 diff -urN sendmail-8.12.3/cf/feature/pg_usersdb.m4 sendmail-8.12.3.patched/cf/feature/pg_usersdb.m4
373 --- sendmail-8.12.3/cf/feature/pg_usersdb.m4    Thu Jan  1 01:00:00 1970
374 +++ sendmail-8.12.3.patched/cf/feature/pg_usersdb.m4    Fri Apr 26 17:10:37 2002
375 @@ -0,0 +1,18 @@
376 +divert(-1)
377 +# By using this file, you agree to be cool and share your knowledge
378 +#
379 +# David, http://blue-labs.org/clue/sendmail.php
380 +#
381 +
382 +divert(0)
383 +VERSIONID(`$Id$')
384 +divert(-1)
385 +
386 +define(`_REWRITE_TABLE_', `')
387 +define(`_PG_REWRITE_TABLE_', `')
388 +
389 +LOCAL_CONFIG
390 +# PostgreSQL based user rewrite table (can turn "John.Doe" into "jdoe")
391 +Kusersdb ifelse(defn(`_ARG_'), `',
392 +                DATABASE_MAP_TYPE MAIL_SETTINGS_DIR`usersdb',
393 +                `_ARG_')
394 diff -urN sendmail-8.12.3/cf/feature/pg_virtualusers.m4 sendmail-8.12.3.patched/cf/feature/pg_virtualusers.m4
395 --- sendmail-8.12.3/cf/feature/pg_virtualusers.m4       Thu Jan  1 01:00:00 1970
396 +++ sendmail-8.12.3.patched/cf/feature/pg_virtualusers.m4       Fri Apr 26 17:10:37 2002
397 @@ -0,0 +1,18 @@
398 +divert(-1)
399 +# By using this file, you agree to be cool and share your knowledge
400 +#
401 +# David, http://blue-labs.org/clue/sendmail.php
402 +#
403 +
404 +divert(0)
405 +VERSIONID(`$Id$')
406 +divert(-1)
407 +
408 +define(`_VIRTUSER_TABLE_', `')
409 +define(`_PG_VIRTUSER_TABLE_', `')
410 +
411 +LOCAL_CONFIG
412 +# PostgreSQL based virtual user table (maps incoming users)
413 +Kvirtuser ifelse(defn(`_ARG_'), `',
414 +                DATABASE_MAP_TYPE MAIL_SETTINGS_DIR`virtusertable',
415 +                `_ARG_')
416 diff -urN sendmail-8.12.3/cf/feature/rhsbl.m4 sendmail-8.12.3.patched/cf/feature/rhsbl.m4
417 --- sendmail-8.12.3/cf/feature/rhsbl.m4 Thu Jan  1 01:00:00 1970
418 +++ sendmail-8.12.3.patched/cf/feature/rhsbl.m4 Fri Apr 26 17:10:37 2002
419 @@ -0,0 +1,43 @@
420 +divert(-1)
421 +#
422 +# Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers.
423 +#      All rights reserved.
424 +#
425 +# By using this file, you agree to the terms and conditions set
426 +# forth in the LICENSE file which can be found at the top level of
427 +# the sendmail distribution.
428 +#
429 +#
430 +
431 +divert(0)
432 +ifdef(`_DNSBL_R_',`dnl',`dnl
433 +VERSIONID(`$Id$')
434 +define(`_DNSBL_R_',`')
435 +LOCAL_CONFIG
436 +# map for DNS based blacklist lookups
437 +Kdnsbl host -T<TMP>')
438 +divert(-1)
439 +define(`_DNSBL_SRV_', `ifelse(len(X`'_ARG_),`1',`blackholes.mail-abuse.org',_ARG_)')dnl
440 +
441 +define(`_DNSBL_LOOKUP_', `ifelse(_ARG4_,`h',`client_name',`client_addr')')dnl
442 +
443 +define(`_DNSBL_MSG_TMP_', `ifelse(_ARG3_,`t',`"451 Temporary lookup failure of "$`'&{_DNSBL_LOOKUP_} " at '_DNSBL_SRV_`"',`_ARG2_')')dnl
444 +define(`_DNSBL_MSG_', `ifelse(len(X`'_ARG2_),`1',`"550 Mail from " $`'&{_DNSBL_LOOKUP_} " refused by blackhole site '_DNSBL_SRV_`"',`_ARG2_')')dnl
445 +divert(8)
446 +
447 +dnl 
448 +dnl the "dnsbl" listed below should be replaced with "host" on 8.11 systems
449 +dnl
450 +
451 +ifelse(_ARG4_,`h',
452 +`R$*                   $: $&{client_name}
453 +R[ $* ]                        $: $1                   Get rid of square brackets
454 +R$*                    $: <?> $(dnsbl $1.'_DNSBL_SRV_`. $: OK $)',
455 +`R$*                   $: $&{client_addr}
456 +R$-.$-.$-.$-           $: <?> $(dnsbl $4.$3.$2.$1.'_DNSBL_SRV_`. $: OK $)')
457 +R<?>OK                 $: OKSOFAR
458 +ifelse(len(X`'_ARG3_),`1',
459 +`R<?>$+<TMP>           $: TMPOK',
460 +`R<?>$+<TMP>           $#error $@ 4.7.1 $: _DNSBL_MSG_TMP_')
461 +R<?>$+                 $#error $@ 5.7.1 $: _DNSBL_MSG_
462 +divert(-1)
463 diff -urN sendmail-8.12.3/include/libsmdb/smdb.h sendmail-8.12.3.patched/include/libsmdb/smdb.h
464 --- sendmail-8.12.3/include/libsmdb/smdb.h      Mon Nov 19 20:30:03 2001
465 +++ sendmail-8.12.3.patched/include/libsmdb/smdb.h      Fri Apr 26 17:10:37 2002
466 @@ -18,6 +18,14 @@
467  # include <sm/gen.h>
468  # include <sm/errstring.h>
469  
470 +# ifndef PGSQLMAP
471 +#  ifndef NDBM
472 +#   ifndef NEWDB
473 +  ERROR        NDBM or NEWDB must be defined.
474 +#   endif /* ! NEWDB */
475 +#  endif /* ! NDBM */
476 +# endif /* ! PGSQLMAP */
477 +
478  # ifdef NDBM
479  #  include <ndbm.h>
480  # endif /* NDBM */
481 diff -urN sendmail-8.12.3/sendmail/Makefile.m4 sendmail-8.12.3.patched/sendmail/Makefile.m4
482 --- sendmail-8.12.3/sendmail/Makefile.m4        Sat Dec  1 00:32:02 2001
483 +++ sendmail-8.12.3.patched/sendmail/Makefile.m4        Fri Apr 26 17:10:37 2002
484 @@ -13,7 +13,7 @@
485  define(`bldTARGET_INST_DEP', ifdef(`confINST_DEP', `confINST_DEP',
486  `${DESTDIR}/etc/mail/submit.cf ${DESTDIR}${MSPQ}'))dnl
487  define(`bldTARGET_LINKS', ifdef(`confLINKS', `confLINKS',
488 -`${DESTDIR}${UBINDIR}/newaliases ${DESTDIR}${UBINDIR}/mailq ${DESTDIR}${UBINDIR}/hoststat ${DESTDIR}${UBINDIR}/purgestat')
489 +`${DESTDIR}${UBINDIR}/mailq ${DESTDIR}${UBINDIR}/hoststat ${DESTDIR}${UBINDIR}/purgestat')
490  )dnl
491  
492  # location of sendmail statistics file (usually /etc/mail/ or /var/log)
493 diff -urN sendmail-8.12.3/sendmail/README sendmail-8.12.3.patched/sendmail/README
494 --- sendmail-8.12.3/sendmail/README     Thu Apr  4 23:39:33 2002
495 +++ sendmail-8.12.3.patched/sendmail/README     Fri Apr 26 17:10:37 2002
496 @@ -117,6 +117,10 @@
497                 have to install the UMich or OpenLDAP
498                 (http://www.openldap.org/) ldap and lber libraries to use
499                 this flag.
500 +PGSQLMAP       PostgreSQL SQL query support.  You will need to have
501 +               PostgreSQL include files and libraries installed to use this
502 +               feature.  Information on PostgreSQL can be found at
503 +               http://www.postgresql.org
504  MAP_REGEX      Regular Expression support.  You will need to use an
505                 operating system which comes with the POSIX regex()
506                 routines or install a regexp library such as libregex from
507 diff -urN sendmail-8.12.3/sendmail/conf.c sendmail-8.12.3.patched/sendmail/conf.c
508 --- sendmail-8.12.3/sendmail/conf.c     Thu Apr  4 23:32:14 2002
509 +++ sendmail-8.12.3.patched/sendmail/conf.c     Fri Apr 26 17:10:37 2002
510 @@ -491,6 +491,12 @@
511                 ldapmap_lookup, null_map_store);
512  #endif /* LDAPMAP */
513  
514 +#ifdef PGSQLMAP
515 +       MAPDEF("pgsql", NULL, MCF_ALIASOK|MCF_NOTPERSIST,
516 +               pgsql_map_parseargs, pgsql_map_open, pgsql_map_close,
517 +               pgsql_map_lookup, null_map_store);
518 +#endif
519 +
520  #if PH_MAP
521         MAPDEF("ph", NULL, MCF_NOTPERSIST,
522                 ph_map_parseargs, ph_map_open, ph_map_close,
523 @@ -5484,6 +5490,9 @@
524  #if LDAPMAP
525         "LDAPMAP",
526  #endif /* LDAPMAP */
527 +#if PGSQL
528 +       "PGSQL",
529 +#endif /* PGSQL */
530  #if LOG
531         "LOG",
532  #endif /* LOG */
533 diff -urN sendmail-8.12.3/sendmail/map.c sendmail-8.12.3.patched/sendmail/map.c
534 --- sendmail-8.12.3/sendmail/map.c      Tue Mar 26 23:56:36 2002
535 +++ sendmail-8.12.3.patched/sendmail/map.c      Fri Apr 26 17:10:37 2002
536 @@ -4839,6 +4839,482 @@
537         }
538  }
539  #endif /* LDAPMAP */
540 +
541 +#ifdef PGSQLMAP
542 +#include <libpq-fe.h>
543 +
544 +struct pgsqlmap {
545 +       struct pgsqlmap *p,*n;
546 +       char *host;
547 +       char *connstr;
548 +       PGconn *conn;
549 +       pid_t pid;
550 +} *pgsqlmap=NULL;
551 +
552 +/*
553 + * search our structure for matching entries/add entry to struct
554 + */
555 +
556 +PGconn *getconn(char *host, char *connstr)
557 +{
558 +       pid_t p=getpid();
559 +       
560 +       if(!pgsqlmap)
561 +               return NULL;
562 +
563 +       while(pgsqlmap->p)
564 +               pgsqlmap=pgsqlmap->p;
565 +
566 +#if (PGSQLDEBUG)
567 +       sm_syslog(LOG_MAIL, NOQID, "   HostSearch (host:%s, cstr:%s, pid:%i)",
568 +               host, connstr, p);
569 +#endif
570 +
571 +       // only return connections that match everything                
572 +       do {
573 +               if(pgsqlmap->conn) {
574 +                       if (!strncmp(connstr, pgsqlmap->connstr, strlen(connstr)+1)) {
575 +                               if ((!host && !pgsqlmap->host) || !strncmp(host, pgsqlmap->host, strlen(host)+1)) {
576 +                                       if (pgsqlmap->pid == p) {
577 +                                               return pgsqlmap->conn;
578 +                                       }
579 +                               }
580 +                       }
581 +               }
582 +
583 +               if (pgsqlmap->n)
584 +                       pgsqlmap=pgsqlmap->n;
585 +               else
586 +                       break;
587 +       } while(1);
588 +
589 +       return NULL;
590 +}
591 +
592 +void addconn(char *host, char *connstr, PGconn *conn)
593 +{
594 +       if(pgsqlmap) {
595 +               // advance, then alloc
596 +               while(pgsqlmap->n)
597 +                       pgsqlmap=pgsqlmap->n;
598 +               pgsqlmap->n= (struct pgsqlmap *) xalloc(sizeof(struct pgsqlmap));
599 +               bzero(pgsqlmap->n, sizeof(struct pgsqlmap));
600 +               pgsqlmap->n->p=pgsqlmap;
601 +               pgsqlmap=pgsqlmap->n;
602 +       } else {
603 +               // create
604 +               pgsqlmap= (struct pgsqlmap *) xalloc(sizeof(struct pgsqlmap));
605 +               bzero(pgsqlmap, sizeof(struct pgsqlmap));
606 +       }
607 +
608 +       pgsqlmap->host=host;
609 +       pgsqlmap->connstr=connstr;
610 +       pgsqlmap->conn=conn;
611 +       pgsqlmap->pid=getpid();
612 +
613 +#if (PGSQLDEBUG)
614 +       sm_syslog(LOG_MAIL, NOQID, "      HostAdd (host:%s, cstr:%s, conn:%p, pid:%i)",
615 +               host, connstr, conn, pgsqlmap->pid);
616 +#endif
617 +}
618 +
619 +int removeconn(PGconn *conn)
620 +{
621 +       if(!pgsqlmap)
622 +               return 0;
623 +
624 +       while(pgsqlmap->p)
625 +               pgsqlmap=pgsqlmap->p;
626 +
627 +       do {
628 +               if (pgsqlmap->conn==conn) {
629 +                       /*
630 +                        * no pressing desire to remove it from the structure, sendmail will
631 +                        * exit soon enough. just free the data and null the conn value
632 +                        */
633 +                       if(pgsqlmap->host) {
634 +                               pgsqlmap->host=NULL;
635 +                       }
636 +                       if(pgsqlmap->connstr) {
637 +                               pgsqlmap->connstr=NULL;
638 +                       }
639 +                       pgsqlmap->conn=NULL;
640 +                       pgsqlmap->pid=0;
641 +                       return 1;
642 +               }
643 +
644 +               if (pgsqlmap->n)
645 +                       pgsqlmap=pgsqlmap->n;
646 +               else
647 +                       break;
648 +       } while(1);
649 +       
650 +       return 0;
651 +}
652 +
653 +/* 
654 + * PostgreSQL map functionality for Sendmail 8.12.0
655 + * Portions Copyright (C) 2000 Jonathan Yarden <jyarden@bluegrass.net>
656 + * Remainder copyright (c) 2000,2001 David Ford <david@blue-labs.org>
657 + *
658 + * For information on PostgreSQL, visit http://www.pgsql.com/
659 + * Information on this patch and setup is at http://blue-labs.org/ under
660 + * sendmail link.
661 + *
662 + * This patch, because it integrates with and is based on the existing
663 + * prior work of Sendmail, is considered by me to be a "derivative
664 + * work" subject to the Sendmail licensing terms.  Sendmail, Inc. in not
665 + * responsable for this code.
666 + *
667 + * USE AT YOUR OWN RISK.  NO WARRANTY OF ANY KIND IS PROVIDED. PLEASE
668 + * READ THE INSTRUCTIONS FOR USE OF THIS PATCH BEFORE CONTACTING THE
669 + * AUTHOR OR SENDMAIL, INC.  NO SUPPORT OF ANY KIND WILL BE PROVIDED
670 + * BY SENDMAIL, INC. FOR THIS PATCH.
671 + */
672 +
673 +char *skip_quotes(char *p)
674 +{
675 +   p = strchr(p,'"');
676 +   if (p) {
677 +      p++;
678 +      p = strchr(p,'"');
679 +      if (p) p++;
680 +   }
681 +   return p;
682 +}
683 +/*
684 + * Parse PostgreSQL map definition args.
685 + *
686 + * Nothing really special here, since to be perfectly honest, I have never
687 + * seen or used almost all of these options.  Most of this code was taken
688 + * directly from existing Sendmail source code.
689 + */
690 +bool
691 +pgsql_map_parseargs(map,args)
692 +       MAP *map;
693 +       char *args;
694 +{
695 +       register char *p = args;
696 +       register int done;
697 +
698 +       map->map_mflags |= MF_TRY0NULL | MF_TRY1NULL;
699 +       for (;;) {
700 +               while (isascii(*p) && isspace(*p))
701 +                       p++;
702 +               if (*p != '-')
703 +                       break;
704 +               switch (*++p) {
705 +                       case 'N':
706 +                               map->map_mflags |= MF_INCLNULL;
707 +                               map->map_mflags &= ~MF_TRY0NULL;
708 +                               break;
709 +
710 +                       case 'O':
711 +                               map->map_mflags &= ~MF_TRY1NULL;
712 +                               break;
713 +
714 +                       case 'o':
715 +                               map->map_mflags |= MF_OPTIONAL;
716 +                               break;
717 +
718 +                       case 'f':
719 +                               map->map_mflags |= MF_NOFOLDCASE;
720 +                               break;
721 +
722 +                       case 'm':
723 +                               map->map_mflags |= MF_MATCHONLY;
724 +                               break;
725 +
726 +                       case 'A':
727 +                               map->map_mflags |= MF_APPEND;
728 +                               break;
729 +
730 +                       case 'q':
731 +                               map->map_mflags |= MF_KEEPQUOTES;
732 +                               break;
733 +
734 +                       case 't':
735 +                               map->map_mflags |= MF_NODEFER;
736 +                               break;
737 +
738 +                       case 'a':
739 +                               map->map_app = ++p;
740 +                               break;
741 +
742 +                       case 'T':
743 +                               map->map_tapp = ++p;
744 +                               break;
745 +
746 +/* 
747 + * Start of PostgreSQL specific args.  I cheat and use some existing
748 + * Sendmail variables here since this map class makes no other use of them.
749 + */
750 +
751 +                       case 'c':               /* connection string */
752 +                               map->map_keycolnm = ++p;
753 +                               p = skip_quotes(p);
754 +                               break;
755 +
756 +                       case 'h':               /* host string */
757 +                               map->map_db2 = ++p;
758 +                               p = skip_quotes(p);
759 +                               break;
760 +
761 +                       case 's':               /* select statement */
762 +                               map->map_valcolnm = ++p;
763 +                               p = skip_quotes(p);
764 +                               break;
765 +               }
766 +
767 +               if (*p != '\0')
768 +                       *p++ = '\0';
769 +       }
770 +
771 +       if (map->map_app != NULL)
772 +               map->map_app = newstr(map->map_app);
773 +
774 +       if (map->map_tapp != NULL)
775 +               map->map_tapp = newstr(map->map_tapp);
776 +       
777 +       if(map->map_db2 != NULL) {
778 +               map->map_db2 = newstr(map->map_db2);
779 +               stripquotes(map->map_db2);
780 +               p=map->map_db2;
781 +               while(*p==' ')
782 +                                       p++;
783 +               map->map_db2=p;
784 +       }
785 +
786 +       if (map->map_keycolnm != NULL) { /* database connect string */
787 +               map->map_keycolnm = newstr(map->map_keycolnm);
788 +               stripquotes(map->map_keycolnm);
789 +               p=map->map_keycolnm;
790 +               while(*p==' ')
791 +                                       p++;
792 +               map->map_keycolnm=p;
793 +   } else {
794 +      syserr("No PostgreSQL connect string for %s map %s",
795 +             map->map_class->map_cname, map->map_mname);
796 +      return false;
797 +   }
798 +
799 +       if (map->map_valcolnm != NULL) { /* select statement */
800 +               map->map_valcolnm = newstr(map->map_valcolnm);
801 +               stripquotes(map->map_valcolnm);
802 +               p=map->map_valcolnm;
803 +               while(*p==' ')
804 +                                       p++;
805 +               map->map_valcolnm=p;
806 +   } else {
807 +      syserr("No PostgreSQL select statement for %s map %s",
808 +             map->map_class->map_cname, map->map_mname);
809 +      return false;
810 +   }
811 +
812 +#if (PGSQLDEBUG)
813 +       sm_syslog(LOG_MAIL, NOQID, "psqlinfo(%s, %s, %s)",
814 +               map->map_db2, map->map_keycolnm, map->map_valcolnm);
815 +#endif
816 +       return true;
817 +}
818 +
819 +/*
820 + * Open a PostgreSQL database connection using the connection string.
821 + *
822 + * Returns TRUE if the database was opened or FALSE if it choked. 
823 + *
824 + * - Changed to check return status better on open and save
825 + *   PID to fix Broken pipes from child processes closing the
826 + *   connection on us.
827 + */
828 +bool
829 +pgsql_map_open(map, mode)
830 +       MAP *map;
831 +       int mode;
832 +{
833 +       PGconn *conn;
834 +        char *s;
835 +        int n=0;
836
837 +       conn=(PGconn *) map->map_db1;
838 +
839 +       /*
840 +        * check our list for an already established connection that
841 +        * matches both the host and connection string
842 +        * keycolnm is the connection string
843 +        * file is the hostname
844 +        */
845 +       conn=getconn(map->map_db2, map->map_keycolnm);
846 +
847 +       /*
848 +        * we already have a connection to the server
849 +        */
850 +       if (PQstatus(conn) == CONNECTION_OK) {
851 +#if (PGSQLDEBUG)
852 +               sm_syslog(LOG_MAIL, NOQID, "AlreadyExists (host:%s, cstr:%s, conn:%p)",
853 +                       map->map_db2, map->map_keycolnm, conn);
854 +#endif
855 +               map->map_db1 = (ARBPTR_T) conn;
856 +               return true;
857 +       }
858 +  
859 +       if(map->map_db2)
860 +               n+=strlen(map->map_db2);
861 +       if(map->map_keycolnm)
862 +               n+=strlen(map->map_keycolnm);
863 +       
864 +       s=malloc(n+2);
865 +       sprintf(s, "%s %s",
866 +               map->map_db2? map->map_db2:"",
867 +               map->map_keycolnm? map->map_keycolnm:"");
868 +
869 +       conn=PQconnectdb(s);
870 +       if (!conn || PQstatus(conn) == CONNECTION_BAD) {
871 +               if (conn)
872 +                       PQfinish(conn);
873 +               syserr("Cannot open %s map \'%s\' using \"%s\" (%s)",
874 +                       map->map_class->map_cname,
875 +                       map->map_mname,
876 +                       s,
877 +                       PQerrorMessage(conn));
878 +                       free(s);
879 +               return false;
880 +       }
881 +       free(s);
882 +
883 +       addconn(map->map_db2, map->map_keycolnm, conn);
884 +       map->map_db1 = (ARBPTR_T) conn;
885 +       map->map_pid = getpid(); /* save PID for check on close */
886 +       return true;
887 +}   
888 +
889 +/*
890 + * Close the PostgreSQL database connection, check that the opening process
891 + * is the closing process; ignore if not.
892 + */
893 +void
894 +pgsql_map_close(map)
895 +       MAP *map;
896 +{
897 +       PGconn *conn;
898 +       int r;
899 +       
900 +       if (map->map_pid == getpid()) {
901 +               conn= (PGconn *) map->map_db1;
902 +               r=removeconn(conn);
903 +               if(r)
904 +                       PQfinish(conn);
905 +#if (PGSQLDEBUG)
906 +               sm_syslog(LOG_MAIL, NOQID, "Closed map %s", map->map_mname);
907 +#endif
908 +       }
909 +}
910 +
911 +/*
912 +** PGSQL_MAP_LOOKUP -- look up a datum in a PGSQL map
913 +**
914 +** Attempt to map an incoming key value with a PostgreSQL query.
915 +**
916 +** This performs the query specified in the Sendmail config file and
917 +** uses the value of the first row and column as the map data value.
918 +** All other rows and columns are ignored.
919 +**
920 +** July 8, 2000
921 +** 
922 +** - Modified to check the status of the PostgreSQL connection and reset it
923 +**   if it looks like it has dropped.  This was done to flush out an error,
924 +**   but it's a good idea to do this anyway just in case.
925 +** 
926 +*/
927 +char *
928 +pgsql_map_lookup(map, name, av, statp)
929 +   MAP *map;
930 +   char *name;
931 +   char **av;
932 +   int *statp;
933 +{
934 +   int len,ntuples,r;
935 +   char *sbuf;
936 +   char sname[MAXNAME+1];
937 +   char resbuf[MAXNAME+1];
938 +   PGconn *conn = (PGconn *) map->map_db1;
939 +   PGresult *res;
940 +
941 +   bzero(sname,sizeof sname);
942 +   bzero(resbuf,sizeof resbuf);
943 +
944 +       /* Buffer overflow check. */
945 +   len = strlen(name);
946 +   if (len > MAXNAME)
947 +               len=MAXNAME;
948 +   bcopy(name,sname,len);
949 +   
950 +   if (!bitset(MF_NOFOLDCASE, map->map_mflags))
951 +      makelower(sname);
952 +
953 +       /* Allocate query buffer (select statement + key value) */
954 +   len = strlen(map->map_valcolnm) + strlen(sname);
955 +   sbuf = xalloc(len);
956 +   bzero(sbuf,len);
957 +
958 +/*
959 + * Check the backend to make sure it's still valid.  If it's not, try and
960 + * reset the connection.  This is a good idea anyway, just in case
961 + * the backend died.  BTW this is how I discovered the "child close" bug.
962 + */
963 +       r=PQstatus(conn);
964 +   if (r == CONNECTION_BAD) {
965 +#if (PGSQLDEBUG)
966 +               sm_syslog(LOG_MAIL, NOQID, "CNX Bad, resetting (%i)", r);
967 +#endif
968 +      PQreset(conn); /* does this block?  I hope so */
969 +      if (PQstatus(conn) == CONNECTION_BAD) {
970 +         PQfinish(conn);
971 +         syserr("Unable to reestablish closed PGSQL connection %s",map->map_keycolnm);
972 +         return NULL;
973 +      }
974 +   }         
975 +
976 +       /* Create SQL query statement and execute it */   
977 +   sprintf(sbuf,map->map_valcolnm,sname);
978 +   
979 +   /*syserr("starting map lookup, pid: %i", map->map_pid);*/
980 +   res = PQexec(conn,sbuf);
981 +   if (PQresultStatus(res) != PGRES_TUPLES_OK) {
982 +      PQclear(res);
983 +      syserr("Cannot query PGSQL database %s using %s",map->map_keycolnm,sbuf);
984 +      return NULL;
985 +   }
986 +
987 +/*
988 + * See if anything came back.  If no rows were returned, nothing there for
989 + * this query.
990 + */
991 +   ntuples = PQntuples(res);
992 +   if (ntuples <= 0) {
993 +      PQclear(res);
994 +      return NULL;
995 +   }
996 +
997 +/*
998 + * Get the result from column 0 and clear the rest of the result.
999 + * If the result data is too big, then it's truncated.
1000 + */   
1001 +   len = PQgetlength(res,0,0);
1002 +   if (len > MAXNAME) len=MAXNAME;
1003 +   bcopy(PQgetvalue(res,0,0),resbuf,len);
1004 +   PQclear(res);
1005 +
1006 +/*
1007 + * Process results like the other map classes do.
1008 + */
1009 +  /*syserr("finishing map lookup, pid: %i", map->map_pid);*/
1010 +       if (bitset(MF_MATCHONLY, map->map_mflags))
1011 +               return map_rewrite(map, name, strlen(name), NULL);
1012 +       else
1013 +               return map_rewrite(map, resbuf, len, av);
1014 +}
1015 +#endif /* PGSQLMAP */
1016  /*
1017  **  PH map
1018  */
This page took 0.127492 seconds and 2 git commands to generate.