X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/9242a7e8cfa94bbc9dd7eca6bd651b569b871c4e..8f2cf8f5adaa08ef84b47bf9bc2f71e39236c22d:/src/src/exipick.src diff --git a/src/src/exipick.src b/src/src/exipick.src index d0122a324..a63133353 100644 --- a/src/src/exipick.src +++ b/src/src/exipick.src @@ -1,5 +1,5 @@ #!PERL_COMMAND -# Copyright (c) 2017 University of Cambridge. +# Copyright (c) 1995 - 2018 University of Cambridge. # See the file NOTICE for conditions of use and distribution. @@ -17,12 +17,15 @@ my $charset = 'ISO-8859-1'; use strict; BEGIN { pop @INC if $INC[-1] eq '.' }; use Getopt::Long; +use File::Basename; +use Pod::Usage; -my($p_name) = $0 =~ m|/?([^/]+)$|; +my $p_name = basename $0; my $p_version = "20100323.0"; -my $p_usage = "Usage: $p_name [--help|--version] (see --help for details)"; +my $p_usage = "Usage: $p_name [--help|--man|--version] (see --help for details)"; my $p_cp = < + Copyright (c) 2019 The Exim Maintainers This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -38,7 +41,6 @@ my $p_cp = < \$G::spool, # exim spool dir 'C|Config=s' => \$G::config, # use alternative Exim configuration file 'input-dir=s' => \$G::input_dir, # name of the "input" dir + 'queue=s' => \$G::queue, # name of the queue 'finput' => \$G::finput, # same as "--input-dir Finput" 'bp' => \$G::mailq_bp, # List the queue (noop - default) 'bpa' => \$G::mailq_bpa, # ... with generated address as well @@ -83,8 +86,16 @@ GetOptions( 'show-vars=s' => \$G::show_vars, # display the contents of these vars 'just-vars' => \$G::just_vars, # only display vars, no other info 'show-rules' => \$G::show_rules, # display compiled match rules - 'show-tests' => \$G::show_tests # display tests as applied to each message -) || exit(1); + 'show-tests' => \$G::show_tests, # display tests as applied to each message + 'man' => sub { pod2usage(-verbose => 2, -exit => 0, -noperldoc => system('perldoc -V >/dev/null 2>&1')) }, + 'help' => sub { pod2usage(-verbose => 1, -exit => 0) }, + 'version' => sub { + print "$p_name: $0\n", + "build: EXIM_RELEASE_VERSIONEXIM_VARIANT_VERSION\n", + "perl(runtime): $]\n"; + exit 0; + }, +) or pod2usage; # if both freeze and thaw specified, only thaw as it is less destructive $G::freeze = undef if ($G::freeze && $G::thaw); @@ -121,7 +132,8 @@ $G::caseless = $G::caseful ? 0 : 1; # nocase by default, case if both $spool = defined $G::spool ? $G::spool : do { chomp($_ = `$exim @{[defined $G::config ? "-C $G::config" : '']} -n -bP spool_directory`) and $_ or $spool }; -my $input_dir = $G::input_dir || ($G::finput ? "Finput" : "input"); +my $input_dir = (defined $G::queue ? "$G::queue/" : '') + . (defined $G::input_dir || ($G::finput ? "Finput" : "input")); my $count_only = 1 if ($G::mailq_bpc || $G::qgrep_c); my $unsorted = 1 if ($G::mailq_bpr || $G::mailq_bpra || $G::mailq_bpru || $G::unsorted); @@ -390,7 +402,7 @@ sub process_criteria { } else { $c[-1]{cmp} .= $G::negate ? " ? 0 : 1" : " ? 1 : 0"; } - # support the each_* psuedo variables. Steal the criteria off of the + # support the each_* pseudo variables. Steal the criteria off of the # queue for special processing later if ($c[-1]{var} =~ /^each_(recipients(_(un)?del)?)$/) { my $var = $1; @@ -891,115 +903,112 @@ sub _parse_header { $self->{_vars}{warning_count} = $2; $self->{_vars}{message_age} = time() - $self->{_vars}{received_time}; - while () { - chomp(); - if (/^(-\S+)\s*(.*$)/) { - my $tag = $1; - my $arg = $2; - if ($tag eq '-acl') { - my $t; - return(0) if ($arg !~ /^(\d+)\s(\d+)$/); - if ($1 < $Exim::SpoolFile::ACL_C_MAX_LEGACY) { - $t = "acl_c$1"; - } else { - $t = "acl_m" . ($1 - $Exim::SpoolFile::ACL_C_MAX_LEGACY); - } - read(I, $self->{_vars}{$t}, $2+1) || return(0); - chomp($self->{_vars}{$t}); - } elsif ($tag eq '-aclc') { - #return(0) if ($arg !~ /^(\d+)\s(\d+)$/); - return(0) if ($arg !~ /^(\S+)\s(\d+)$/); - my $t = "acl_c$1"; - read(I, $self->{_vars}{$t}, $2+1) || return(0); - chomp($self->{_vars}{$t}); - } elsif ($tag eq '-aclm') { - #return(0) if ($arg !~ /^(\d+)\s(\d+)$/); - return(0) if ($arg !~ /^(\S+)\s(\d+)$/); - my $t = "acl_m$1"; - read(I, $self->{_vars}{$t}, $2+1) || return(0); - chomp($self->{_vars}{$t}); - } elsif ($tag eq '-local') { - $self->{_vars}{sender_local} = 1; - } elsif ($tag eq '-localerror') { - $self->{_vars}{local_error_message} = 1; - } elsif ($tag eq '-local_scan') { - $self->{_vars}{local_scan_data} = $arg; - } elsif ($tag eq '-spam_score_int') { - $self->{_vars}{spam_score_int} = $arg; - $self->{_vars}{spam_score} = $arg / 10; - } elsif ($tag eq '-bmi_verdicts') { - $self->{_vars}{bmi_verdicts} = $arg; - } elsif ($tag eq '-host_lookup_deferred') { - $self->{_vars}{host_lookup_deferred} = 1; - } elsif ($tag eq '-host_lookup_failed') { - $self->{_vars}{host_lookup_failed} = 1; - } elsif ($tag eq '-body_linecount') { - $self->{_vars}{body_linecount} = $arg; - } elsif ($tag eq '-max_received_linelength') { - $self->{_vars}{max_received_linelength} = $arg; - } elsif ($tag eq '-body_zerocount') { - $self->{_vars}{body_zerocount} = $arg; - } elsif ($tag eq '-frozen') { - $self->{_vars}{deliver_freeze} = 1; - $self->{_vars}{deliver_frozen_at} = $arg; - } elsif ($tag eq '-allow_unqualified_recipient') { - $self->{_vars}{allow_unqualified_recipient} = 1; - } elsif ($tag eq '-allow_unqualified_sender') { - $self->{_vars}{allow_unqualified_sender} = 1; - } elsif ($tag eq '-deliver_firsttime') { - $self->{_vars}{deliver_firsttime} = 1; - $self->{_vars}{first_delivery} = 1; - } elsif ($tag eq '-manual_thaw') { - $self->{_vars}{deliver_manual_thaw} = 1; - $self->{_vars}{manually_thawed} = 1; - } elsif ($tag eq '-auth_id') { - $self->{_vars}{authenticated_id} = $arg; - } elsif ($tag eq '-auth_sender') { - $self->{_vars}{authenticated_sender} = $arg; - } elsif ($tag eq '-sender_set_untrusted') { - $self->{_vars}{sender_set_untrusted} = 1; - } elsif ($tag eq '-tls_certificate_verified') { - $self->{_vars}{tls_certificate_verified} = 1; - } elsif ($tag eq '-tls_cipher') { - $self->{_vars}{tls_cipher} = $arg; - } elsif ($tag eq '-tls_peerdn') { - $self->{_vars}{tls_peerdn} = $arg; - } elsif ($tag eq '-tls_sni') { - $self->{_vars}{tls_sni} = $arg; - } elsif ($tag eq '-host_address') { - $self->{_vars}{sender_host_port} = $self->_get_host_and_port(\$arg); - $self->{_vars}{sender_host_address} = $arg; - } elsif ($tag eq '-interface_address') { - $self->{_vars}{received_port} = - $self->{_vars}{interface_port} = $self->_get_host_and_port(\$arg); - $self->{_vars}{received_ip_address} = - $self->{_vars}{interface_address} = $arg; - } elsif ($tag eq '-active_hostname') { - $self->{_vars}{smtp_active_hostname} = $arg; - } elsif ($tag eq '-host_auth') { - $self->{_vars}{sender_host_authenticated} = $arg; - } elsif ($tag eq '-host_name') { - $self->{_vars}{sender_host_name} = $arg; - } elsif ($tag eq '-helo_name') { - $self->{_vars}{sender_helo_name} = $arg; - } elsif ($tag eq '-ident') { - $self->{_vars}{sender_ident} = $arg; - } elsif ($tag eq '-received_protocol') { - $self->{_vars}{received_protocol} = $arg; - } elsif ($tag eq '-N') { - $self->{_vars}{dont_deliver} = 1; + TAGGED: while () { + my ($tag, $arg) = /^-?(-\S+)(?:\s+(.*))?$/ or last TAGGED; + chomp; + + if ($tag eq '-acl') { + my $t; + return(0) if ($arg !~ /^(\d+)\s(\d+)$/); + if ($1 < $Exim::SpoolFile::ACL_C_MAX_LEGACY) { + $t = "acl_c$1"; } else { - # unrecognized tag, save it for reference - $self->{$tag} = $arg; + $t = "acl_m" . ($1 - $Exim::SpoolFile::ACL_C_MAX_LEGACY); } + read(I, $self->{_vars}{$t}, $2+1) || return(0); + chomp($self->{_vars}{$t}); + } elsif ($tag eq '-aclc') { + #return(0) if ($arg !~ /^(\d+)\s(\d+)$/); + return(0) if ($arg !~ /^(\S+)\s(\d+)$/); + my $t = "acl_c$1"; + read(I, $self->{_vars}{$t}, $2+1) || return(0); + chomp($self->{_vars}{$t}); + } elsif ($tag eq '-aclm') { + #return(0) if ($arg !~ /^(\d+)\s(\d+)$/); + return(0) if ($arg !~ /^(\S+)\s(\d+)$/); + my $t = "acl_m$1"; + read(I, $self->{_vars}{$t}, $2+1) || return(0); + chomp($self->{_vars}{$t}); + } elsif ($tag eq '-local') { + $self->{_vars}{sender_local} = 1; + } elsif ($tag eq '-localerror') { + $self->{_vars}{local_error_message} = 1; + } elsif ($tag eq '-local_scan') { + $self->{_vars}{local_scan_data} = $arg; + } elsif ($tag eq '-spam_score_int') { + $self->{_vars}{spam_score_int} = $arg; + $self->{_vars}{spam_score} = $arg / 10; + } elsif ($tag eq '-bmi_verdicts') { + $self->{_vars}{bmi_verdicts} = $arg; + } elsif ($tag eq '-host_lookup_deferred') { + $self->{_vars}{host_lookup_deferred} = 1; + } elsif ($tag eq '-host_lookup_failed') { + $self->{_vars}{host_lookup_failed} = 1; + } elsif ($tag eq '-body_linecount') { + $self->{_vars}{body_linecount} = $arg; + } elsif ($tag eq '-max_received_linelength') { + $self->{_vars}{max_received_linelength} = $arg; + } elsif ($tag eq '-body_zerocount') { + $self->{_vars}{body_zerocount} = $arg; + } elsif ($tag eq '-frozen') { + $self->{_vars}{deliver_freeze} = 1; + $self->{_vars}{deliver_frozen_at} = $arg; + } elsif ($tag eq '-allow_unqualified_recipient') { + $self->{_vars}{allow_unqualified_recipient} = 1; + } elsif ($tag eq '-allow_unqualified_sender') { + $self->{_vars}{allow_unqualified_sender} = 1; + } elsif ($tag eq '-deliver_firsttime') { + $self->{_vars}{deliver_firsttime} = 1; + $self->{_vars}{first_delivery} = 1; + } elsif ($tag eq '-manual_thaw') { + $self->{_vars}{deliver_manual_thaw} = 1; + $self->{_vars}{manually_thawed} = 1; + } elsif ($tag eq '-auth_id') { + $self->{_vars}{authenticated_id} = $arg; + } elsif ($tag eq '-auth_sender') { + $self->{_vars}{authenticated_sender} = $arg; + } elsif ($tag eq '-sender_set_untrusted') { + $self->{_vars}{sender_set_untrusted} = 1; + } elsif ($tag eq '-tls_certificate_verified') { + $self->{_vars}{tls_certificate_verified} = 1; + } elsif ($tag eq '-tls_cipher') { + $self->{_vars}{tls_cipher} = $arg; + } elsif ($tag eq '-tls_peerdn') { + $self->{_vars}{tls_peerdn} = $arg; + } elsif ($tag eq '-tls_sni') { + $self->{_vars}{tls_sni} = $arg; + } elsif ($tag eq '-host_address') { + $self->{_vars}{sender_host_port} = $self->_get_host_and_port(\$arg); + $self->{_vars}{sender_host_address} = $arg; + } elsif ($tag eq '-interface_address') { + $self->{_vars}{received_port} = + $self->{_vars}{interface_port} = $self->_get_host_and_port(\$arg); + $self->{_vars}{received_ip_address} = + $self->{_vars}{interface_address} = $arg; + } elsif ($tag eq '-active_hostname') { + $self->{_vars}{smtp_active_hostname} = $arg; + } elsif ($tag eq '-host_auth') { + $self->{_vars}{sender_host_authenticated} = $arg; + } elsif ($tag eq '-host_name') { + $self->{_vars}{sender_host_name} = $arg; + } elsif ($tag eq '-helo_name') { + $self->{_vars}{sender_helo_name} = $arg; + } elsif ($tag eq '-ident') { + $self->{_vars}{sender_ident} = $arg; + } elsif ($tag eq '-received_protocol') { + $self->{_vars}{received_protocol} = $arg; + } elsif ($tag eq '-N') { + $self->{_vars}{dont_deliver} = 1; } else { - last; + # unrecognized tag, save it for reference + $self->{$tag} = $arg; } } # when we drop out of the while loop, we have the first line of the # delivered tree in $_ do { + chomp; if ($_ eq 'XX') { ; # noop } elsif ($_ =~ s/^[YN][YN]\s+//) { @@ -1007,7 +1016,7 @@ sub _parse_header { } else { return(0); } - chomp($_ = ); + $_ = ; } while ($_ !~ /^\d+$/); $self->{_numrecips} = $_; @@ -1257,64 +1266,53 @@ sub dump { } # BEGIN -sub ext_usage { - if ($ARGV[0] =~ /^--help$/i) { - require Config; - $ENV{PATH} .= ":" unless $ENV{PATH} eq ""; - $ENV{PATH} = "$ENV{PATH}$Config::Config{'installscript'}"; - #exec("perldoc", "-F", "-U", $0) || exit 1; - $< = $> = 1 if ($> == 0 || $< == 0); - exec("perldoc", $0) || exit 1; - # make parser happy - %Config::Config = (); - } elsif ($ARGV[0] =~ /^--version$/i) { - print "$p_name version $p_version\n\n$p_cp\n"; - } else { - return; - } - - exit(0); -} - __END__ =head1 NAME -exipick - selectively display messages from an Exim queue + exipick - selectively display messages from an Exim queue =head1 SYNOPSIS -exipick [] [ [ ...]] + exipick [] [ [ ...]] + exipick --help|--man =head1 DESCRIPTION -exipick is a tool to display messages in an Exim queue. It is very similar to exiqgrep and is, in fact, a drop in replacement for exiqgrep. exipick allows you to select messages to be displayed using any piece of data stored in an Exim spool file. Matching messages can be displayed in a variety of formats. +B is a tool to display messages in an Exim queue. It is very similar to exiqgrep and is, in fact, a drop in replacement for exiqgrep. B allows you to select messages to be displayed using any piece of data stored in an Exim spool file. Matching messages can be displayed in a variety of formats. =head1 QUICK START Delete every frozen message from queue: + exipick -zi | xargs exim -Mrm Show only messages which have not yet been virus scanned: + exipick '$received_protocol ne virus-scanned' Run the queue in a semi-random order: + exipick -i --random | xargs exim -M Show the count and total size of all messages which either originated from localhost or have a received protocol of 'local': + exipick --or --size --bpc \ '$sender_host_address eq 127.0.0.1' \ '$received_protocol eq local' Display all messages received on the MSA port, ordered first by the sender's email domain and then by the size of the emails: + exipick --sort sender_address_domain,message_size \ '$received_port == 587' Display only messages whose every recipient is in the example.com domain, also listing the IP address of the sending host: + exipick --show-vars sender_host_address \ '$each_recipients = example.com' Same as above, but show values for all defined variables starting with sender_ and the number of recipients: + exipick --show-vars ^sender_,recipients_count \ '$each_recipients = example.com' @@ -1322,178 +1320,176 @@ Same as above, but show values for all defined variables starting with sender_ a =over 4 -=item --and +=item B<--and> Display messages matching all criteria (default) -=item -b +=item B<-b> Display messages in brief format (exiqgrep) -=item -bp +=item B<-bp> | B<-l> -Display messages in standard mailq format (default) +Display messages in standard mailq format (default). +(exiqgrep: C<-l>) -=item -bpa +=item B<-bpa> -Same as -bp, show generated addresses also (exim) +Same as C<-bp>, show generated addresses also (exim) -=item -bpc +=item B<-bpc> Show a count of matching messages (exim) -=item -bpr +=item B<-bpr> -Same as '-bp --unsorted' (exim) +Same as C<-bp --unsorted> (exim) -=item -bpra +=item B<-bpra> -Same as '-bpa --unsorted' (exim) +Same as C<-bpa --unsorted> (exim) -=item -bpru +=item B<-bpru> -Same as '-bpu --unsorted' (exim) +Same as C<-bpu --unsorted> (exim) -=item -bpu +=item B<-bpu> -Same as -bp, but only show undelivered messages (exim) +Same as C<-bp>, but only show undelivered messages (exim) -=item -C | --config +=item B<-C> | B<--config> I -Use to determine the proper spool directory. (See C<--spool> +Use I to determine the proper spool directory. (See C<--spool> or C<--input> for alternative ways to specify the directories to operate on.) -=item -c +=item B<-c> Show a count of matching messages (exiqgrep) -=item --caseful +=item B<--caseful> -Make operators involving '=' honor case +Make operators involving C<=> honor case -=item --charset +=item B<--charset> -Override the default local character set for $header_ decoding +Override the default local character set for C<$header_> decoding -=item -f +=item B<-f> I -Same as '$sender_address =~ //' (exiqgrep). Note that this preserves the default case sensitivity of exiqgrep's interface. +Same as C<< $sender_address =~ // >> (exiqgrep). Note that this preserves the default case sensitivity of exiqgrep's interface. -=item --finput +=item B<--finput> -Same as '--input-dir Finput'. 'Finput' is where exim copies frozen messages when compiled with SUPPORT_MOVE_FROZEN_MESSAGES. +Same as C<--input-dir Finput>. F is where exim copies frozen messages when compiled with SUPPORT_MOVE_FROZEN_MESSAGES. -=item --flatq +=item B<--flatq> Use a single-line output format -=item --freeze +=item B<--freeze> I Save queue information in an quickly retrievable format -=item --help +=item B<--help> Display this output -=item -i +=item B<-i> Display only the message IDs (exiqgrep) -=item --input-dir - -Set the name of the directory under the spool directory. By default this is "input". If this starts with '/', the value of --spool is ignored. See also --finput. - -=item -l +=item B<--input-dir> I -Same as -bp (exiqgrep) +Set the name of the directory under the spool directory. By default this is F. If this starts with F, +the value of C<--spool> is ignored. See also C<--finput>. -=item --not +=item B<--not> Negate all tests. -=item -o +=item B<-o> I -Same as '$message_age > ' (exiqgrep) +Same as C<< $message_age > >> (exiqgrep) -=item --or +=item B<--or> Display messages matching any criteria -=item -R +=item B<--queue> I -Same as --reverse (exiqgrep) +Name of the queue (default: ''). See "named queues" in the spec. -=item -r +=item B<-r> I -Same as '$recipients =~ //' (exiqgrep). Note that this preserves the default case sensitivity of exiqgrep's interface. +Same as C<< $recipients =~ // >> (exiqgrep). Note that this preserves the default case sensitivity of exiqgrep's interface. -=item --random +=item B<--random> Display messages in random order -=item --reverse +=item B<--reverse> | B<-R> -Display messages in reverse order +Display messages in reverse order (exiqgrep: C<-R>) -=item -s +=item B<-s> I -Same as '$shown_message_size eq ' (exiqgrep) +Same as C<< $shown_message_size eq >> (exiqgrep) -=item --spool +=item B<--spool> I -Set the path to the exim spool to use. This value will have the argument to --input or 'input' appended, or be ignored if --input is a full path. If not specified, exipick uses the value from C, and if this call fails, the F from build time (F) is used. See also --config. +Set the path to the exim spool to use. This value will have the arguments to C<--queue>, and C<--input> or F appended, or be ignored if C<--input> is a full path. If not specified, B uses the value from C, and if this call fails, the F from build time (F) is used. See also C<--config>. -=item --show-rules +=item B<--show-rules> Show the internal representation of each criterion specified -=item --show-tests +=item B<--show-tests> Show the result of each criterion on each message -=item --show-vars [,...] +=item B<--show-vars> I[,I...] -Show the value for for each displayed message. will be a regular expression if it begins with a circumflex. +Show the value for I for each displayed message. I will be a regular expression if it begins with a circumflex. -=item --size +=item B<--size> Show the total bytes used by each displayed message -=item --thaw +=item B<--thaw> I -Read queue information cached from a previous --freeze run +Read queue information cached from a previous C<--freeze> run -=item --sort [,...] +=item B<--sort> I[,I...] -Display matching messages sorted according to +Display matching messages sorted according to I -=item --unsorted +=item B<--unsorted> Do not apply any sorting to output -=item --version +=item B<--version> Display the version of this command -=item -x +=item B<-x> -Same as '!$deliver_freeze' (exiqgrep) +Same as C (exiqgrep) -=item -y +=item B<-y> -Same as '$message_age < ' (exiqgrep) +Same as C<< $message_age < >> (exiqgrep) -=item -z +=item B<-z> -Same as '$deliver_freeze' (exiqgrep) +Same as C<$deliver_freeze> (exiqgrep) =back =head1 CRITERIA -Exipick decides which messages to display by applying a test against each message. The rules take the general form of 'VARIABLE OPERATOR VALUE'. For example, '$message_age > 60'. When exipick is deciding which messages to display, it checks the $message_age variable for each message. If a message's age is greater than 60, the message will be displayed. If the message's age is 60 or less seconds, it will not be displayed. +B decides which messages to display by applying a test against each message. The rules take the general form of "I I I". For example, C<< $message_age > 60 >>. When B is deciding which messages to display, it checks the C<$message_age> variable for each message. If a message's age is greater than 60, the message will be displayed. If the message's age is 60 or less seconds, it will not be displayed. -Multiple criteria can be used. The order they are specified does not matter. By default all criteria must evaluate to true for a message to be displayed. If the --or option is used, a message is displayed as long as any of the criteria evaluate to true. +Multiple criteria can be used. The order they are specified does not matter. By default all criteria must evaluate to true for a message to be displayed. If the C<--or> option is used, a message is displayed as long as any of the criteria evaluate to true. See the VARIABLES and OPERATORS sections below for more details @@ -1504,26 +1500,29 @@ See the VARIABLES and OPERATORS sections below for more details =item BOOLEAN Boolean variables are checked simply by being true or false. There is no real operator except negation. Examples of valid boolean tests: - '$deliver_freeze' - '!$deliver_freeze' + + $deliver_freeze + !$deliver_freeze =item NUMERIC Valid comparisons are <, <=, >, >=, ==, and !=. Numbers can be integers or floats. Any number in a test suffixed with d, h, m, s, M, K, or B will be multiplied by 86400, 3600, 60, 1, 1048576, 1024, or 1 respectively. Examples of valid numeric tests: - '$message_age >= 3d' - '$local_interface == 587' - '$message_size < 30K' + + $message_age >= 3d + $local_interface == 587 + $message_size < 30K =item STRING -The string operators are =, eq, ne, =~, and !~. With the exception of '=', the operators all match the functionality of the like-named perl operators. eq and ne match a string exactly. !~, =~, and = apply a perl regular expression to a string. The '=' operator behaves just like =~ but you are not required to place // around the regular expression. Examples of valid string tests: - '$received_protocol eq esmtp' - '$sender_address = example.com' - '$each_recipients =~ /^a[a-z]{2,3}@example.com$/' +The string operators are =, eq, ne, =~, and !~. With the exception of C<< = >>, the operators all match the functionality of the like-named perl operators. eq and ne match a string exactly. !~, =~, and = apply a perl regular expression to a string. The C<< = >> operator behaves just like =~ but you are not required to place // around the regular expression. Examples of valid string tests: + + $received_protocol eq esmtp + $sender_address = example.com + $each_recipients =~ /^a[a-z]{2,3}@example.com$/ =item NEGATION -There are many ways to negate tests, each having a reason for existing. Many tests can be negated using native operators. For instance, >1 is the opposite of <=1 and eq and ne are opposites. In addition, each individual test can be negated by adding a ! at the beginning of the test. For instance, '!$acl_m1 =~ /^DENY$/' is the same as '$acl_m1 !~ /^DENY$/'. Finally, every test can be specified by using the command line argument --not. This is functionally equivalent to adding a ! to the beginning of every test. +There are many ways to negate tests, each having a reason for existing. Many tests can be negated using native operators. For instance, >1 is the opposite of <=1 and eq and ne are opposites. In addition, each individual test can be negated by adding a ! at the beginning of the test. For instance, C<< !$acl_m1 =~ /^DENY$/ >> is the same as C<< $acl_m1 !~ /^DENY$/ >>. Finally, every test can be specified by using the command line argument C<--not>. This is functionally equivalent to adding a ! to the beginning of every test. =back @@ -1531,7 +1530,7 @@ There are many ways to negate tests, each having a reason for existing. Many te With a few exceptions the available variables match Exim's internal expansion variables in both name and exact contents. There are a few notable additions and format deviations which are noted below. Although a brief explanation is offered below, Exim's spec.txt should be consulted for full details. It is important to remember that not every variable will be defined for every message. For example, $sender_host_port is not defined for messages not received from a remote host. -Internally, all variables are represented as strings, meaning any operator will work on any variable. This means that '$sender_host_name > 4' is a legal criterion, even if it does not produce meaningful results. Variables in the list below are marked with a 'type' to help in choosing which types of operators make sense to use. +Internally, all variables are represented as strings, meaning any operator will work on any variable. This means that C<< $sender_host_name > 4 >> is a legal criterion, even if it does not produce meaningful results. Variables in the list below are marked with a 'type' to help in choosing which types of operators make sense to use. Identifiers B - Boolean variables @@ -1543,283 +1542,283 @@ Internally, all variables are represented as strings, meaning any operator will =over 4 -=item S . $acl_c0-$acl_c9, $acl_m0-$acl_m9 +=item S . B<$acl_c0>-B<$acl_c9>, B<$acl_m0>-B<$acl_m9> User definable variables. -=item B + $allow_unqualified_recipient +=item B + B<$allow_unqualified_recipient> TRUE if unqualified recipient addresses are permitted in header lines. -=item B + $allow_unqualified_sender +=item B + B<$allow_unqualified_sender> TRUE if unqualified sender addresses are permitted in header lines. -=item S . $authenticated_id +=item S . B<$authenticated_id> Optional saved information from authenticators, or the login name of the calling process for locally submitted messages. -=item S . $authenticated_sender +=item S . B<$authenticated_sender> The value of AUTH= param for smtp messages, or a generated value from the calling processes login and qualify domain for locally submitted messages. -=item S . $bheader_*, $bh_* +=item S . B<$bheader_*>, B<$bh_*> Value of the header(s) with the same name with any RFC2047 words decoded if present. See section 11.5 of Exim's spec.txt for full details. -=item S + $bmi_verdicts +=item S + B<$bmi_verdicts> The verdict string provided by a Brightmail content scan -=item N . $body_linecount +=item N . B<$body_linecount> The number of lines in the message's body. -=item N . $body_zerocount +=item N . B<$body_zerocount> The number of binary zero bytes in the message's body. -=item S + $data_path +=item S + B<$data_path> The path to the body file's location in the filesystem. -=item B + $deliver_freeze +=item B + B<$deliver_freeze> TRUE if the message is currently frozen. -=item N + $deliver_frozen_at +=item N + B<$deliver_frozen_at> The epoch time at which message was frozen. -=item B + $dont_deliver +=item B + B<$dont_deliver> TRUE if, under normal circumstances, Exim will not try to deliver the message. -=item S + $each_recipients +=item S + B<$each_recipients> -This is a psuedo variable which allows you to apply a test against each address in $recipients individually. Whereas '$recipients =~ /@aol.com/' will match if any recipient address contains aol.com, '$each_recipients =~ /@aol.com$/' will only be true if every recipient matches that pattern. Note that this obeys --and or --or being set. Using it with --or is very similar to just matching against $recipients, but with the added benefit of being able to use anchors at the beginning and end of each recipient address. +This is a pseudo variable which allows you to apply a test against each address in $recipients individually. Whereas C<< $recipients =~ /@aol.com/ >> will match if any recipient address contains aol.com, C<< $each_recipients =~ /@aol.com$/ >> will only be true if every recipient matches that pattern. Note that this obeys C<--and> or C<--or> being set. Using it with C<--or> is very similar to just matching against $recipients, but with the added benefit of being able to use anchors at the beginning and end of each recipient address. -=item S + $each_recipients_del +=item S + B<$each_recipients_del> Like $each_recipients, but for $recipients_del -=item S + $each_recipients_undel +=item S + B<$each_recipients_undel> Like $each_recipients, but for $recipients_undel -=item B . $first_delivery +=item B . B<$first_delivery> TRUE if the message has never been deferred. -=item S . $header_*, $h_* +=item S . B<$header_*>, B<$h_*> This will always match the contents of the corresponding $bheader_* variable currently (the same behaviour Exim displays when iconv is not installed). -=item S + $header_path +=item S + B<$header_path> The path to the header file's location in the filesystem. -=item B . $host_lookup_deferred +=item B . B<$host_lookup_deferred> TRUE if there was an attempt to look up the host's name from its IP address, but an error occurred that during the attempt. -=item B . $host_lookup_failed +=item B . B<$host_lookup_failed> TRUE if there was an attempt to look up the host's name from its IP address, but the attempt returned a negative result. -=item B + $local_error_message +=item B + B<$local_error_message> TRUE if the message is a locally-generated error message. -=item S . $local_scan_data +=item S . B<$local_scan_data> The text returned by the local_scan() function when a message is received. -=item B . $manually_thawed +=item B . B<$manually_thawed> TRUE when the message has been manually thawed. -=item N . $max_received_linelength +=item N . B<$max_received_linelength> The number of bytes in the longest line that was received as part of the message, not counting line termination characters. -=item N . $message_age +=item N . B<$message_age> The number of seconds since the message was received. -=item S # $message_body +=item S # B<$message_body> The message's body. Unlike Exim's variable of the same name, this variable contains the entire message body. Newlines and nulls are replaced by spaces. -=item B + $message_body_missing +=item B + B<$message_body_missing> TRUE is a message's spool data file (-D file) is missing or unreadable. -=item N . $message_body_size +=item N . B<$message_body_size> The size of the body in bytes. -=item S . $message_exim_id, $message_id +=item S . B<$message_exim_id>, B<$message_id> The unique message id that is used by Exim to identify the message. $message_id is deprecated as of Exim 4.53. -=item S . $message_headers +=item S . B<$message_headers> A concatenation of all the header lines except for lines added by routers or transports. RFC2047 decoding is performed -=item S . $message_headers_raw +=item S . B<$message_headers_raw> A concatenation of all the header lines except for lines added by routers or transports. No decoding or translation is performed. -=item N . $message_linecount +=item N . B<$message_linecount> The number of lines in the entire message (body and headers). -=item N . $message_size +=item N . B<$message_size> The size of the message in bytes. -=item N . $originator_gid +=item N . B<$originator_gid> The group id under which the process that called Exim was running as when the message was received. -=item S + $originator_login +=item S + B<$originator_login> The login of the process which called Exim. -=item N . $originator_uid +=item N . B<$originator_uid> The user id under which the process that called Exim was running as when the message was received. -=item S . $received_ip_address, $interface_address +=item S . B<$received_ip_address>, B<$interface_address> The address of the local IP interface for network-originated messages. $interface_address is deprecated as of Exim 4.64 -=item N . $received_port, $interface_port +=item N . B<$received_port>, B<$interface_port> The local port number if network-originated messages. $interface_port is deprecated as of Exim 4.64 -=item N . $received_count +=item N . B<$received_count> The number of Received: header lines in the message. -=item S . $received_protocol +=item S . B<$received_protocol> The name of the protocol by which the message was received. -=item N . $received_time +=item N . B<$received_time> The epoch time at which the message was received. -=item S # $recipients +=item S # B<$recipients> The list of envelope recipients for a message. Unlike Exim's version, this variable always contains every recipient of the message. The recipients are separated by a comma and a space. See also $each_recipients. -=item N . $recipients_count +=item N . B<$recipients_count> The number of envelope recipients for the message. -=item S + $recipients_del +=item S + B<$recipients_del> The list of delivered envelope recipients for a message. This non-standard variable is in the same format as $recipients and contains the list of already-delivered recipients including any generated addresses. See also $each_recipients_del. -=item N + $recipients_del_count +=item N + B<$recipients_del_count> The number of envelope recipients for the message which have already been delivered. Note that this is the count of original recipients to which the message has been delivered. It does not include generated addresses so it is possible that this number will be less than the number of addresses in the $recipients_del string. -=item S + $recipients_undel +=item S + B<$recipients_undel> The list of undelivered envelope recipients for a message. This non-standard variable is in the same format as $recipients and contains the list of undelivered recipients. See also $each_recipients_undel. -=item N + $recipients_undel_count +=item N + B<$recipients_undel_count> The number of envelope recipients for the message which have not yet been delivered. -=item S . $reply_address +=item S . B<$reply_address> The contents of the Reply-To: header line if one exists and it is not empty, or otherwise the contents of the From: header line. -=item S . $rheader_*, $rh_* +=item S . B<$rheader_*>, B<$rh_*> The value of the message's header(s) with the same name. See section 11.5 of Exim's spec.txt for full description. -=item S . $sender_address +=item S . B<$sender_address> The sender's address that was received in the message's envelope. For bounce messages, the value of this variable is the empty string. -=item S . $sender_address_domain +=item S . B<$sender_address_domain> The domain part of $sender_address. -=item S . $sender_address_local_part +=item S . B<$sender_address_local_part> The local part of $sender_address. -=item S . $sender_helo_name +=item S . B<$sender_helo_name> The HELO or EHLO value supplied for smtp or bsmtp messages. -=item S . $sender_host_address +=item S . B<$sender_host_address> The remote host's IP address. -=item S . $sender_host_authenticated +=item S . B<$sender_host_authenticated> The name of the authenticator driver which successfully authenticated the client from which the message was received. -=item S . $sender_host_name +=item S . B<$sender_host_name> The remote host's name as obtained by looking up its IP address. -=item N . $sender_host_port +=item N . B<$sender_host_port> The port number that was used on the remote host for network-originated messages. -=item S . $sender_ident +=item S . B<$sender_ident> The identification received in response to an RFC 1413 request for remote messages, the login name of the user that called Exim for locally generated messages. -=item B + $sender_local +=item B + B<$sender_local> TRUE if the message was locally generated. -=item B + $sender_set_untrusted +=item B + B<$sender_set_untrusted> TRUE if the envelope sender of this message was set by an untrusted local caller. -=item S + $shown_message_size +=item S + B<$shown_message_size> This non-standard variable contains the formatted size string. That is, for a message whose $message_size is 66566 bytes, $shown_message_size is 65K. -=item S . $smtp_active_hostname +=item S . B<$smtp_active_hostname> The value of the active host name when the message was received, as specified by the "smtp_active_hostname" option. -=item S . $spam_score +=item S . B<$spam_score> The spam score of the message, for example '3.4' or '30.5'. (Requires exiscan or WITH_CONTENT_SCAN) -=item S . $spam_score_int +=item S . B<$spam_score_int> The spam score of the message, multiplied by ten, as an integer value. For instance '34' or '305'. (Requires exiscan or WITH_CONTENT_SCAN) -=item B . $tls_certificate_verified +=item B . B<$tls_certificate_verified> TRUE if a TLS certificate was verified when the message was received. -=item S . $tls_cipher +=item S . B<$tls_cipher> The cipher suite that was negotiated for encrypted SMTP connections. -=item S . $tls_peerdn +=item S . B<$tls_peerdn> The value of the Distinguished Name of the certificate if Exim is configured to request one -=item S . $tls_sni +=item S . B<$tls_sni> The value of the Server Name Indication TLS extension sent by a client, if one was sent. -=item N + $warning_count +=item N + B<$warning_count> The number of delay warnings which have been sent for this message. @@ -1831,8 +1830,12 @@ The number of delay warnings which have been sent for this message. =item EMAIL: proj-exipick@jetmore.net -=item HOME: jetmore.org/john/code/#exipick +=item HOME: L + +This script was incorporated into the main Exim distribution some years ago. =back =cut + +# vim:ft=perl