the base64 and plain attribute I/O encodings. Files:
util/attr_scan_plain.c util/attr_print_plain.c.
-20040624
+20050624
Added "." to the list commands that smtp-sink can "break"
(by disconnecting, or by responding with a 4XX or 5XX reply
code). File: smtpstone/smtp-sink.c.
-20040625
+20050625
Safety: allow only 4.x.x and 5.x.x enhanced status codes
in header/body_checks REJECT actions. File:
to complete the TCP, SMTP, EHLO or TLS handshake (was: TCP
and SMTP). File: smtp/smtp_proto.c.
+20050630
+
+ Updated the example spf.pl script to version 1.06.
+
+ Portability: the file descriptor passing code broke on LP64
+ systems (inherited from Stevens Network Programming). Files:
+ util/unix_send_fd.c, util/unix_recv_fd.c.
+
Open problems:
Look for systems with XPG basename() declared in <libgen.h>,
lots of time trying to connect to lots of bogus MX servers.
The Postfix SMTP error handling of [45]XX server greetings was
-cleaned up. The server reply is now properly reported.
+cleaned up. The server reply is now properly reported.
Incompatibility with snapshot 20050615
======================================
# mengwong@pobox.com
# Wed Dec 10 03:52:04 EST 2003
# postfix-policyd-spf
-# version 1.03
+# version 1.06
# see http://spf.pobox.com/
use Fcntl;
# ----------------------------------------------------------
# to use SPF, install Mail::SPF::Query from CPAN or from the SPF website at http://spf.pobox.com/downloads.html
-# then uncomment the SPF line.
my @HANDLERS;
push @HANDLERS, "testing";
-# push @HANDLERS, "sender_permitted_from"; use Mail::SPF::Query;
+ push @HANDLERS, "sender_permitted_from"; use Mail::SPF::Query;
my $VERBOSE = 1;
#
# smtpd_recipient_restrictions =
# ...
+# reject_unknown_sender_domain
# reject_unauth_destination
# check_policy_service unix:private/policy
# ...
#
sub fatal_exit {
syslog(err => "fatal_exit: @_");
- syslog(warn => "fatal_exit: @_");
+ syslog(warning => "fatal_exit: @_");
syslog(info => "fatal_exit: @_");
die "fatal: @_";
}
while (<STDIN>) {
chomp;
if (/=/) { my ($k, $v) = split (/=/, $_, 2); $attr{$k} = $v; next }
- elsif (length) { syslog(warn=>sprintf("warning: ignoring garbage: %.100s", $_)); next; }
+ elsif (length) { syslog(warning=>sprintf("warning: ignoring garbage: %.100s", $_)); next; }
if ($VERBOSE) {
for (sort keys %attr) {
local %_ = @_;
my %attr = %{ $_{attr} };
- my $query = new Mail::SPF::Query (ip =>$attr{client_address},
- sender=>$attr{sender},
- helo =>$attr{helo_name});
+ my $query = eval { new Mail::SPF::Query (ip =>$attr{client_address},
+ sender=>$attr{sender},
+ helo =>$attr{helo_name}) };
+ if ($@) {
+ syslog(info=>"%s: Mail::SPF::Query->new(%s, %s, %s) failed: %s",
+ $attr{queue_id}, $attr{client_address}, $attr{sender}, $attr{helo_name}, $@);
+ return "DUNNO";
+ }
my ($result, $smtp_comment, $header_comment) = $query->result();
syslog(info=>"%s: SPF %s: smtp_comment=%s, header_comment=%s",
elsif ($result eq "fail") { return "REJECT " . ($smtp_comment || $header_comment); }
elsif ($result eq "error") { return "450 temporary failure: $smtp_comment"; }
else { return "DUNNO"; }
- # unknown, softfail, and none all return DUNNO
+ # unknown, softfail, neutral and none all return DUNNO
# TODO XXX: prepend Received-SPF header. Wietse says he will add that functionality soon.
}
<b>-a</b> Do not announce SASL authentication support.
- <b>-c</b> Display a running counter that is updated whenever
- an SMTP QUIT command is executed.
+ <b>-c</b> Display running counters that are updated whenever
+ an SMTP session ends, a QUIT command is executed,
+ or when "." is received.
<b>-C</b> Disable XCLIENT support.
<b>-E</b> Do not announce ENHANCEDSTATUSCODES support.
<b>-f</b> <i>command,command,...</i>
- Reject the specified commands with a hard (5xx)
+ Reject the specified commands with a hard (5xx)
error code. This option implies <b>-p</b>.
- Examples of commands are HELO, EHLO, LHLO, MAIL,
+ Examples of commands are HELO, EHLO, LHLO, MAIL,
RCPT, VRFY, DATA, ., RSET, NOOP, and QUIT. Separate
- command names by white space or commas, and use
- quotes to protect white space from the shell. Com-
+ command names by white space or commas, and use
+ quotes to protect white space from the shell. Com-
mand names are case-insensitive.
<b>-F</b> Disable XFORWARD support.
<b>-h</b> <i>hostname</i>
- Use <i>hostname</i> in the SMTP greeting, in the HELO
- response, and in the EHLO response. The default
+ Use <i>hostname</i> in the SMTP greeting, in the HELO
+ response, and in the EHLO response. The default
hostname is "smtp-sink".
<b>-L</b> Enable LMTP instead of SMTP.
Terminate after <i>count</i> sessions. This is for testing
purposes.
- <b>-p</b> Do not announce support for ESMTP command pipelin-
+ <b>-p</b> Do not announce support for ESMTP command pipelin-
ing.
- <b>-P</b> Change the server greeting so that it appears to
+ <b>-P</b> Change the server greeting so that it appears to
come through a CISCO PIX system. Implies <b>-e</b>.
<b>-q</b> <i>command,command,...</i>
- Disconnect (without replying) after receiving one
+ Disconnect (without replying) after receiving one
of the specified commands.
- Examples of commands are HELO, EHLO, LHLO, MAIL,
+ Examples of commands are HELO, EHLO, LHLO, MAIL,
RCPT, VRFY, DATA, ., RSET, NOOP, and QUIT. Separate
- command names by white space or commas, and use
- quotes to protect white space from the shell. Com-
+ command names by white space or commas, and use
+ quotes to protect white space from the shell. Com-
mand names are case-insensitive.
<b>-r</b> <i>command,command,...</i>
- Reject the specified commands with a soft (4xx)
+ Reject the specified commands with a soft (4xx)
error code. This option implies <b>-p</b>.
- Examples of commands are HELO, EHLO, LHLO, MAIL,
+ Examples of commands are HELO, EHLO, LHLO, MAIL,
RCPT, VRFY, DATA, ., RSET, NOOP, and QUIT. Separate
- command names by white space or commas, and use
- quotes to protect white space from the shell. Com-
+ command names by white space or commas, and use
+ quotes to protect white space from the shell. Com-
mand names are case-insensitive.
<b>-s</b> <i>command,command,...</i>
Log the named commands to syslogd.
- Examples of commands are HELO, EHLO, LHLO, MAIL,
+ Examples of commands are HELO, EHLO, LHLO, MAIL,
RCPT, VRFY, DATA, ., RSET, NOOP, and QUIT. Separate
- command names by white space or commas, and use
- quotes to protect white space from the shell. Com-
+ command names by white space or commas, and use
+ quotes to protect white space from the shell. Com-
mand names are case-insensitive.
<b>-t</b> <i>timeout</i> (default: 100)
Limit the time for receiving a command or sending a
- response. The time limit is specified in seconds.
+ response. The time limit is specified in seconds.
<b>-v</b> Show the SMTP conversations.
mand.
[<b>inet:</b>][<i>host</i>]:<i>port</i>
- Listen on network interface <i>host</i> (default: any
+ Listen on network interface <i>host</i> (default: any
interface) TCP port <i>port</i>. Both <i>host</i> and <i>port</i> may be
specified in numeric or symbolic form.
Listen on the UNIX-domain socket at <i>pathname</i>.
<i>backlog</i>
- The maximum length the queue of pending connec-
+ The maximum length the queue of pending connec-
tions, as defined by the <b>listen</b>(2) system call.
<b>SEE ALSO</b>
<a href="smtp-source.1.html">smtp-source(1)</a>, SMTP/LMTP message generator
<b>LICENSE</b>
- The Secure Mailer license must be distributed with this
+ The Secure Mailer license must be distributed with this
software.
<b>AUTHOR(S)</b>
.IP \fB-a\fR
Do not announce SASL authentication support.
.IP \fB-c\fR
-Display a running counter that is updated whenever an SMTP
-QUIT command is executed.
+Display running counters that are updated whenever an SMTP
+session ends, a QUIT command is executed, or when "." is
+received.
.IP \fB-C\fR
Disable XCLIENT support.
.IP \fB-e\fR
* Patches change both the patchlevel and the release date. Snapshots have no
* patchlevel; they change the release date only.
*/
-#define MAIL_RELEASE_DATE "20050629"
+#define MAIL_RELEASE_DATE "20050630"
#define MAIL_VERSION_NUMBER "2.3"
#define VAR_MAIL_VERSION "mail_version"
||
#endif
(fd = LOCAL_RECV_FD(vstream_fileno(client_stream))) < 0) {
- msg_warn("%s: unable to receive file descriptor", myname);
+ msg_warn("%s: unable to receive file descriptor: %m", myname);
attr_print(client_stream, ATTR_FLAG_NONE,
ATTR_TYPE_NUM, MAIL_ATTR_STATUS, SCACHE_STAT_FAIL,
ATTR_TYPE_END);
/* .IP \fB-a\fR
/* Do not announce SASL authentication support.
/* .IP \fB-c\fR
-/* Display a running counter that is updated whenever an SMTP
-/* QUIT command is executed.
+/* Display running counters that are updated whenever an SMTP
+/* session ends, a QUIT command is executed, or when "." is
+/* received.
/* .IP \fB-C\fR
/* Disable XCLIENT support.
/* .IP \fB-e\fR
static int data_read(SINK_STATE *);
static void disconnect(SINK_STATE *);
static int count;
-static int counter;
-static int max_count;
+static int sess_count;
+static int quit_count;
+static int mesg_count;
+static int max_quit_count;
static int disable_pipelining;
static int disable_8bitmime;
static int fixed_delay;
#define SOFT_ERROR_RESP "450 4.3.0 Error: command failed"
#define HARD_ERROR_RESP "500 5.3.0 Error: command failed"
+/* do_stats - show counters */
+
+static void do_stats(void)
+{
+ vstream_printf("sess=%d quit=%d mesg=%d\r",
+ sess_count, quit_count, mesg_count);
+ vstream_fflush(VSTREAM_OUT);
+}
+
/* hard_err_resp - generic hard error response */
static void hard_err_resp(SINK_STATE *state)
{
smtp_printf(state->stream, "221 Bye");
smtp_flush(state->stream);
- if (count) {
- counter++;
- vstream_printf("%d\r", counter);
- vstream_fflush(VSTREAM_OUT);
- }
+ if (count)
+ quit_count++;
}
/* data_read - read data from socket */
PUSH_BACK_SET(state, ".\r\n");
state->read_fn = command_read;
state->data_state = ST_ANY;
+ if (count) {
+ mesg_count++;
+ do_stats();
+ }
break;
}
{
event_disable_readwrite(vstream_fileno(state->stream));
event_cancel_timer(read_timeout, (char *) state);
+ if (count) {
+ sess_count++;
+ do_stats();
+ }
vstream_fclose(state->stream);
vstring_free(state->buffer);
myfree((char *) state);
- if (max_count > 0 && counter >= max_count)
+ if (max_quit_count > 0 && quit_count >= max_quit_count)
exit(0);
}
enable_lmtp = 1;
break;
case 'n':
- if ((max_count = atoi(optarg)) <= 0)
+ if ((max_quit_count = atoi(optarg)) <= 0)
msg_fatal("bad count: %s", optarg);
break;
case 'p':
/*
* Adapted from: W. Richard Stevens, UNIX Network Programming, Volume 1,
- * Second edition.
+ * Second edition. Except that we use CMSG_LEN instead of CMSG_SPACE, for
+ * portability to LP64 environments.
*/
#if defined(CMSG_SPACE) && !defined(NO_MSGHDR_MSG_CONTROL)
union {
- struct msghdr just_for_alignment;
+ struct cmsghdr just_for_alignment;
char control[CMSG_SPACE(sizeof(newfd))];
} control_un;
struct cmsghdr *cmptr;
msg.msg_control = control_un.control;
- msg.msg_controllen = sizeof(control_un.control);
+ msg.msg_controllen = CMSG_LEN(sizeof(newfd)); /* Fix 200506 */
#else
msg.msg_accrights = (char *) &newfd;
msg.msg_accrightslen = sizeof(newfd);
* unix_send_fd test program) and copy its content until EOF.
*/
#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
#include <split_at.h>
#include <listen.h>
/*
* Adapted from: W. Richard Stevens, UNIX Network Programming, Volume 1,
- * Second edition.
+ * Second edition. Except that we use CMSG_LEN instead of CMSG_SPACE; the
+ * latter breaks on LP64 systems.
*/
#if defined(CMSG_SPACE) && !defined(NO_MSGHDR_MSG_CONTROL)
union {
- struct msghdr just_for_alignment;
+ struct cmsghdr just_for_alignment;
char control[CMSG_SPACE(sizeof(sendfd))];
} control_un;
struct cmsghdr *cmptr;
msg.msg_control = control_un.control;
- msg.msg_controllen = sizeof(control_un.control);
+ msg.msg_controllen = CMSG_LEN(sizeof(sendfd)); /* Fix 200506 */
cmptr = CMSG_FIRSTHDR(&msg);
cmptr->cmsg_len = CMSG_LEN(sizeof(sendfd));
* to the unix_recv_fd test program.
*/
#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
#include <fcntl.h>
#include <split_at.h>
#include <connect.h>