diff options
author | gshapiro <gshapiro@FreeBSD.org> | 2002-02-17 21:56:45 +0000 |
---|---|---|
committer | gshapiro <gshapiro@FreeBSD.org> | 2002-02-17 21:56:45 +0000 |
commit | 514d1553cc1f49dd008e6e432664359124af60a9 (patch) | |
tree | e71b01386ad11f2e0c99bab2eab606f5c7360807 /contrib/sendmail/contrib | |
parent | c2a47cdbe88de50d484d2cdb605874e1168626dc (diff) | |
parent | 8449595fe97f4474b9b9a7e4edee1ef35dcff393 (diff) | |
download | FreeBSD-src-514d1553cc1f49dd008e6e432664359124af60a9.zip FreeBSD-src-514d1553cc1f49dd008e6e432664359124af60a9.tar.gz |
This commit was generated by cvs2svn to compensate for changes in r90792,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/sendmail/contrib')
-rwxr-xr-x | contrib/sendmail/contrib/buildvirtuser | 2 | ||||
-rw-r--r-- | contrib/sendmail/contrib/dnsblaccess.m4 | 94 | ||||
-rw-r--r-- | contrib/sendmail/contrib/domainmap.m4 | 8 | ||||
-rw-r--r-- | contrib/sendmail/contrib/link_hash.sh | 2 | ||||
-rw-r--r-- | contrib/sendmail/contrib/qtool.8 | 66 | ||||
-rwxr-xr-x | contrib/sendmail/contrib/qtool.pl | 124 |
6 files changed, 240 insertions, 56 deletions
diff --git a/contrib/sendmail/contrib/buildvirtuser b/contrib/sendmail/contrib/buildvirtuser index 3ea2d66..2fe469b 100755 --- a/contrib/sendmail/contrib/buildvirtuser +++ b/contrib/sendmail/contrib/buildvirtuser @@ -27,7 +27,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. -# $Id: buildvirtuser,v 1.1.2.3 2001/02/12 02:57:13 gshapiro Exp $ +# $Id: buildvirtuser,v 1.3 2001/02/12 02:58:20 gshapiro Exp $ =head1 NAME diff --git a/contrib/sendmail/contrib/dnsblaccess.m4 b/contrib/sendmail/contrib/dnsblaccess.m4 new file mode 100644 index 0000000..8eb5ae6 --- /dev/null +++ b/contrib/sendmail/contrib/dnsblaccess.m4 @@ -0,0 +1,94 @@ +divert(-1) +# +# Copyright (c) 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. +# +# + +dnl ## This is a modified enhdnsbl, loosely based on the +dnl ## original. +dnl ## +dnl ## Use it as follows +dnl ## +dnl ## HACK(dnsblaccess, domain, optional-message, tempfail-message, keytag) +dnl ## +dnl ## The first argument (domain) is required. The other arguments +dnl ## are optional and have reasonable defaults. The +dnl ## optional-message is the error message given in case of a +dnl ## match. The default behavior for a tempfail is to accept the +dnl ## email. A tempfail-message value of `t' temporarily rejects +dnl ## with a default message. Otherwise the value should be your +dnl ## own message. The keytag is used to lookup the access map to +dnl ## further refine the result. I recommend a qualified keytag +dnl ## (containing a ".") as less likely to accidently conflict with +dnl ## other access tags. +dnl ## +dnl ## This is best illustrated with an example. Please do not use +dnl ## the example, as it refers to a bogus lookup list. +dnl ## +dnl ## Suppose that you use +dnl ## +dnl ## HACK(dnsblaccess, `rbl.bogus.org',`',`t',bogus.tag) +dnl ## +dnl ## and suppose that your access map contains the entries +dnl ## +dnl ## bogus.tag:127.0.0.2 REJECT +dnl ## bogus.tag:127.0.0.3 error:dialup mail from %1 rejected by %2 +dnl ## bogus.tag:127.0.0.4 OK +dnl ## bogus.tag:127 REJECT +dnl ## bogus.tag: OK +dnl ## +dnl ## If an SMTP connection is received from 123.45.6.7, sendmail +dnl ## will lookup the A record for 7.6.45.123.bogus.org. If there +dnl ## is a temp failure for the lookup, sendmail will generate a +dnl ## temporary failure with a default message. If there is no +dnl ## A-record for this lookup, then the mail is treated as if the +dnl ## HACK line were not present. If the lookup returns 127.0.0.2, +dnl ## then a default message rejects the mail. If it returns +dnl ## 127.0.0.3, then the message +dnl ## "dialup mail from 123.45.6.7 rejected by rbl.bogus.org" +dnl ## is used to reject the mail. If it returns 127.0.0.4, the +dnl ## mail is processed as if there were no HACK line. If the +dnl ## address returned is something else beginning with 127.*, the +dnl ## mail is rejected with a default error message. If the +dnl ## address returned does not begin 127, then the mail is +dnl ## processed as if the HACK line were not present. + +divert(0) +VERSIONID(`$Id: dnsblaccess.m4,v 1.2 2001/07/23 00:24:04 ca Exp $') +ifdef(`_ACCESS_TABLE_', `dnl', + `errprint(`*** ERROR: dnsblaccess requires FEATURE(`access_db') +')') +ifdef(`_EDNSBL_R_',`dnl',`dnl +define(`_EDNSBL_R_', `1')dnl ## prevent multiple redefines of the map. +LOCAL_CONFIG +# map for enhanced DNS based blacklist lookups +Kednsbl dns -R A -a. -T<TMP> -r`'ifdef(`EDNSBL_TO',`EDNSBL_TO',`5') +') +divert(-1) +define(`_EDNSBL_SRV_', `ifelse(len(X`'_ARG_),`1',`blackholes.mail-abuse.org',_ARG_)')dnl +define(`_EDNSBL_MSG_', `ifelse(len(X`'_ARG2_),`1',`"550 Mail from " $`'&{client_addr} " refused by blackhole site '_EDNSBL_SRV_`"',`_ARG2_')')dnl +define(`_EDNSBL_MSG_TMP_', `ifelse(_ARG3_,`t',`"451 Temporary lookup failure of " $`'&{client_addr} " at '_EDNSBL_SRV_`"',`_ARG3_')')dnl +define(`_EDNSBL_KEY_', `ifelse(len(X`'_ARG4_),`1',`dnsblaccess',_ARG4_)')dnl +divert(8) +# DNS based IP address spam list _EDNSBL_SRV_ +R$* $: $&{client_addr} +dnl IPv6? +R$-.$-.$-.$- $: <?> $(ednsbl $4.$3.$2.$1._EDNSBL_SRV_. $: OK $) <>$1.$2.$3.$4 +R<?>OK<>$* $: OKSOFAR +R<?>$+<TMP><>$* $: <? <TMPF>> +R<?>$* $- .<>$* <$(access _EDNSBL_KEY_`:'$1$2 $@$3 $@`'_EDNSBL_SRV_ $: ? $)> $1 <>$3 +R<?>$* <>$* $:<$(access _EDNSBL_KEY_`:' $@$2 $@`'_EDNSBL_SRV_ $: ? $)> <>$2 +ifelse(len(X`'_ARG3_),`1', +`R<$*<TMPF>>$* $: TMPOK', +`R<$*<TMPF>>$* $#error $@ 4.7.1 $: _EDNSBL_MSG_TMP_') +R<$={Accept}>$* $: OKSOFAR +R<ERROR:$-.$-.$-:$+> $* $#error $@ $1.$2.$3 $: $4 +R<ERROR:$+> $* $#error $: $1 +R<DISCARD> $* $#discard $: discard +R<$*> $* $#error $@ 5.7.1 $: _EDNSBL_MSG_ +divert(-1) diff --git a/contrib/sendmail/contrib/domainmap.m4 b/contrib/sendmail/contrib/domainmap.m4 index fbaf62c..540beff 100644 --- a/contrib/sendmail/contrib/domainmap.m4 +++ b/contrib/sendmail/contrib/domainmap.m4 @@ -46,7 +46,7 @@ divert(-1)changequote(<<, >>)<< in the sendmail source tree. For more information, please see the following URL: - http://www-wsg.cso.uiuc.edu/sendmail/patches/domainmap.html + http://www-dev.cso.uiuc.edu/sendmail/domainmap/ Feedback is welcome. @@ -69,14 +69,16 @@ LOCAL_RULESETS SDomainMapLookup R $=L <@ $=w .> $@ $1 <@ $2 .> weed out local users, in case # Cw contains a mapped domain +R $+ <@ $+> $: $1 <@ $2 > <$&{addr_type}> check if sender +R $+ <@ $+> <e s> $#smtp $@ $2 $: $1 @ $2 do not process sender ifdef(`DOMAINMAP_NO_REGEX',`dnl -R $+ <@ $+> $: $1 <@ $2> <$2> find domain +R $+ <@ $+> <$*> $: $1 <@ $2> <$2> find domain R $+ <$+> <$+ . $+> $1 <$2> < $(dequote $3 "_" $4 $) > # change "." to "_" R $+ <$+> <$+ .> $: $1 <$2> < $(dequote "domain_" $3 $) > # prepend "domain_" dnl',`dnl -R $+ <@ $+> $: $1 <@ $2> <$2 :NOTDONE:> find domain +R $+ <@ $+> <$*> $: $1 <@ $2> <$2 :NOTDONE:> find domain R $+ <$+> <$+ . :NOTDONE:> $1 <$2> < $(domainmap_regex $3 $: $3 $) > # change "." and "-" to "_" R $+ <$+> <$+> $: $1 <$2> < $(dequote "domain_" $3 $) > diff --git a/contrib/sendmail/contrib/link_hash.sh b/contrib/sendmail/contrib/link_hash.sh index e07104d..843c920 100644 --- a/contrib/sendmail/contrib/link_hash.sh +++ b/contrib/sendmail/contrib/link_hash.sh @@ -3,7 +3,7 @@ ## Copyright (c) 2000 Sendmail, Inc. and its suppliers. ## All rights reserved. ## -## $Id: link_hash.sh,v 1.1.2.1 2000/04/25 00:10:47 ca Exp $ +## $Id: link_hash.sh,v 1.2 2000/04/25 00:12:28 ca Exp $ ## # # ln a certificate to its hash diff --git a/contrib/sendmail/contrib/qtool.8 b/contrib/sendmail/contrib/qtool.8 index 1106d07..5c40142 100644 --- a/contrib/sendmail/contrib/qtool.8 +++ b/contrib/sendmail/contrib/qtool.8 @@ -1,4 +1,4 @@ -.\" Copyright (c) 1999 Sendmail, Inc. and its suppliers. +.\" Copyright (c) 1999, 2001 Sendmail, Inc. and its suppliers. .\" All rights reserved. .\" .\" By using this file, you agree to the terms and conditions set @@ -6,18 +6,18 @@ .\" the sendmail distribution. .\" .\" -.\" $Id: qtool.8,v 8.9.16.2 2000/12/15 19:50:41 gshapiro Exp $ +.\" $Id: qtool.8,v 8.16 2001/11/21 19:21:20 gshapiro Exp $ .\" -.TH QTOOL 8 "$Date: 2000/12/15 19:50:41 $" +.TH QTOOL 8 "$Date: 2001/11/21 19:21:20 $" .SH NAME qtool \- manipulate sendmail queues .SH SYNOPSIS .B qtool.pl -.RB [options] +.RB [options] target_directory source [source ...] .PP -.B qtool.pl [-d/-b] +.B qtool.pl [-Q][-d|-b] .RB [options] source [source ...] .SH DESCRIPTION @@ -28,8 +28,8 @@ running. .PP With no options, .B qtool -will move any queue files as specified by \fIsource\fP into -\fItarget_directory\fP. \fISource\fP can be either an individual +will move any queue files as specified by \fIsource\fP into +\fItarget_directory\fP. \fISource\fP can be either an individual queue control file, a queue file id, or a queue directory. .PP If the -d option is specified, qtool will delete the messages specified by @@ -38,19 +38,27 @@ source instead of moving them. If the -b option is specified, the selected messages will be bounced by running sendmail with the -OTimeout.queuereturn=now option. .SS Options -.TP +.TP \fB\-b\fP Bounce all of the messages specified by source. The messages will be bounced immediately. No attempt will be made to deliver the messages. .TP +\fB\-C\fP configfile +Specify the sendmail config file. +Defaults to /etc/mail/sendmail.cf. +.TP \fB\-d\fP Delete all of the messages specified by source. -.TP +.TP \fB\-e\fP \fIperl_expression\fP -Evalute \fIperl_expression\fP for each queue file as specified -by \fIsource\fP. If \fIperl_expression\fP evaluates to true, then that +Evalute \fIperl_expression\fP for each queue file as specified +by \fIsource\fP. If \fIperl_expression\fP evaluates to true, then that queue file is moved. See below for more detail on \fIperl_expression\fP. -.TP +.TP +\fB\-Q\fP +Operate on quarantined items +(queue control file begins with hf instead of qf). +.TP \fB\-s\fP \fIseconds\fP Move only the queue files specified by \fIsource\fP that have a modification time older than \fIseconds\fP. @@ -74,9 +82,6 @@ The last time the body was modified since the epoch in seconds. \fBbody_size\fP The size of the body file in bytes. .TP -\fBcharset\fP -Character set (for future use). -.TP \fBcontent-length\fP Content-Length: header value (Solaris sendmail only). .TP @@ -84,7 +89,7 @@ Content-Length: header value (Solaris sendmail only). The controlling user. .TP \fBcontrol_last_mod_time\fP -The last time the body was modified since the epoch in seconds. +The last time the control file was modified since the epoch in seconds. .TP \fBcontrol_size\fP The size of the control file in bytes. @@ -92,15 +97,24 @@ The size of the control file in bytes. \fBcreation_time\fP The time when the control file was created. .TP +\fBcurrent_delay\fP +Current delay for queue delay algorithm if _FFR_QUEUEDELAY is enabled. +.TP \fBdata_file_name\fP The data file name (deprecated). .TP +\fBdeliver_by\fP +Deliver by flag and deadline for DELIVERBY ESMTP extension. +.TP \fBenvid\fP Original envelope id form ESMTP. .TP \fBerror_recipient\fP The error recipient (deprecated). .TP +\fBfinal_recipient\fP +Final recipient (for DSNs). +.TP \fBflags\fP Array of characters that can be the following values: .PD 0 @@ -110,7 +124,7 @@ w warning message has been sent .TP 8 r -This is an error respone or DSN +This is an error response or DSN .TP 8 8 has 8 bit data in body @@ -153,6 +167,13 @@ Original recipient (ORCPT= parameter). \fBpriority\fP Adjusted priority of message. .TP +\fBquarantine_reason\fP +Quarantine reason for quarantined (held) envelopes if _FFR_QUARANTINE is +enabled. +.TP +\fBqueue_delay\fP +Queue delay algorithm if _FFR_QUEUEDELAY is enabled. +.TP \fBrecipient\fP Array of character flags followed by colon and recipient name. Flags: .PD 0 @@ -191,16 +212,19 @@ Moves the message with id d6CLQh100847 in queue q1 to queue q2. \fBqtool.pl q2 q1/qfd6CLQh100847\fP Moves the message with id d6CLQh100847 in queue q1 to queue q2. .TP -\fBqtool.pl q2 q1/dfd6CLQh100847\fP -Moves the message with id d6CLQh100847 in queue q1 to queue q2. -.TP \fBqtool.pl -e '$msg{num_delivery_attempts} == 3' /q2 /q1\fP Moves all of the queue files that have had three attempted deliveries from queue q1 to queue q2. +.SH BUGS +In sendmail 8.12, it is possible for a message's queue and data files (df) +to be stored in different queues. +In this situation, you must give qtool the pathname of the queue file, +not of the data file (df). +To be safe, never feed qtool the pathname of a data file (df). .SH SEE ALSO sendmail(8) .SH HISTORY The .B qtool -command appeared in +command appeared in sendmail 8.10. diff --git a/contrib/sendmail/contrib/qtool.pl b/contrib/sendmail/contrib/qtool.pl index f4d36f3..d93f743a 100755 --- a/contrib/sendmail/contrib/qtool.pl +++ b/contrib/sendmail/contrib/qtool.pl @@ -1,9 +1,9 @@ #!/usr/bin/env perl ## -## Copyright (c) 1998-2000 Sendmail, Inc. and its suppliers. -## All rights reserved. +## Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers. +## All rights reserved. ## -## $Id: qtool.pl,v 8.15.16.4 2000/11/30 07:14:01 gshapiro Exp $ +## $Id: qtool.pl,v 8.26 2001/11/21 19:26:17 gshapiro Exp $ ## use strict; use File::Basename; @@ -43,7 +43,7 @@ use Getopt::Std; ## queue message. This lets you check for any value in the message ## headers or the control file. Here's an example: ## -## ./qtool.pl -e '$msg->{num_delivery_attempts} >= 2' /q1 /q2 +## ./qtool.pl -e '$msg{num_delivery_attempts} >= 2' /q1 /q2 ## ## This would move any queue files whose number of delivery attempts ## is greater than or equal to 2 from the queue 'q2' to the queue 'q1'. @@ -61,9 +61,10 @@ my $source; my $result; my $action; my $new_condition; +my $qprefix; my $conditions = new Compound(); -Getopt::Std::getopts('bde:s:', \%opts); +Getopt::Std::getopts('bC:de:Qs:', \%opts); sub move_action { @@ -113,6 +114,15 @@ if (defined $opts{e}) $conditions->add($new_condition); } +if (defined $opts{Q}) +{ + $qprefix = "hf"; +} +else +{ + $qprefix = "qf"; +} + if ($action == \&move_action) { $dst_name = shift(@ARGV); @@ -126,6 +136,37 @@ if ($action == \&move_action) $destination = new Queue($dst_name); } +# determine queue_root by reading config file +my $queue_root; +{ + my $config_file = "/etc/mail/sendmail.cf"; + if (defined $opts{C}) + { + $config_file = $opts{C}; + } + + my $line; + open(CONFIG_FILE, $config_file) or die "$config_file: $!"; + while ($line = <CONFIG_FILE>) + { + chomp $line; + if ($line =~ m/^O QueueDirectory=(.*)/) + { + $queue_root = $1; + if ($queue_root =~ m/(.*)\/[^\/]+\*$/) + { + $queue_root = $1; + } + last; + } + } + close(CONFIG_FILE); + if (!defined $queue_root) + { + die "QueueDirectory option not defined in $config_file"; + } +} + while (@ARGV) { $source_name = shift(@ARGV); @@ -157,13 +198,18 @@ while (($source_name, $source) = each(%sources)) sub usage { - print("Usage: $0 [options] directory source ...\n"); - print(" $0 [-d|-b] source ...\n"); - print("options:\n"); - print(" -b Bounce the messages specified by source.\n"); - print(" -d Delete the messages specified by source.\n"); - print(" -e [perl expression] Move only messages for which perl expression returns true.\n"); - print(" -s [seconds] Move only messages whose qf file is older than seconds.\n"); + print("Usage:\t$0 [options] directory source ...\n"); + print("\t$0 [-Q][-d|-b] source ...\n"); + print("Options:\n"); + print("\t-b\t\tBounce the messages specified by source.\n"); + print("\t-C configfile\tSpecify sendmail config file.\n"); + print("\t-d\t\tDelete the messages specified by source.\n"); + print("\t-e [perl expression]\n"); + print("\t\t\tMove only messages for which perl expression\n"); + print("\t\t\treturns true.\n"); + print("\t-Q\t\tOperate on quarantined files.\n"); + print("\t-s [seconds]\tMove only messages whose queue file is older\n"); + print("\t\t\tthan seconds.\n"); } ## @@ -204,10 +250,10 @@ sub add_source $data_dir_name = $source_dir_name; $source_prefix = substr($source_base_name, 0, 2); - if (!-d $source_name && $source_prefix ne 'qf' && + if (!-d $source_name && $source_prefix ne $qprefix && $source_prefix ne 'df') { - $source_base_name = "qf$source_base_name"; + $source_base_name = "$qprefix$source_base_name"; $source_name = File::Spec->catfile("$source_dir_name", "$source_base_name"); } @@ -216,12 +262,16 @@ sub add_source if (!-e $source_name) { $source_name = File::Spec->catfile("$source_dir_name", "qf", - "qf$source_id"); + "$qprefix$source_id"); if (!-e $source_name) { return "'$source_name' does not exist"; } $data_dir_name = File::Spec->catfile("$source_dir_name", "df"); + if (!-d $data_dir_name) + { + $data_dir_name = $source_dir_name; + } $source_dir_name = File::Spec->catfile("$source_dir_name", "qf"); } @@ -377,7 +427,7 @@ sub initialize my $queue_dir = shift; $self->{id} = shift; - $self->{file_name} = $queue_dir . '/qf' . $self->{id}; + $self->{file_name} = $queue_dir . '/' . $qprefix . $self->{id}; $self->{headers} = {}; } @@ -402,9 +452,11 @@ sub parse 'B' => 'body_type', 'C' => 'controlling_user', 'D' => 'data_file_name', + 'd' => 'data_file_directory', 'E' => 'error_recipient', 'F' => 'flags', 'H' => 'parse_header', + 'G' => 'queue_delay', 'I' => 'inode_number', 'K' => 'next_delivery_time', 'L' => 'content-length', @@ -413,11 +465,14 @@ sub parse 'P' => 'priority', 'Q' => 'original_recipient', 'R' => 'recipient', + 'q' => 'quarantine_reason', + 'r' => 'final_recipient', 'S' => 'sender', 'T' => 'creation_time', 'V' => 'version', - 'X' => 'charset', + 'Y' => 'current_delay', 'Z' => 'envid', + '!' => 'deliver_by', '$' => 'macro' ); my $line; @@ -488,7 +543,7 @@ sub parse_header if (ref($headers->{$last_header}) eq 'ARRAY') { $headers->{$last_header}[-1] = - $headers->{$last_header}[-1] . $line; + $headers->{$last_header}[-1] . $line; } else { @@ -621,10 +676,21 @@ sub new sub initialize { my $self = shift; - my $queue_dir = shift; + my $data_dir = shift; $self->{id} = shift; - - $self->{file_name} = $queue_dir . '/df' . $self->{id}; + my $control_file = shift; + + $self->{file_name} = $data_dir . '/df' . $self->{id}; + return if -e $self->{file_name}; + $control_file->parse(); + return if !defined $control_file->{data_file_directory}; + $data_dir = $queue_root . '/' . $control_file->{data_file_directory}; + chomp $data_dir; + if (-d ($data_dir . '/df')) + { + $data_dir .= '/df'; + } + $self->{file_name} = $data_dir . '/df' . $self->{id}; } sub do_stat @@ -694,14 +760,11 @@ sub initialize $self->{id} = $id; $self->{control_file} = new ControlFile($queue_dir, $id); - if ($data_dir) - { - $self->{data_file} = new DataFile($data_dir, $id); - } - else + if (!$data_dir) { - $self->{data_file} = new DataFile($queue_dir, $id); + $data_dir = $queue_dir; } + $self->{data_file} = new DataFile($data_dir, $id, $self->{control_file}); } sub last_modified_time @@ -780,7 +843,7 @@ sub move $df_dest = $destination; } - if (-e File::Spec->catfile($qf_dest, "qf$self->{id}")) + if (-e File::Spec->catfile($qf_dest, "$qprefix$self->{id}")) { $result = "There is already a queued message with id '$self->{id}' in '$destination'"; } @@ -884,7 +947,8 @@ sub initialize ## READ - Loads the queue with all of the objects that reside in it. ## ## This reads the queue's directory and creates QueuedMessage objects -## for every file in the queue that starts with 'qf'. +## for every file in the queue that starts with 'qf' or 'hf' +## (depending on the -Q option). ## sub read @@ -920,7 +984,7 @@ sub read return "Unable to open directory '$control_dir'"; } - @control_files = grep { /^qf.*/ && -f "$control_dir/$_" } readdir(QUEUE_DIR); + @control_files = grep { /^$qprefix.*/ && -f "$control_dir/$_" } readdir(QUEUE_DIR); closedir(QUEUE_DIR); foreach $file_name (@control_files) { |