resolve conflicts

This commit is contained in:
perry 2002-12-24 20:38:22 +00:00
parent 7857417570
commit cad21f274d
14 changed files with 1866 additions and 701 deletions

View File

@ -170,6 +170,10 @@ case "$SYSTEM.$RELEASE" in
;;
*) echo "Unknown AIX version: `uname -v`." 1>&2; exit 1;;
esac;;
# Tested with RedHat 3.03 on 20020729.
Linux.1*) SYSTYPE=LINUX1
SYSLIBS="-ldb"
;;
Linux.2*) SYSTYPE=LINUX2
# Postfix no longer needs DB 1.85 compatibility
if [ -f /usr/include/db.h ]
@ -187,6 +191,10 @@ case "$SYSTEM.$RELEASE" in
echo "See the RELEASE_NOTES file for more information." 1>&2
exit 1
fi
if [ -f /usr/include/pcre/pcre.h ]
then
CCARGS="$CCARGS -DHAS_PCRE -I/usr/include/pcre"
fi
# GDBM locks the DBM .pag file after open. This breaks postmap.
# if [ -f /usr/include/gdbm-ndbm.h ]
# then
@ -198,7 +206,7 @@ case "$SYSTEM.$RELEASE" in
# GDBM_LIBS=gdbm
# fi
SYSLIBS="-ldb"
for name in nsl resolv $GDBM_LIBS
for name in nsl resolv pcre $GDBM_LIBS
do
test -e /usr/lib/lib$name.a -o -e /usr/lib/lib$name.so \
-o -e /lib/lib$name.a -o -e /lib/lib$name.so \
@ -309,5 +317,5 @@ OPT = $OPT
DEBUG = $DEBUG
AWK = $AWK
STRCASE = $STRCASE
EXPORT = AUXLIBS="$AUXLIBS" CCARGS="$CCARGS" OPT="$OPT" DEBUG="$DEBUG"
EXPORT = AUXLIBS='$AUXLIBS' CCARGS='$CCARGS' OPT='$OPT' DEBUG='$DEBUG'
EOF

View File

@ -4,25 +4,41 @@
.SH NAME
virtual
\-
format of Postfix virtual table
format of Postfix virtual alias table
.SH SYNOPSIS
.na
.nf
\fBpostmap /etc/postfix/virtual\fR
\fBpostmap -q "\fIstring\fB" /etc/postfix/virtual\fR
\fBpostmap -q - /etc/postfix/virtual <\fIinputfile\fR
.SH DESCRIPTION
.ad
.fi
The optional \fBvirtual\fR table specifies address redirections for
local and non-local recipients or domains. The redirections are used
by the \fBcleanup\fR(8) daemon. The redirections are recursive.
The optional \fBvirtual\fR alias table specifies address aliasing
for arbitrary local or non-local recipient addresses. Virtual aliasing
is recursive, and is done by the Postfix \fBcleanup\fR(8) daemon.
The \fBvirtual\fR redirection is applied only to recipient
The main applications of virtual aliasing are:
.IP \(bu
To redirect mail for one address to one or more addresses.
.IP \(bu
To implement virtual alias domains where all addresses are aliased
to addresses in other domains.
.sp
Virtual alias domains are not to be confused with the virtual mailbox
domains that are implemented with the Postfix \fBvirtual\fR(8) mail
delivery agent. With virtual mailbox domains, each recipient address
can have its own mailbox.
.PP
Virtual aliasing is applied only to recipient
envelope addresses, and does not affect message headers.
Think Sendmail rule set \fBS0\fR, if you like. Use \fBcanonical\fR(5)
mapping to rewrite header and envelope addresses in general.
Normally, the \fBvirtual\fR table is specified as a text file that
serves as input to the \fBpostmap\fR(1) command.
Normally, the \fBvirtual\fR alias table is specified as a text file
that serves as input to the \fBpostmap\fR(1) command.
The result, an indexed file in \fBdbm\fR or \fBdb\fR format,
is used for fast searching by the mail system. Execute the command
\fBpostmap /etc/postfix/virtual\fR in order to rebuild the indexed
@ -34,87 +50,6 @@ or SQL, the same lookups are done as for ordinary indexed files.
Alternatively, the table can be provided as a regular-expression
map where patterns are given as regular expressions. In that case,
the lookups are done in a slightly different way as described below.
.SH POSTFIX-STYLE VIRTUAL DOMAINS
.na
.nf
.ad
.fi
With a Postfix-style virtual domain, the virtual domain has its
own user name space. Local (i.e. non-virtual) usernames are not
visible in a Postfix-style virtual domain. In particular, local
\fBaliases\fR(5) and mailing lists are not visible as
\fIlocalname@virtual.domain\fR.
Use a Sendmail-style virtual domain (see below) if local usernames,
\fBaliases\fR(5) or mailing lists should be visible as
\fIlocalname@virtual.domain\fR.
Support for a Postfix-style virtual domain looks like:
.sp
/etc/postfix/virtual:
.in +4
.nf
\fIvirtual.domain anything\fR (right-hand content does not matter)
\fIpostmaster@virtual.domain postmaster\fR
\fIuser1@virtual.domain address1\fR
\fIuser2@virtual.domain address2, address3\fR
.fi
.in -4
The \fIvirtual.domain anything\fR entry is required for a
Postfix-style virtual domain.
Do not list a Postfix-style virtual domain in the \fBmain.cf
mydestination\fR configuration parameter.
Such an entry is required only for a Sendmail-style virtual domain.
With a Postfix-style virtual domain, the Postfix SMTP server
accepts mail for \fIknown-user@virtual.domain\fR and rejects
mail for \fIunknown-user\fR@\fIvirtual.domain\fR as undeliverable.
.SH SENDMAIL-STYLE VIRTUAL DOMAINS
.na
.nf
.ad
.fi
With a Sendmail-style virtual domain, every local (i.e. non-virtual)
username is visible in the virtual domain. In particular, every local
alias and mailing list is visible as \fIlocalname@virtual.domain\fR.
Use a Postfix-style virtual domain (see above) if local usernames,
\fBaliases\fR(5) or mailing lists should not be visible as
\fIlocalname@virtual.domain\fR.
Support for a Sendmail-style virtual domain looks like:
.sp
/etc/postfix/main.cf:
.in +4
.nf
mydestination = $myhostname localhost.$mydomain $mydomain
.ti +4
\fIvirtual.domain\fR
.fi
.in -4
.sp
/etc/postfix/virtual:
.in +4
.nf
\fIuser1@virtual.domain address1\fR
\fIuser2@virtual.domain address2, address3\fR
.fi
.in -4
The \fBmain.cf mydestination\fR entry is required for a Sendmail-style
virtual domain.
Do not specify a \fIvirtual.domain anything\fR virtual map entry
for a Sendmail-style virtual domain.
Such an entry is required only with a Postfix-style virtual domain.
With a Sendmail-style virtual domain, the Postfix local delivery
agent delivers mail for an unknown \fIuser\fR@\fIvirtual.domain\fR
to a local (i.e. non-virtual) user that has the same name; if no
such recipient exists, the Postfix local delivery agent bounces the
mail to the sender.
.SH TABLE FORMAT
.na
.nf
@ -163,6 +98,65 @@ When a mail address localpart contains the optional recipient delimiter
\fIuser+foo\fR@\fIdomain\fR, \fIuser\fR@\fIdomain\fR, \fIuser+foo\fR,
\fIuser\fR, and @\fIdomain\fR. An unmatched address extension
(\fI+foo\fR) is propagated to the result of table lookup.
.SH VIRTUAL ALIAS DOMAINS
.na
.nf
.ad
.fi
Besides virtual aliases, the virtual alias table can also be used
to implement virtual alias domains. With a virtual alias domain, all
recipient addresses are aliased to addresses in other domains.
Virtual alias domains are not to be confused with the virtual mailbox
domains that are implemented with the Postfix \fBvirtual\fR(8) mail
delivery agent. With virtual mailbox domains, each recipient address
can have its own mailbox.
With a virtual alias domain, the virtual domain has its
own user name space. Local (i.e. non-virtual) usernames are not
visible in a virtual alias domain. In particular, local
\fBaliases\fR(5) and local mailing lists are not visible as
\fIlocalname@virtual-alias.domain\fR.
Support for a virtual alias domain looks like:
/etc/postfix/main.cf:
.in +4
virtual_alias_maps = hash:/etc/postfix/virtual
Note: some systems use \fBdbm\fR databases instead of \fBhash\fR.
See the output from \fBpostconf -m\fR for available database types.
.ti -4
/etc/postfix/virtual:
.nf
.na
\fIvirtual-alias.domain anything\fR (right-hand content does not matter)
\fIpostmaster@virtual-alias.domain postmaster\fR
\fIuser1@virtual-alias.domain address1\fR
\fIuser2@virtual-alias.domain address2, address3\fR
.fi
.in -4
.ad
.fi
.sp
The \fIvirtual-alias.domain anything\fR entry is required for a
virtual alias domain. Without this entry, mail is rejected
with "relay access denied", or bounces with
"mail loops back to myself".
Do not specify virtual alias domain names in the \fBmain.cf
mydestination\fR or \fBrelay_domains\fR configuration parameters.
With a virtual alias domain, the Postfix SMTP server
accepts mail for \fIknown-user@virtual-alias.domain\fR, and rejects
mail for \fIunknown-user\fR@\fIvirtual-alias.domain\fR as undeliverable.
Instead of specifying the virtual alias domain name via
the \fBvirtual_alias_maps\fR table, you may also specify it via
the \fBmain.cf virtual_alias_domains\fR configuration parameter.
This latter parameter uses the same syntax as the \fBmain.cf
mydestination\fR configuration parameter.
.SH REGULAR EXPRESSION TABLES
.na
.nf
@ -197,16 +191,20 @@ The following \fBmain.cf\fR parameters are especially relevant to
this topic. See the Postfix \fBmain.cf\fR file for syntax details
and for default values. Use the \fBpostfix reload\fR command after
a configuration change.
.IP \fBvirtual_maps\fR
List of virtual mapping tables.
.IP \fBvirtual_alias_maps\fR
List of virtual aliasing tables.
.IP \fBvirtual_alias_domains\fR
List of virtual alias domains. This uses the same syntax
as the \fBmydestination\fR parameter.
.PP
Other parameters of interest:
.IP \fBinet_interfaces\fR
The network interface addresses that this system receives mail on.
You need to stop and start Postfix when this parameter changes.
.IP \fBmydestination\fR
List of domains that this mail system considers local.
.IP \fBmyorigin\fR
The domain that is appended to locally-posted mail.
The domain that is appended to any address that does not have a domain.
.IP \fBowner_request_special\fR
Give special treatment to \fBowner-\fIxxx\fR and \fIxxx\fB-request\fR
addresses.
@ -215,8 +213,8 @@ addresses.
.nf
cleanup(8) canonicalize and enqueue mail
postmap(1) create mapping table
pcre_table(5) format of PCRE tables
regexp_table(5) format of POSIX regular expression tables
regexp_table(5) POSIX regular expression table format
pcre_table(5) Perl Compatible Regular Expression table format
.SH LICENSE
.na
.nf

View File

@ -121,6 +121,8 @@ for recipients that are not found in the UNIX passwd database.
In the case of UNIX-style mailbox delivery,
the \fBlocal\fR daemon prepends a "\fBFrom \fIsender time_stamp\fR"
envelope header to each message, prepends an
\fBX-Original-To:\fR header with the recipient address as given to
Postfix, prepends an
optional \fBDelivered-To:\fR header
with the envelope recipient address, prepends a \fBReturn-Path:\fR
header with the envelope sender address, prepends a \fB>\fR character
@ -131,7 +133,10 @@ mailbox to its original length.
In the case of \fBmaildir\fR delivery, the local daemon prepends
an optional
\fBDelivered-To:\fR header with the envelope recipient address
\fBDelivered-To:\fR header with the final envelope recipient address,
prepends an
\fBX-Original-To:\fR header with the recipient address as given to
Postfix,
and prepends a \fBReturn-Path:\fR header with the envelope sender
address.
.SH EXTERNAL COMMAND DELIVERY
@ -176,15 +181,20 @@ The entire recipient address localpart (text to the left of the
rightmost @ character).
.IP \fBRECIPIENT\fR
The entire recipient address.
.IP \fBSENDER\fR
The entire sender address.
.PP
The \fBPATH\fR environment variable is always reset to a
system-dependent default path, and the \fBTZ\fR (time zone)
environment variable is always passed on without change.
system-dependent default path, and environment variables
whose names are blessed by the \fBexport_environment\fR
configuration parameter are exported unchanged.
The current working directory is the mail queue directory.
The \fBlocal\fR daemon prepends a "\fBFrom \fIsender time_stamp\fR"
envelope header to each message, prepends an
\fBX-Original-To:\fR header with the recipient address as given to
Postfix, prepends an
optional \fBDelivered-To:\fR
header with the recipient envelope address, prepends a
\fBReturn-Path:\fR header with the sender envelope address,
@ -205,6 +215,8 @@ forward\fR) forbids file destinations in \fB:include:\fR files.
In the case of UNIX-style mailbox delivery,
the \fBlocal\fR daemon prepends a "\fBFrom \fIsender time_stamp\fR"
envelope header to each message, prepends an
\fBX-Original-To:\fR header with the recipient address as given to
Postfix, prepends an
optional \fBDelivered-To:\fR
header with the recipient envelope address, prepends a \fB>\fR
character to lines beginning with "\fBFrom \fR", and appends an
@ -217,7 +229,10 @@ is made to truncate a regular file to its original length.
In the case of \fBmaildir\fR delivery, the local daemon prepends
an optional
\fBDelivered-To:\fR header with the envelope recipient address.
\fBDelivered-To:\fR header with the envelope recipient address, and
prepends an
\fBX-Original-To:\fR header with the recipient address as given to
Postfix.
The envelope sender address is available in the \fBReturn-Path:\fR
header.
.SH ADDRESS EXTENSION
@ -326,12 +341,22 @@ recipient before attempting delivery. Defer delivery otherwise.
Message transport for recipients that are not found in the UNIX
passwd database.
This parameter overrides \fBluser_relay\fR.
.sp
Note: you must update the \fBlocal_recipient_maps\fR
setting in the \fBmain.cf\fR file, otherwise the Postfix SMTP
server will reject mail for non-UNIX accounts with "\fBUser
unknown in local recipient table\fR".
.IP \fBhome_mailbox\fR
Pathname of a mailbox relative to a user's home directory.
Specify a path ending in \fB/\fR for maildir-style delivery.
.IP \fBluser_relay\fR
Destination (\fI@domain\fR or \fIaddress\fR) for non-existent users.
The \fIaddress\fR is subjected to \fI$name\fR expansion.
.sp
Note: you must specify "\fBlocal_recipient_maps =\fR"
(i.e. empty) in the \fBmain.cf\fR file, otherwise the Postfix SMTP
server will reject mail for non-UNIX accounts with "\fBUser
unknown in local recipient table\fR".
.IP \fBmail_spool_directory\fR
Directory with UNIX-style mailboxes. The default pathname is system
dependent.
@ -348,6 +373,12 @@ Message transport to use for mailbox delivery to all local
recipients, whether or not they are found in the UNIX passwd database.
This parameter overrides all other configuration parameters that
control mailbox delivery, including \fBluser_relay\fR.
.sp
Note: if you use this feature to receive mail for non-UNIX
accounts then you must update the \fBlocal_recipient_maps\fR
setting in the \fBmain.cf\fR file, otherwise the Postfix SMTP
server will reject mail for non-UNIX accounts with "\fBUser
unknown in local recipient table\fR".
.SH "Locking controls"
.ad
.fi

View File

@ -169,8 +169,8 @@ static int dns_query(const char *name, int type, int flags,
len = res_search((char *) name, C_IN, type, reply->buf, sizeof(reply->buf));
if (len < 0) {
if (why)
vstring_sprintf(why, "Name service error for %s: %s",
name, dns_strerror(h_errno));
vstring_sprintf(why, "Name service error for name=%s type=%s: %s",
name, dns_strtype(type), dns_strerror(h_errno));
if (msg_verbose)
msg_info("dns_query: %s (%s): %s",
name, dns_strtype(type), dns_strerror(h_errno));
@ -187,6 +187,15 @@ static int dns_query(const char *name, int type, int flags,
if (msg_verbose)
msg_info("dns_query: %s (%s): OK", name, dns_strtype(type));
/*
* Paranoia.
*/
if (len > sizeof(reply->buf)) {
msg_warn("reply length %d > buffer length %d for name=%s type=%s",
len, sizeof(reply->buf), name, dns_strtype(type));
len = sizeof(reply->buf);
}
/*
* Initialize the reply structure. Some structure members are filled on
* the fly while the reply is being parsed.
@ -338,6 +347,7 @@ static DNS_RR *dns_get_rr(DNS_REPLY *reply, unsigned char *pos,
memcpy(temp, pos, fixed->length);
data_len = fixed->length;
break;
#ifdef T_AAAA
case T_AAAA:
if (fixed->length != INET6_ADDR_LEN) {
msg_warn("extract_answer: bad address length: %d", fixed->length);
@ -349,6 +359,7 @@ static DNS_RR *dns_get_rr(DNS_REPLY *reply, unsigned char *pos,
memcpy(temp, pos, fixed->length);
data_len = fixed->length;
break;
#endif
case T_TXT:
data_len = MIN2(pos[0] + 1, MIN2(fixed->length + 1, sizeof(temp)));
for (src = pos + 1, dst = (unsigned char *) (temp);
@ -389,6 +400,7 @@ static int dns_get_answer(DNS_REPLY *reply, int type,
DNS_RR *rr;
int resource_found = 0;
int cname_found = 0;
int not_found_status = DNS_NOTFOUND;
/*
* Initialize. Skip over the name server query if we haven't yet.
@ -449,12 +461,14 @@ static int dns_get_answer(DNS_REPLY *reply, int type,
if (pos + fixed.length > reply->end)
CORRUPT;
if (type == fixed.type || type == T_ANY) { /* requested type */
resource_found++;
if (rrlist) {
if ((rr = dns_get_rr(reply, pos, rr_name, &fixed)) == 0)
CORRUPT;
*rrlist = dns_rr_append(*rrlist, rr);
}
if ((rr = dns_get_rr(reply, pos, rr_name, &fixed)) != 0) {
resource_found++;
*rrlist = dns_rr_append(*rrlist, rr);
} else
not_found_status = DNS_RETRY;
} else
resource_found++;
} else if (fixed.type == T_CNAME) { /* cname resource */
cname_found++;
if (cname && c_len > 0)
@ -473,7 +487,7 @@ static int dns_get_answer(DNS_REPLY *reply, int type,
return (DNS_OK);
if (cname_found)
return (DNS_RECURSE);
return (DNS_NOTFOUND);
return (not_found_status);
}
/* dns_lookup - DNS lookup user interface */
@ -492,7 +506,19 @@ int dns_lookup(const char *name, unsigned type, unsigned flags,
*/
if (!valid_hostname(name, DONT_GRIPE)) {
if (why)
vstring_sprintf(why, "Name service error for %s: invalid name",
vstring_sprintf(why,
"Name service error for %s: invalid host or domain name",
name);
return (DNS_NOTFOUND);
}
/*
* DJBDNS produces a bogus A record when given a numerical hostname.
*/
if (valid_hostaddr(name, DONT_GRIPE)) {
if (why)
vstring_sprintf(why,
"Name service error for %s: invalid host or domain name",
name);
return (DNS_NOTFOUND);
}
@ -517,7 +543,9 @@ int dns_lookup(const char *name, unsigned type, unsigned flags,
switch (status) {
default:
if (why)
vstring_sprintf(why, "%s: Malformed name server reply", name);
vstring_sprintf(why, "Name service error for name=%s type=%s: "
"Malformed name server reply",
name, dns_strtype(type));
case DNS_NOTFOUND:
case DNS_OK:
return (status);

View File

@ -402,6 +402,8 @@ MASTER_SERV *get_master_ent()
argv_add(serv->args, command, (char *) 0);
if (serv->max_proc == 1)
argv_add(serv->args, "-l", (char *) 0);
if (serv->max_proc == 0)
argv_add(serv->args, "-z", (char *) 0);
if (strcmp(basename(command), name) != 0)
argv_add(serv->args, "-n", name, (char *) 0);
argv_add(serv->args, "-t", transport, (char *) 0);

View File

@ -109,10 +109,9 @@
#include <rec_type.h>
#include <sent.h>
#include <deliver_completed.h>
#include <mail_addr_find.h>
#include <opened.h>
#include <resolve_local.h>
#include <verp_sender.h>
#include <mail_proto.h>
/* Client stubs. */
@ -143,6 +142,7 @@ static QMGR_MESSAGE *qmgr_message_create(const char *queue_name,
message->data_offset = 0;
message->queue_id = mystrdup(queue_id);
message->queue_name = mystrdup(queue_name);
message->encoding = 0;
message->sender = 0;
message->errors_to = 0;
message->return_receipt = 0;
@ -203,6 +203,10 @@ static int qmgr_message_read(QMGR_MESSAGE *message)
char *start;
struct stat st;
int nrcpt = 0;
const char *error_text;
char *name;
char *value;
char *orig_rcpt = 0;
/*
* Initialize. No early returns or we have a memory leak.
@ -254,11 +258,13 @@ static int qmgr_message_read(QMGR_MESSAGE *message)
if (message->arrival_time == 0)
message->arrival_time = atol(start);
} else if (rec_type == REC_TYPE_FILT) {
if (message->filter_xport == 0)
message->filter_xport = mystrdup(start);
if (message->filter_xport != 0)
myfree(message->filter_xport);
message->filter_xport = mystrdup(start);
} else if (rec_type == REC_TYPE_INSP) {
if (message->inspect_xport == 0)
message->inspect_xport = mystrdup(start);
if (message->inspect_xport != 0)
myfree(message->inspect_xport);
message->inspect_xport = mystrdup(start);
} else if (rec_type == REC_TYPE_FROM) {
if (message->sender == 0) {
message->sender = mystrdup(start);
@ -269,7 +275,12 @@ static int qmgr_message_read(QMGR_MESSAGE *message)
} else if (rec_type == REC_TYPE_RCPT) {
#define FUDGE(x) ((x) * (var_qmgr_fudge / 100.0))
if (message->rcpt_list.len < FUDGE(var_qmgr_rcpt_limit)) {
qmgr_rcpt_list_add(&message->rcpt_list, curr_offset, start);
qmgr_rcpt_list_add(&message->rcpt_list, curr_offset,
orig_rcpt ? orig_rcpt : "unknown", start);
if (orig_rcpt) {
myfree(orig_rcpt);
orig_rcpt = 0;
}
if (message->rcpt_list.len >= FUDGE(var_qmgr_rcpt_limit)) {
if ((message->rcpt_offset = vstream_ftell(message->fp)) < 0)
msg_fatal("vstream_ftell %s: %m",
@ -294,6 +305,18 @@ static int qmgr_message_read(QMGR_MESSAGE *message)
}
if (vstream_fseek(message->fp, extra_offset, SEEK_SET) < 0)
msg_fatal("seek file %s: %m", VSTREAM_PATH(message->fp));
} else if (rec_type == REC_TYPE_ATTR) {
if ((error_text = split_nameval(start, &name, &value)) != 0) {
msg_warn("%s: bad attribute: %s: %.200s",
message->queue_id, error_text, start);
break;
}
/* Allow extra segment to override envelope segment info. */
if (strcmp(name, MAIL_ATTR_ENCODING) == 0) {
if (message->encoding != 0)
myfree(message->encoding);
message->encoding = mystrdup(value);
}
} else if (rec_type == REC_TYPE_ERTO) {
if (message->errors_to == 0)
message->errors_to = mystrdup(start);
@ -316,8 +339,26 @@ static int qmgr_message_read(QMGR_MESSAGE *message)
}
}
}
if (orig_rcpt != 0) {
if (rec_type != REC_TYPE_DONE)
msg_warn("%s: out-of-order original recipient record <%.200s>",
message->queue_id, start);
myfree(orig_rcpt);
orig_rcpt = 0;
}
if (rec_type == REC_TYPE_ORCP)
orig_rcpt = mystrdup(start);
} while (rec_type > 0 && rec_type != REC_TYPE_END);
/*
* Grr.
*/
if (orig_rcpt != 0) {
msg_warn("%s: out-of-order original recipient <%.200s>",
message->queue_id, start);
myfree(orig_rcpt);
}
/*
* If there is no size record, use the queue file size instead.
*/
@ -336,6 +377,8 @@ static int qmgr_message_read(QMGR_MESSAGE *message)
message->errors_to = mystrdup("");
if (message->return_receipt == 0)
message->return_receipt = mystrdup("");
if (message->encoding == 0)
message->encoding = mystrdup(MAIL_ATTR_ENC_NONE);
/*
* Clean up.
@ -461,11 +504,8 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message)
QMGR_TRANSPORT *transport = 0;
QMGR_QUEUE *queue = 0;
RESOLVE_REPLY reply;
const char *newloc;
char *at;
char **cpp;
char *domain;
const char *junk;
char *nexthop;
int len;
@ -497,12 +537,33 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message)
* Resolve the destination to (transport, nexthop, address). The
* result address may differ from the one specified by the sender.
*/
resolve_clnt_query(recipient->address, &reply);
if (reply.flags & RESOLVE_FLAG_ERROR) {
qmgr_bounce_recipient(message, recipient,
"bad address syntax: \"%s\"",
recipient->address);
continue;
if (var_sender_routing == 0) {
resolve_clnt_query(recipient->address, &reply);
if (reply.flags & RESOLVE_FLAG_FAIL) {
qmgr_defer_recipient(message, recipient,
"address resolver failure");
continue;
}
if (reply.flags & RESOLVE_FLAG_ERROR) {
qmgr_bounce_recipient(message, recipient,
"bad address syntax: \"%s\"",
recipient->address);
continue;
}
} else {
resolve_clnt_query(message->sender, &reply);
if (reply.flags & RESOLVE_FLAG_FAIL) {
qmgr_defer_recipient(message, recipient,
"address resolver failure");
continue;
}
if (reply.flags & RESOLVE_FLAG_ERROR) {
qmgr_bounce_recipient(message, recipient,
"bad address syntax: \"%s\"",
message->sender);
continue;
}
vstring_strcpy(reply.recipient, recipient->address);
}
if (message->filter_xport) {
vstring_strcpy(reply.transport, message->filter_xport);
@ -514,6 +575,11 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message)
if (!STREQ(recipient->address, STR(reply.recipient)))
UPDATE(recipient->address, STR(reply.recipient));
}
if (recipient->address[0] == 0) {
qmgr_bounce_recipient(message, recipient,
"null recipient address");
continue;
}
/*
* XXX The nexthop destination is also used as lookup key for the
@ -522,46 +588,6 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message)
*/
lowercase(STR(reply.nexthop));
/*
* Bounce recipients that have moved. We do it here instead of in the
* local delivery agent. The benefit is that we can bounce mail for
* virtual addresses, not just local addresses only, and that there
* is no need to run a local delivery agent just for the sake of
* relocation notices. The downside is that this table has no effect
* on local alias expansion results, so that mail will have to make
* almost an entire iteration through the mail system.
*/
#define IGNORE_ADDR_EXTENSION ((char **) 0)
if (qmgr_relocated != 0) {
if ((newloc = mail_addr_find(qmgr_relocated, recipient->address,
IGNORE_ADDR_EXTENSION)) != 0) {
qmgr_bounce_recipient(message, recipient,
"user has moved to %s", newloc);
continue;
} else if (dict_errno != 0) {
qmgr_defer_recipient(message, recipient->address,
"relocated map lookup failure");
continue;
}
}
/*
* Bounce mail to non-existent users in virtual domains.
*/
if (qmgr_virtual != 0
&& (at = strrchr(recipient->address, '@')) != 0
&& !resolve_local(at + 1)) {
domain = lowercase(mystrdup(at + 1));
junk = maps_find(qmgr_virtual, domain, 0);
myfree(domain);
if (junk) {
qmgr_bounce_recipient(message, recipient,
"unknown user: \"%s\"", recipient->address);
continue;
}
}
/*
* Bounce recipient addresses that start with `-'. External commands
* may misinterpret such addresses as command-line options.
@ -621,13 +647,17 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message)
* system can run without a local delivery agent. They'd still have
* to configure something for mail directed to the local postmaster,
* though, but that is an RFC requirement anyway.
*
* XXX This lookup should be done in the resolver, and the mail should
* be directed to a general-purpose null delivery agent.
*/
if (at == 0 || resolve_local(at + 1)) {
if (reply.flags & RESOLVE_CLASS_LOCAL) {
if (strncasecmp(STR(reply.recipient), var_double_bounce_sender,
len) == 0
&& !var_double_bounce_sender[len]) {
sent(message->queue_id, recipient->address,
"none", message->arrival_time, "discarded");
sent(message->queue_id, recipient->orig_rcpt,
recipient->address, "none", message->arrival_time,
"discarded");
deliver_completed(message->fp, recipient->offset);
msg_warn("%s: undeliverable postmaster notification discarded",
message->queue_id);
@ -643,11 +673,10 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message)
if (defer_xport_argv == 0)
defer_xport_argv = argv_split(var_defer_xports, " \t\r\n,");
for (cpp = defer_xport_argv->argv; *cpp; cpp++)
if (strcasecmp(*cpp, STR(reply.transport)) == 0)
if (strcmp(*cpp, STR(reply.transport)) == 0)
break;
if (*cpp) {
qmgr_defer_recipient(message, recipient->address,
"deferred transport");
qmgr_defer_recipient(message, recipient, "deferred transport");
continue;
}
}
@ -676,7 +705,7 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message)
* This transport is dead. Defer delivery to this recipient.
*/
if ((transport->flags & QMGR_TRANSPORT_STAT_DEAD) != 0) {
qmgr_defer_recipient(message, recipient->address, transport->reason);
qmgr_defer_recipient(message, recipient, transport->reason);
continue;
}
@ -693,27 +722,10 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message)
* This queue is dead. Defer delivery to this recipient.
*/
if (queue->window == 0) {
qmgr_defer_recipient(message, recipient->address, queue->reason);
qmgr_defer_recipient(message, recipient, queue->reason);
continue;
}
/*
* This queue is a hog. Defer this recipient until the queue drains.
* When a site accumulates a large backlog, Postfix will deliver a
* little chunk and hammer the disk as it defers the remainder of the
* backlog and searches the deferred queue for deliverable mail.
*/
if (var_qmgr_hog < 100) {
if (queue->todo_refcount + queue->busy_refcount
> (var_qmgr_hog / 100.0)
* (qmgr_recipient_count > 0.8 * var_qmgr_rcpt_limit ?
qmgr_message_count : var_qmgr_active_limit)) {
qmgr_defer_recipient(message, recipient->address,
"site destination queue overflow");
continue;
}
}
/*
* This queue is alive. Bind this recipient to this queue instance.
*/
@ -749,7 +761,8 @@ static void qmgr_message_assign(QMGR_MESSAGE *message)
entry->rcpt_list.len)) {
entry = qmgr_entry_create(queue, message);
}
qmgr_rcpt_list_add(&entry->rcpt_list, recipient->offset, recipient->address);
qmgr_rcpt_list_add(&entry->rcpt_list, recipient->offset,
recipient->orig_rcpt, recipient->address);
qmgr_recipient_count++;
}
}
@ -767,6 +780,8 @@ void qmgr_message_free(QMGR_MESSAGE *message)
msg_panic("qmgr_message_free: queue file is open");
myfree(message->queue_id);
myfree(message->queue_name);
if (message->encoding)
myfree(message->encoding);
if (message->sender)
myfree(message->sender);
if (message->verp_delims)

View File

@ -268,6 +268,19 @@ static DNS_RR *smtp_find_self(DNS_RR *addr_list)
}
}
/*
* Find out if this mail system has a proxy listening on this address.
*/
self = proxy_inet_addr_list();
for (addr = addr_list; addr; addr = addr->next) {
for (i = 0; i < self->used; i++)
if (INADDRP(addr->data)->s_addr == self->addrs[i].s_addr) {
if (msg_verbose)
msg_info("%s: found at pref %d", myname, addr->pref);
return (addr);
}
}
/*
* Didn't find myself.
*/

View File

@ -111,6 +111,7 @@
#include <iostuff.h>
#include <timed_connect.h>
#include <stringops.h>
#include <host_port.h>
/* Global library. */
@ -233,7 +234,7 @@ static SMTP_SESSION *smtp_connect_addr(DNS_RR *addr, unsigned port,
*/
stream = vstream_fdopen(sock, O_RDWR);
if ((ch = VSTREAM_GETC(stream)) == VSTREAM_EOF) {
vstring_sprintf(why, "connect to %s[%s]: server dropped connection",
vstring_sprintf(why, "connect to %s[%s]: server dropped connection without sending the initial greeting",
addr->name, inet_ntoa(sin.sin_addr));
smtp_errno = SMTP_RETRY;
vstream_fclose(stream);
@ -325,49 +326,21 @@ static char *smtp_parse_destination(char *destination, char *def_service,
char **hostp, unsigned *portp)
{
char *buf = mystrdup(destination);
char *host = buf;
char *service;
struct servent *sp;
char *protocol = "tcp"; /* XXX configurable? */
unsigned port;
char *cruft;
const char *err;
if (msg_verbose)
msg_info("smtp_parse_destination: %s %s", destination, def_service);
/*
* Strip quoting. We're working with a copy of the destination argument
* so the stripping can be destructive.
* Parse the host/port information. We're working with a copy of the
* destination argument so the parsing can be destructive.
*/
if (*host == '[') {
host++;
cruft = split_at(host, ']');
} else
cruft = 0;
/*
* Separate host and service information, or use the default service
* specified by the caller. XXX the ":" character is used in the IPV6
* address notation, so we will have to deprecate the use of [host:port]
* in favor of [host]:port.
*/
if (cruft && *cruft) {
if ((service = split_at_right(cruft, ':')) == 0)
service = def_service;
} else {
if ((service = split_at_right(host, ':')) == 0)
service = def_service;
#if 0
else if (cruft) {
msg_warn("old-style address form: %s", destination);
msg_warn("support for [host:port] forms will go away");
msg_warn("specify [host]:port instead");
}
#endif
}
if (*service == 0)
msg_fatal("empty service name: %s", destination);
*hostp = host;
if ((err = host_port(buf, hostp, &service, def_service)) != 0)
msg_fatal("%s in SMTP server description: %s", err, destination);
/*
* Convert service to port number, network byte order.
@ -391,9 +364,9 @@ SMTP_SESSION *smtp_connect(char *destination, VSTRING *why)
char *host;
unsigned port;
char *def_service = "smtp"; /* XXX configurable? */
char *save;
ARGV *sites;
char *dest;
char *cp;
char **cpp;
int found_myself = 0;
/*
@ -401,9 +374,11 @@ SMTP_SESSION *smtp_connect(char *destination, VSTRING *why)
* to the optional fall-back relays. Each can be a list of destinations
* by itself, with domain, host, [], numerical address, and port.
*/
cp = save = concatenate(destination, " ", var_fallback_relay, (char *) 0);
sites = argv_alloc(1);
argv_add(sites, destination, (char *) 0);
argv_split_append(sites, var_fallback_relay, ", \t\r\n");
while ((dest = mystrtok(&cp, ", \t\r\n")) != 0) {
for (cpp = sites->argv; (dest = *cpp) != 0; cpp++) {
/*
* Parse the destination. Default is to use the SMTP port.
@ -448,8 +423,8 @@ SMTP_SESSION *smtp_connect(char *destination, VSTRING *why)
VAR_RELAYHOST, var_relayhost);
smtp_errno = SMTP_RETRY;
}
if (*var_fallback_relay) {
msg_warn("%s configuration problem: %s",
if (cpp > sites->argv && sites->argc > 1) {
msg_warn("%s problem: %s",
VAR_FALLBACK_RELAY, var_fallback_relay);
smtp_errno = SMTP_RETRY;
}
@ -458,6 +433,6 @@ SMTP_SESSION *smtp_connect(char *destination, VSTRING *why)
/*
* Cleanup.
*/
myfree(save);
argv_free(sites);
return (session);
}

View File

@ -34,11 +34,11 @@
/* RFC 1123 (Host requirements)
/* RFC 1652 (8bit-MIME transport)
/* RFC 1869 (SMTP service extensions)
/* RFC 1854 (SMTP Pipelining)
/* RFC 1870 (Message Size Declaration)
/* RFC 1985 (ETRN command)
/* RFC 2554 (AUTH command)
/* RFC 2821 (SMTP protocol)
/* RFC 2920 (SMTP Pipelining)
/* DIAGNOSTICS
/* Problems and transactions are logged to \fBsyslogd\fR(8).
/*
@ -102,9 +102,9 @@
/* .fi
/* .IP \fBalways_bcc\fR
/* Address to send a copy of each message that enters the system.
/* .IP \fBcommand_directory\fR
/* Location of Postfix support commands (default:
/* \fB$program_directory\fR).
/* .IP \fBauthorized_verp_clients\fR
/* Hostnames, domain names and/or addresses of clients that are
/* authorized to use the XVERP extension.
/* .IP \fBdebug_peer_level\fR
/* Increment in verbose logging level when a remote host matches a
/* pattern in the \fBdebug_peer_list\fR parameter.
@ -119,10 +119,6 @@
/* Recipient of protocol/policy/resource/software error notices.
/* .IP \fBhopcount_limit\fR
/* Limit the number of \fBReceived:\fR message headers.
/* .IP \fBlocal_recipient_maps\fR
/* List of maps with user names that are local to \fB$myorigin\fR
/* or \fB$inet_interfaces\fR. If this parameter is defined,
/* then the SMTP server rejects mail for unknown local users.
/* .IP \fBnotify_classes\fR
/* List of error classes. Of special interest are:
/* .RS
@ -136,6 +132,9 @@
/* .RE
/* .IP \fBsmtpd_banner\fR
/* Text that follows the \fB220\fR status code in the SMTP greeting banner.
/* .IP \fBsmtpd_expansion_filter\fR
/* Controls what characters are allowed in $name expansion of
/* rbl template responses and other text.
/* .IP \fBsmtpd_recipient_limit\fR
/* Restrict the number of recipients that the SMTP server accepts
/* per message delivery.
@ -147,6 +146,30 @@
/* This can be useful for testing purposes.
/* .IP \fBverp_delimiter_filter\fR
/* The characters that Postfix accepts as VERP delimiter characters.
/* .SH "Known versus unknown recipients"
/* .ad
/* .fi
/* .IP \fBshow_user_unknown_table_name\fR
/* Whether or not to reveal the table name in the "User unknown"
/* responses. The extra detail makes trouble shooting easier
/* but also reveals information that is nobody elses business.
/* .IP \fBunknown_local_recipient_reject_code\fR
/* The response code when a client specifies a recipient whose domain
/* matches \fB$mydestination\fR or \fB$inet_interfaces\fR, while
/* \fB$local_recipient_maps\fR is non-empty and does not list
/* the recipient address or address local-part.
/* .IP \fBunknown_relay_recipient_reject_code\fR
/* The response code when a client specifies a recipient whose domain
/* matches \fB$relay_domains\fR, while \fB$relay_recipient_maps\fR
/* is non-empty and does not list the recipient address.
/* .IP \fBunknown_virtual_alias_reject_code\fR
/* The response code when a client specifies a recipient whose domain
/* matches \fB$virtual_alias_domains\fR, while the recipient is not
/* listed in \fB$virtual_alias_maps\fR.
/* .IP \fBunknown_virtual_mailbox_reject_code\fR
/* The response code when a client specifies a recipient whose domain
/* matches \fB$virtual_mailbox_domains\fR, while the recipient is not
/* listed in \fB$virtual_mailbox_maps\fR.
/* .SH "Resource controls"
/* .ad
/* .fi
@ -199,6 +222,9 @@
/* .IP \fBsmtpd_etrn_restrictions\fR
/* Restrict what domain names can be used in \fBETRN\fR commands,
/* and what clients may issue \fBETRN\fR commands.
/* .IP \fBsmtpd_data_restrictions\fR
/* Restrictions on the \fBDATA\fR command. Currently, the only restriction
/* that makes sense here is \fBreject_unauth_pipelining\fR.
/* .IP \fBallow_untrusted_routing\fR
/* Allow untrusted clients to specify addresses with sender-specified
/* routing. Enabling this opens up nasty relay loopholes involving
@ -210,41 +236,56 @@
/* .IP \fBsmtpd_null_access_lookup_key\fR
/* The lookup key to be used in SMTPD access tables instead of the
/* null sender address. A null sender address cannot be looked up.
/* .IP \fBmaps_rbl_domains\fR
/* .IP "\fBmaps_rbl_domains\fR (deprecated)"
/* List of DNS domains that publish the addresses of blacklisted
/* hosts.
/* hosts. This is used with the deprecated \fBreject_maps_rbl\fR
/* restriction.
/* .IP \fBpermit_mx_backup_networks\fR
/* Only domains whose primary MX hosts match the listed networks
/* are eligible for the \fBpermit_mx_backup\fR feature.
/* .IP \fBrelay_domains\fR
/* Restrict what domains or networks this mail system will relay
/* mail from or to.
/* Restrict what domains this mail system will relay
/* mail to. The domains are routed to the delivery agent
/* specified with the \fBrelay_transport\fR setting.
/* .SH "UCE control responses"
/* .ad
/* .fi
/* .IP \fBaccess_map_reject_code\fR
/* Server response when a client violates an access database restriction.
/* Response code when a client violates an access database restriction.
/* .IP \fBdefault_rbl_reply\fR
/* Default template reply when a request is RBL blacklisted.
/* This template is used by the \fBreject_rbl_*\fR and
/* \fBreject_rhsbl_*\fR restrictions. See also:
/* \fBrbl_reply_maps\fR and \fBsmtpd_expansion_filter\fR.
/* .IP \fBdefer_code\fR
/* Response code when a client request is rejected by the \fBdefer\fR
/* restriction.
/* .IP \fBinvalid_hostname_reject_code\fR
/* Server response when a client violates the \fBreject_invalid_hostname\fR
/* Response code when a client violates the \fBreject_invalid_hostname\fR
/* restriction.
/* .IP \fBmaps_rbl_reject_code\fR
/* Server response when a client violates the \fBmaps_rbl_domains\fR
/* restriction.
/* Response code when a request is RBL blacklisted.
/* .IP \fBrbl_reply_maps\fR
/* Table with template responses for RBL blacklisted requests, indexed by
/* RBL domain name. These templates are used by the \fBreject_rbl_*\fR
/* and \fBreject_rhsbl_*\fR restrictions. See also:
/* \fBdefault_rbl_reply\fR and \fBsmtpd_expansion_filter\fR.
/* .IP \fBreject_code\fR
/* Response code when the client matches a \fBreject\fR restriction.
/* .IP \fBrelay_domains_reject_code\fR
/* Server response when a client attempts to violate the mail relay
/* Response code when a client attempts to violate the mail relay
/* policy.
/* .IP \fBunknown_address_reject_code\fR
/* Server response when a client violates the \fBreject_unknown_address\fR
/* Response code when a client violates the \fBreject_unknown_address\fR
/* restriction.
/* .IP \fBunknown_client_reject_code\fR
/* Server response when a client without address to name mapping
/* violates the \fBreject_unknown_clients\fR restriction.
/* Response code when a client without address to name mapping
/* violates the \fBreject_unknown_client\fR restriction.
/* .IP \fBunknown_hostname_reject_code\fR
/* Server response when a client violates the \fBreject_unknown_hostname\fR
/* Response code when a client violates the \fBreject_unknown_hostname\fR
/* restriction.
/* SEE ALSO
/* trivial-rewrite(8) address resolver
/* cleanup(8) message canonicalization
/* master(8) process manager
/* syslogd(8) system logging
@ -312,6 +353,9 @@
#include <tok822.h>
#include <verp_sender.h>
#include <string_list.h>
#include <quote_822_local.h>
#include <lex_822.h>
#include <namadr_list.h>
/* Single-threaded server skeleton. */
@ -346,6 +390,7 @@ char *var_helo_checks;
char *var_mail_checks;
char *var_rcpt_checks;
char *var_etrn_checks;
char *var_data_checks;
int var_unk_client_code;
int var_bad_name_code;
int var_unk_name_code;
@ -354,8 +399,10 @@ int var_relay_code;
int var_maps_rbl_code;
int var_access_map_code;
char *var_maps_rbl_domains;
char *var_rbl_reply_maps;
int var_helo_required;
int var_reject_code;
int var_defer_code;
int var_smtpd_err_sleep;
int var_non_fqdn_code;
char *var_always_bcc;
@ -366,9 +413,8 @@ int var_strict_rfc821_env;
bool var_disable_vrfy_cmd;
char *var_canonical_maps;
char *var_rcpt_canon_maps;
char *var_virtual_maps;
char *var_virt_alias_maps;
char *var_virt_mailbox_maps;
char *var_relocated_maps;
char *var_alias_maps;
char *var_local_rcpt_maps;
bool var_allow_untrust_route;
@ -383,6 +429,15 @@ char *var_smtpd_snd_auth_maps;
char *var_smtpd_noop_cmds;
char *var_smtpd_null_key;
int var_smtpd_hist_thrsh;
char *var_smtpd_exp_filter;
char *var_def_rbl_reply;
char *var_relay_rcpt_maps;
int var_local_rcpt_code;
int var_virt_alias_code;
int var_virt_mailbox_code;
int var_relay_rcpt_code;
char *var_verp_clients;
int var_show_unk_rcpt_table;
/*
* Silly little macros.
@ -396,6 +451,8 @@ int var_smtpd_hist_thrsh;
#define VERP_CMD "XVERP"
#define VERP_CMD_LEN 5
static NAMADR_LIST *verp_clients;
/*
* Forward declarations.
*/
@ -428,8 +485,6 @@ static int helo_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
smtpd_chat_reply(state, "501 Syntax: HELO hostname");
return (-1);
}
if (state->helo_name != 0)
helo_reset(state);
if (argc > 2)
collapse_args(argc - 1, argv + 1);
if (SMTPD_STAND_ALONE(state) == 0
@ -438,8 +493,14 @@ static int helo_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
smtpd_chat_reply(state, "%s", err);
return (-1);
}
if (state->helo_name != 0)
helo_reset(state);
chat_reset(state, var_smtpd_hist_thrsh);
mail_reset(state);
rcpt_reset(state);
state->helo_name = mystrdup(printable(argv[1].strval, '?'));
state->protocol = "SMTP";
if (strcmp(state->protocol, MAIL_PROTO_ESMTP) != 0)
state->protocol = MAIL_PROTO_SMTP;
smtpd_chat_reply(state, "250 %s", var_myhostname);
return (0);
}
@ -460,13 +521,6 @@ static int ehlo_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
smtpd_chat_reply(state, "501 Syntax: EHLO hostname");
return (-1);
}
if (state->helo_name != 0)
helo_reset(state);
#ifndef RFC821_SYNTAX
chat_reset(state, var_smtpd_hist_thrsh);
mail_reset(state);
rcpt_reset(state);
#endif
if (argc > 2)
collapse_args(argc - 1, argv + 1);
if (SMTPD_STAND_ALONE(state) == 0
@ -475,8 +529,13 @@ static int ehlo_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
smtpd_chat_reply(state, "%s", err);
return (-1);
}
if (state->helo_name != 0)
helo_reset(state);
chat_reset(state, var_smtpd_hist_thrsh);
mail_reset(state);
rcpt_reset(state);
state->helo_name = mystrdup(printable(argv[1].strval, '?'));
state->protocol = "ESMTP";
state->protocol = MAIL_PROTO_ESMTP;
smtpd_chat_reply(state, "250-%s", var_myhostname);
smtpd_chat_reply(state, "250-PIPELINING");
if (var_message_limit)
@ -494,7 +553,8 @@ static int ehlo_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
smtpd_chat_reply(state, "250-AUTH=%s", state->sasl_mechanism_list);
}
#endif
smtpd_chat_reply(state, "250-%s", VERP_CMD);
if (namadr_list_match(verp_clients, state->name, state->addr))
smtpd_chat_reply(state, "250-%s", VERP_CMD);
smtpd_chat_reply(state, "250 8BITMIME");
return (0);
}
@ -532,13 +592,13 @@ static void mail_open_stream(SMTPD_STATE *state)
*/
if (SMTPD_STAND_ALONE(state) == 0) {
state->dest = mail_stream_service(MAIL_CLASS_PUBLIC,
MAIL_SERVICE_CLEANUP);
var_cleanup_service);
if (state->dest == 0
|| attr_print(state->dest->stream, ATTR_FLAG_NONE,
ATTR_TYPE_NUM, MAIL_ATTR_FLAGS, CLEANUP_FLAG_FILTER,
ATTR_TYPE_END) != 0)
msg_fatal("unable to connect to the %s %s service",
MAIL_CLASS_PUBLIC, MAIL_SERVICE_CLEANUP);
MAIL_CLASS_PUBLIC, var_cleanup_service);
}
/*
@ -663,6 +723,7 @@ static int mail_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
int narg;
char *arg;
char *verp_delims = 0;
char *encoding = 0;
state->msg_size = 0;
@ -703,10 +764,11 @@ static int mail_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
}
for (narg = 3; narg < argc; narg++) {
arg = argv[narg].strval;
if (strcasecmp(arg, "BODY=8BITMIME") == 0
|| strcasecmp(arg, "BODY=7BIT") == 0) {
/* void */ ;
} else if (strncasecmp(arg, "SIZE=", 5) == 0) {
if (strcasecmp(arg, "BODY=8BITMIME") == 0) { /* RFC 1652 */
encoding = MAIL_ATTR_ENC_8BIT;
} else if (strcasecmp(arg, "BODY=7BIT") == 0) { /* RFC 1652 */
encoding = MAIL_ATTR_ENC_7BIT;
} else if (strncasecmp(arg, "SIZE=", 5) == 0) { /* RFC 1870 */
/* Reject non-numeric size. */
if (!alldig(arg + 5)) {
state->error_mask |= MAIL_ERROR_PROTOCOL;
@ -726,16 +788,18 @@ static int mail_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
return (-1);
}
#endif
} else if (strcasecmp(arg, VERP_CMD) == 0) {
verp_delims = var_verp_delims;
} else if (strncasecmp(arg, VERP_CMD, VERP_CMD_LEN) == 0
&& arg[VERP_CMD_LEN] == '=') {
verp_delims = arg + VERP_CMD_LEN + 1;
if (verp_delims_verify(verp_delims) != 0) {
state->error_mask |= MAIL_ERROR_PROTOCOL;
smtpd_chat_reply(state, "501 %s needs two characters from %s",
VERP_CMD, var_verp_filter);
return (-1);
} else if (namadr_list_match(verp_clients, state->name, state->addr)) {
if (strcasecmp(arg, VERP_CMD) == 0) {
verp_delims = var_verp_delims;
} else if (strncasecmp(arg, VERP_CMD, VERP_CMD_LEN) == 0
&& arg[VERP_CMD_LEN] == '=') {
verp_delims = arg + VERP_CMD_LEN + 1;
if (verp_delims_verify(verp_delims) != 0) {
state->error_mask |= MAIL_ERROR_PROTOCOL;
smtpd_chat_reply(state, "501 %s needs two characters from %s",
VERP_CMD, var_verp_filter);
return (-1);
}
}
} else {
state->error_mask |= MAIL_ERROR_PROTOCOL;
@ -754,8 +818,7 @@ static int mail_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
smtpd_chat_reply(state, "%s", err);
return (-1);
}
if ((SMTPD_STAND_ALONE(state) || var_smtpd_delay_reject == 0)
&& (err = smtpd_check_size(state, state->msg_size)) != 0) {
if ((err = smtpd_check_size(state, state->msg_size)) != 0) {
smtpd_chat_reply(state, "%s", err);
return (-1);
}
@ -779,6 +842,22 @@ static int mail_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *argv)
if (*var_filter_xport)
rec_fprintf(state->cleanup, REC_TYPE_FILT, "%s", var_filter_xport);
rec_fputs(state->cleanup, REC_TYPE_FROM, argv[2].strval);
if (encoding != 0)
rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
MAIL_ATTR_ENCODING, encoding);
if (SMTPD_STAND_ALONE(state) == 0) {
rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
MAIL_ATTR_CLIENT_NAME, state->name);
rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
MAIL_ATTR_CLIENT_ADDR, state->addr);
rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
MAIL_ATTR_ORIGIN, state->namaddr);
if (state->helo_name != 0)
rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
MAIL_ATTR_HELO_NAME, state->helo_name);
rec_fprintf(state->cleanup, REC_TYPE_ATTR, "%s=%s",
MAIL_ATTR_PROTO_NAME, state->protocol);
}
if (verp_delims)
rec_fputs(state->cleanup, REC_TYPE_VERP, verp_delims);
state->sender = mystrdup(argv[2].strval);
@ -904,6 +983,7 @@ static void rcpt_reset(SMTPD_STATE *state)
static int data_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv)
{
char *err;
char *start;
int len;
int curr_rec_type;
@ -930,6 +1010,10 @@ static int data_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv)
smtpd_chat_reply(state, "501 Syntax: DATA");
return (-1);
}
if (SMTPD_STAND_ALONE(state) == 0 && (err = smtpd_check_data(state)) != 0) {
smtpd_chat_reply(state, "%s", err);
return (-1);
}
/*
* Terminate the message envelope segment. Start the message content
@ -948,9 +1032,9 @@ static int data_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv)
"\tby %s (%s) with %s id %s",
var_myhostname, var_mail_name,
state->protocol, state->queue_id);
/* XXX Should RFC 822 externalize recipient address */
quote_822_local(state->buffer, state->recipient);
rec_fprintf(state->cleanup, REC_TYPE_NORM,
"\tfor <%s>; %s", state->recipient, mail_date(state->time));
"\tfor <%s>; %s", STR(state->buffer), mail_date(state->time));
} else {
rec_fprintf(state->cleanup, REC_TYPE_NORM,
"\tby %s (%s) with %s",
@ -959,9 +1043,9 @@ static int data_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv)
"\tid %s; %s", state->queue_id, mail_date(state->time));
}
#ifdef RECEIVED_ENVELOPE_FROM
/* XXX Should RFC 822 externalize sender address */
quote_822_local(state->buffer, state->sender);
rec_fprintf(state->cleanup, REC_TYPE_NORM,
"\t(envelope-from %s)", state->sender);
"\t(envelope-from %s)", STR(state->buffer));
#endif
smtpd_chat_reply(state, "354 End data with <CR><LF>.<CR><LF>");
@ -994,7 +1078,7 @@ static int data_cmd(SMTPD_STATE *state, int argc, SMTPD_TOKEN *unused_argv)
continue;
}
first = 0;
if (len > 0 && ISSPACE(start[0]))
if (len > 0 && IS_SPACE_TAB(start[0]))
rec_put(state->cleanup, REC_TYPE_NORM, "", 0);
}
if (prev_rec_type != REC_TYPE_CONT
@ -1323,6 +1407,8 @@ static SMTPD_CMD smtpd_cmd_table[] = {
"ETRN", etrn_cmd, SMTPD_CMD_FLAG_LIMIT,
"QUIT", quit_cmd, 0,
"Received:", 0, SMTPD_CMD_FLAG_HEADER,
"Reply-To:", 0, SMTPD_CMD_FLAG_HEADER,
"Message-ID:", 0, SMTPD_CMD_FLAG_HEADER,
"Subject:", 0, SMTPD_CMD_FLAG_HEADER,
"From:", 0, SMTPD_CMD_FLAG_HEADER,
0,
@ -1375,6 +1461,13 @@ static void smtpd_proto(SMTPD_STATE *state)
break;
case 0:
if (var_smtpd_delay_reject == 0
&& (state->access_denied = smtpd_check_client(state)) != 0) {
smtpd_chat_reply(state, "%s", state->access_denied);
} else {
smtpd_chat_reply(state, "220 %s", var_smtpd_banner);
}
for (;;) {
if (state->error_count > var_smtpd_hard_erlim) {
state->reason = "too many errors";
@ -1407,8 +1500,8 @@ static void smtpd_proto(SMTPD_STATE *state)
continue;
}
if (cmdp->flags & SMTPD_CMD_FLAG_HEADER) {
msg_warn("%s sent message header instead of SMTP command: %.100s",
state->namaddr, vstring_str(state->buffer));
msg_warn("%s sent %s header instead of SMTP command: %.100s",
state->namaddr, cmdp->name, vstring_str(state->buffer));
smtpd_chat_reply(state, "221 Error: I can break rules, too. Goodbye.");
break;
}
@ -1476,24 +1569,13 @@ static void smtpd_service(VSTREAM *stream, char *unused_service, char **argv)
* machines.
*/
smtpd_state_init(&state, stream);
msg_info("connect from %s[%s]", state.name, state.addr);
/*
* See if we need to turn on verbose logging for this client.
*/
debug_peer_check(state.name, state.addr);
/*
* See if we want to talk to this client at all. Then, log the connection
* event.
*/
if (var_smtpd_delay_reject == 0
&& (state.access_denied = smtpd_check_client(&state)) != 0) {
smtpd_chat_reply(&state, "%s", state.access_denied);
} else {
smtpd_chat_reply(&state, "220 %s", var_smtpd_banner);
msg_info("connect from %s[%s]", state.name, state.addr);
}
/*
* Provide the SMTP service.
*/
@ -1528,6 +1610,7 @@ static void pre_jail_init(char *unused_name, char **unused_argv)
* case they specify a filename pattern.
*/
smtpd_noop_cmds = string_list_init(MATCH_FLAG_NONE, var_smtpd_noop_cmds);
verp_clients = namadr_list_init(MATCH_FLAG_NONE, var_verp_clients);
smtpd_check_init();
debug_peer_init();
@ -1557,9 +1640,14 @@ int main(int argc, char **argv)
VAR_MAPS_RBL_CODE, DEF_MAPS_RBL_CODE, &var_maps_rbl_code, 0, 0,
VAR_ACCESS_MAP_CODE, DEF_ACCESS_MAP_CODE, &var_access_map_code, 0, 0,
VAR_REJECT_CODE, DEF_REJECT_CODE, &var_reject_code, 0, 0,
VAR_DEFER_CODE, DEF_DEFER_CODE, &var_defer_code, 0, 0,
VAR_NON_FQDN_CODE, DEF_NON_FQDN_CODE, &var_non_fqdn_code, 0, 0,
VAR_SMTPD_JUNK_CMD, DEF_SMTPD_JUNK_CMD, &var_smtpd_junk_cmd_limit, 1, 0,
VAR_SMTPD_HIST_THRSH, DEF_SMTPD_HIST_THRSH, &var_smtpd_hist_thrsh, 1, 0,
VAR_LOCAL_RCPT_CODE, DEF_LOCAL_RCPT_CODE, &var_local_rcpt_code, 0, 0,
VAR_VIRT_ALIAS_CODE, DEF_VIRT_ALIAS_CODE, &var_virt_alias_code, 0, 0,
VAR_VIRT_MAILBOX_CODE, DEF_VIRT_MAILBOX_CODE, &var_virt_mailbox_code, 0, 0,
VAR_RELAY_RCPT_CODE, DEF_RELAY_RCPT_CODE, &var_relay_rcpt_code, 0, 0,
0,
};
static CONFIG_TIME_TABLE time_table[] = {
@ -1575,6 +1663,7 @@ int main(int argc, char **argv)
VAR_ALLOW_UNTRUST_ROUTE, DEF_ALLOW_UNTRUST_ROUTE, &var_allow_untrust_route,
VAR_SMTPD_SASL_ENABLE, DEF_SMTPD_SASL_ENABLE, &var_smtpd_sasl_enable,
VAR_BROKEN_AUTH_CLNTS, DEF_BROKEN_AUTH_CLNTS, &var_broken_auth_clients,
VAR_SHOW_UNK_RCPT_TABLE, DEF_SHOW_UNK_RCPT_TABLE, &var_show_unk_rcpt_table,
0,
};
static CONFIG_STR_TABLE str_table[] = {
@ -1585,24 +1674,32 @@ int main(int argc, char **argv)
VAR_MAIL_CHECKS, DEF_MAIL_CHECKS, &var_mail_checks, 0, 0,
VAR_RCPT_CHECKS, DEF_RCPT_CHECKS, &var_rcpt_checks, 0, 0,
VAR_ETRN_CHECKS, DEF_ETRN_CHECKS, &var_etrn_checks, 0, 0,
VAR_DATA_CHECKS, DEF_DATA_CHECKS, &var_data_checks, 0, 0,
VAR_MAPS_RBL_DOMAINS, DEF_MAPS_RBL_DOMAINS, &var_maps_rbl_domains, 0, 0,
VAR_RBL_REPLY_MAPS, DEF_RBL_REPLY_MAPS, &var_rbl_reply_maps, 0, 0,
VAR_ALWAYS_BCC, DEF_ALWAYS_BCC, &var_always_bcc, 0, 0,
VAR_ERROR_RCPT, DEF_ERROR_RCPT, &var_error_rcpt, 1, 0,
VAR_REST_CLASSES, DEF_REST_CLASSES, &var_rest_classes, 0, 0,
VAR_CANONICAL_MAPS, DEF_CANONICAL_MAPS, &var_canonical_maps, 0, 0,
VAR_RCPT_CANON_MAPS, DEF_RCPT_CANON_MAPS, &var_rcpt_canon_maps, 0, 0,
VAR_VIRTUAL_MAPS, DEF_VIRTUAL_MAPS, &var_virtual_maps, 0, 0,
VAR_VIRT_ALIAS_MAPS, DEF_VIRT_ALIAS_MAPS, &var_virt_alias_maps, 0, 0,
VAR_VIRT_MAILBOX_MAPS, DEF_VIRT_MAILBOX_MAPS, &var_virt_mailbox_maps, 0, 0,
VAR_RELOCATED_MAPS, DEF_RELOCATED_MAPS, &var_relocated_maps, 0, 0,
VAR_ALIAS_MAPS, DEF_ALIAS_MAPS, &var_alias_maps, 0, 0,
VAR_LOCAL_RCPT_MAPS, DEF_LOCAL_RCPT_MAPS, &var_local_rcpt_maps, 0, 0,
VAR_SMTPD_SASL_OPTS, DEF_SMTPD_SASL_OPTS, &var_smtpd_sasl_opts, 0, 0,
VAR_SMTPD_SASL_REALM, DEF_SMTPD_SASL_REALM, &var_smtpd_sasl_realm, 1, 0,
VAR_SMTPD_SASL_REALM, DEF_SMTPD_SASL_REALM, &var_smtpd_sasl_realm, 0, 0,
VAR_FILTER_XPORT, DEF_FILTER_XPORT, &var_filter_xport, 0, 0,
VAR_PERM_MX_NETWORKS, DEF_PERM_MX_NETWORKS, &var_perm_mx_networks, 0, 0,
VAR_SMTPD_SND_AUTH_MAPS, DEF_SMTPD_SND_AUTH_MAPS, &var_smtpd_snd_auth_maps, 0, 0,
VAR_SMTPD_NOOP_CMDS, DEF_SMTPD_NOOP_CMDS, &var_smtpd_noop_cmds, 0, 0,
VAR_SMTPD_NULL_KEY, DEF_SMTPD_NULL_KEY, &var_smtpd_null_key, 0, 0,
VAR_RELAY_RCPT_MAPS, DEF_RELAY_RCPT_MAPS, &var_relay_rcpt_maps, 0, 0,
VAR_VERP_CLIENTS, DEF_VERP_CLIENTS, &var_verp_clients, 0, 0,
0,
};
static CONFIG_RAW_TABLE raw_table[] = {
VAR_SMTPD_EXP_FILTER, DEF_SMTPD_EXP_FILTER, &var_smtpd_exp_filter, 1, 0,
VAR_DEF_RBL_REPLY, DEF_DEF_RBL_REPLY, &var_def_rbl_reply, 1, 0,
0,
};
@ -1612,6 +1709,7 @@ int main(int argc, char **argv)
single_server_main(argc, argv, smtpd_service,
MAIL_SERVER_INT_TABLE, int_table,
MAIL_SERVER_STR_TABLE, str_table,
MAIL_SERVER_RAW_TABLE, raw_table,
MAIL_SERVER_BOOL_TABLE, bool_table,
MAIL_SERVER_TIME_TABLE, time_table,
MAIL_SERVER_PRE_INIT, pre_jail_init,

File diff suppressed because it is too large Load Diff

View File

@ -107,6 +107,11 @@ void smtpd_peer_init(SMTPD_STATE *state)
struct hostent *hp;
int i;
/*
* Avoid suprious complaints from Purify on Solaris.
*/
memset((char *) &sin, 0, len);
/*
* Look up the peer address information.
*/
@ -134,6 +139,11 @@ void smtpd_peer_init(SMTPD_STATE *state)
if (hp == 0) {
state->name = mystrdup("unknown");
state->peer_code = (h_errno == TRY_AGAIN ? 4 : 5);
} else if (valid_hostaddr(hp->h_name, DONT_GRIPE)) {
msg_warn("numeric result %s in address->name lookup for %s",
hp->h_name, state->addr);
state->name = mystrdup("unknown");
state->peer_code = 5;
} else if (!valid_hostname(hp->h_name, DONT_GRIPE)) {
state->name = mystrdup("unknown");
state->peer_code = 5;

View File

@ -26,7 +26,7 @@ SRCS = alldig.c argv.c argv_split.c attr_print0.c attr_print64.c \
unix_connect.c unix_listen.c unix_trigger.c unsafe.c username.c \
valid_hostname.c vbuf.c vbuf_print.c vstream.c vstream_popen.c \
vstring.c vstring_vstream.c watchdog.c writable.c write_buf.c \
write_wait.c strcasecmp.c
write_wait.c strcasecmp.c nvtable.c host_port.c
OBJS = alldig.o argv.o argv_split.o attr_print0.o attr_print64.o \
attr_scan0.o attr_scan64.o base64_code.o basename.o binhash.o \
chroot_uid.o clean_env.o close_on_exec.o concatenate.o ctable.o \
@ -54,7 +54,7 @@ OBJS = alldig.o argv.o argv_split.o attr_print0.o attr_print64.o \
unix_connect.o unix_listen.o unix_trigger.o unsafe.o username.o \
valid_hostname.o vbuf.o vbuf_print.o vstream.o vstream_popen.o \
vstring.o vstring_vstream.o watchdog.o writable.o write_buf.o \
write_wait.o $(STRCASE)
write_wait.o nvtable.o $(STRCASE) host_port.o
HDRS = argv.h attr.h base64_code.h binhash.h chroot_uid.h clean_env.h \
connect.h ctable.h dict.h dict_db.h dict_dbm.h dict_env.h \
dict_ht.h dict_ldap.h dict_mysql.h dict_ni.h dict_nis.h \
@ -71,7 +71,8 @@ HDRS = argv.h attr.h base64_code.h binhash.h chroot_uid.h clean_env.h \
scan_dir.h set_eugid.h set_ugid.h sigdelay.h spawn_command.h \
split_at.h stat_as.h stringops.h sys_defs.h timed_connect.h \
timed_wait.h trigger.h username.h valid_hostname.h vbuf.h \
vbuf_print.h vstream.h vstring.h vstring_vstream.h watchdog.h
vbuf_print.h vstream.h vstring.h vstring_vstream.h watchdog.h \
nvtable.h host_port.h
TESTSRC = fifo_open.c fifo_rdwr_bug.c fifo_rdonly_bug.c select_bug.c \
stream_test.c dup2_pass_on_exec.c
WARN = -W -Wformat -Wimplicit -Wmissing-prototypes \
@ -89,7 +90,7 @@ TESTPROG= dict_open dup2_pass_on_exec events exec_command fifo_open \
vstring vstring_vstream doze select_bug stream_test mac_expand \
watchdog unescape hex_quote name_mask rand_sleep sane_time ctable \
inet_addr_list attr_print64 attr_scan64 base64_code attr_print0 \
attr_scan0
attr_scan0 host_port
LIB_DIR = ../../lib
INC_DIR = ../../include
@ -208,112 +209,117 @@ fifo_rdonly_bug: fifo_rdonly_bug.c $(LIB)
select_bug: select_bug.c $(LIB)
$(CC) $(CFLAGS) -o $@ $@.c $(LIB) $(SYSLIBS)
translit: $(LIB) $@.o
translit: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
fsspace: $(LIB) $@.o
fsspace: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
exec_command: $(LIB) $@.o
exec_command: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
make_dirs: $(LIB) $@.o
make_dirs: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
mac_parse: $(LIB) $@.o
mac_parse: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
vstream_popen: $(LIB) $@.o
vstream_popen: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
fifo_trigger: $(LIB) $@.o
fifo_trigger: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
doze: $(LIB) $@.o
doze: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
mac_expand: $(LIB) $@.o
mac_expand: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
watchdog: $(LIB) $@.o
watchdog: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
unescape: $(LIB) $@.o
unescape: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
hex_quote: $(LIB) $@.o
hex_quote: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
name_mask: $(LIB) $@.o
name_mask: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
rand_sleep: $(LIB) $@.o
rand_sleep: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
sane_time: $(LIB) $@.o
sane_time: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
ctable: $(LIB) $@.o
ctable: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
inet_addr_list: $(LIB) $@.o
inet_addr_list: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
attr_print64: $(LIB) $@.o
attr_print64: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
attr_scan64: $(LIB) $@.o
attr_scan64: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
base64_code: $(LIB) $@.o
base64_code: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
attr_print0: $(LIB) $@.o
attr_print0: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
attr_scan0: $(LIB) $@.o
attr_scan0: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
host_port: $(LIB)
mv $@.o junk
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS)
mv junk $@.o
@ -331,7 +337,7 @@ stream_test: stream_test.c $(LIB)
tests: valid_hostname_test mac_expand_test dict_test unescape_test \
hex_quote_test ctable_test inet_addr_list_test base64_code_test \
attr_scan64_test attr_scan0_test
attr_scan64_test attr_scan0_test dict_pcre_test host_port_test
valid_hostname_test: valid_hostname valid_hostname.in valid_hostname.ref
./valid_hostname <valid_hostname.in 2>valid_hostname.tmp
@ -377,18 +383,31 @@ attr_scan0_test: attr_print0 attr_scan0 attr_scan0.ref
diff attr_scan0.ref attr_scan0.tmp
rm -f attr_scan0.tmp
DB_TYPE = `../postconf/postconf -h default_database_type`
dict_test: dict_open testdb dict_test.in dict_test.ref
rm -f testdb.db testdb.dir testdb.pag
../postmap/postmap -N testdb
./dict_open $(DB_TYPE):testdb write < dict_test.in > dict_test.tmp 2>&1
../postmap/postmap -N hash:testdb
./dict_open hash:testdb write < dict_test.in > dict_test.tmp 2>&1
diff dict_test.ref dict_test.tmp
../postmap/postmap -n testdb
./dict_open $(DB_TYPE):testdb write < dict_test.in > dict_test.tmp 2>&1
../postmap/postmap -n hash:testdb
./dict_open hash:testdb write < dict_test.in > dict_test.tmp 2>&1
diff dict_test.ref dict_test.tmp
rm -f testdb.db testdb.dir testdb.pag dict_test.tmp
dict_pcre_test: dict_open dict_pcre.in dict_pcre.map dict_pcre.ref
./dict_open pcre:dict_pcre.map read <dict_pcre.in >dict_pcre.tmp 2>&1
diff dict_pcre.ref dict_pcre.tmp
rm -f dict_pcre.tmp
dict_regexp_test: dict_open dict_regexp.in dict_regexp.map dict_regexp.ref
./dict_open regexp:dict_regexp.map read <dict_regexp.in >dict_regexp.tmp 2>&1
diff dict_regexp.ref dict_regexp.tmp
rm -f dict_regexp.tmp
host_port_test: host_port host_port.in host_port.ref
./host_port <host_port.in >host_port.tmp 2>&1
diff host_port.ref host_port.tmp
rm -f host_port.tmp
# do not edit below this line - it is generated by 'make depend'
alldig.o: alldig.c
alldig.o: sys_defs.h
@ -736,6 +755,15 @@ hex_quote.o: msg.h
hex_quote.o: vstring.h
hex_quote.o: vbuf.h
hex_quote.o: hex_quote.h
host_port.o: host_port.c
host_port.o: sys_defs.h
host_port.o: msg.h
host_port.o: split_at.h
host_port.o: stringops.h
host_port.o: vstring.h
host_port.o: vbuf.h
host_port.o: valid_hostname.h
host_port.o: host_port.h
htable.o: htable.c
htable.o: sys_defs.h
htable.o: mymalloc.h
@ -922,6 +950,11 @@ non_blocking.o: non_blocking.c
non_blocking.o: sys_defs.h
non_blocking.o: msg.h
non_blocking.o: iostuff.h
nvtable.o: nvtable.c
nvtable.o: sys_defs.h
nvtable.o: mymalloc.h
nvtable.o: htable.h
nvtable.o: nvtable.h
open_as.o: open_as.c
open_as.o: sys_defs.h
open_as.o: msg.h

View File

@ -52,11 +52,11 @@
#define STATFS_IN_SYS_MOUNT_H
#define HAS_POSIX_REGEXP
#define HAS_ST_GEN /* struct stat contains inode generation number */
#define DEF_SENDMAIL_PATH "/usr/sbin/sendmail"
#define DEF_MAILQ_PATH "/usr/bin/mailq"
#define DEF_NEWALIAS_PATH "/usr/bin/newaliases"
#define DEF_COMMAND_DIR "/usr/sbin"
#define DEF_DAEMON_DIR "/usr/libexec/postfix"
#define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail"
#define NATIVE_MAILQ_PATH "/usr/bin/mailq"
#define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
#define NATIVE_COMMAND_DIR "/usr/sbin"
#define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
#endif
#if defined(FREEBSD2) || defined(FREEBSD3) || defined(FREEBSD4)
@ -99,11 +99,11 @@
#define PRINTFLIKE(x,y)
#define SCANFLIKE(x,y)
#define HAS_NETINFO
#define DEF_SENDMAIL_PATH "/usr/sbin/sendmail"
#define DEF_MAILQ_PATH "/usr/bin/mailq"
#define DEF_NEWALIAS_PATH "/usr/bin/newaliases"
#define DEF_COMMAND_DIR "/usr/sbin"
#define DEF_DAEMON_DIR "/usr/libexec/postfix"
#define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail"
#define NATIVE_MAILQ_PATH "/usr/bin/mailq"
#define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
#define NATIVE_COMMAND_DIR "/usr/sbin"
#define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
#endif
/*
@ -152,9 +152,9 @@ extern int h_errno;
#define DUP2_DUPS_CLOSE_ON_EXEC
#define MISSING_USLEEP
#define NO_HERRNO
#define DEF_SENDMAIL_PATH "/usr/lib/sendmail"
#define DEF_COMMAND_DIR "/usr/etc"
#define DEF_DAEMON_DIR "/usr/libexec/postfix"
#define NATIVE_SENDMAIL_PATH "/usr/lib/sendmail"
#define NATIVE_COMMAND_DIR "/usr/etc"
#define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
#endif
/*
@ -221,11 +221,11 @@ extern int opterr;
#define STATFS_IN_SYS_VFS_H
#define memmove(d,s,l) bcopy(s,d,l)
#define NO_HERRNO
#define DEF_SENDMAIL_PATH "/usr/lib/sendmail"
#define DEF_MAILQ_PATH "/usr/ucb/mailq"
#define DEF_NEWALIAS_PATH "/usr/ucb/newaliases"
#define DEF_COMMAND_DIR "/usr/etc"
#define DEF_DAEMON_DIR "/usr/libexec/postfix"
#define NATIVE_SENDMAIL_PATH "/usr/lib/sendmail"
#define NATIVE_MAILQ_PATH "/usr/ucb/mailq"
#define NATIVE_NEWALIAS_PATH "/usr/ucb/newaliases"
#define NATIVE_COMMAND_DIR "/usr/etc"
#define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
#endif
/*
@ -260,11 +260,14 @@ extern int opterr;
#define LOCAL_CONNECT stream_connect
#define LOCAL_TRIGGER stream_trigger
#define HAS_VOLATILE_LOCKS
#define DEF_SENDMAIL_PATH "/usr/lib/sendmail"
#define DEF_MAILQ_PATH "/usr/bin/mailq"
#define DEF_NEWALIAS_PATH "/usr/bin/newaliases"
#define DEF_COMMAND_DIR "/usr/sbin"
#define DEF_DAEMON_DIR "/usr/libexec/postfix"
/*
* Allow build environment to override paths.
*/
#define NATIVE_SENDMAIL_PATH "/usr/lib/sendmail"
#define NATIVE_MAILQ_PATH "/usr/bin/mailq"
#define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
#define NATIVE_COMMAND_DIR "/usr/sbin"
#define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
#endif
/*
@ -353,11 +356,11 @@ extern int opterr;
#define USE_STATVFS
#define STATVFS_IN_SYS_STATVFS_H
#define STRCASECMP_IN_STRINGS_H
#define DEF_SENDMAIL_PATH "/usr/lib/sendmail"
#define DEF_MAILQ_PATH "/usr/sbin/mailq"
#define DEF_NEWALIAS_PATH "/usr/sbin/newaliases"
#define DEF_COMMAND_DIR "/usr/sbin"
#define DEF_DAEMON_DIR "/usr/libexec/postfix"
#define NATIVE_SENDMAIL_PATH "/usr/lib/sendmail"
#define NATIVE_MAILQ_PATH "/usr/sbin/mailq"
#define NATIVE_NEWALIAS_PATH "/usr/sbin/newaliases"
#define NATIVE_COMMAND_DIR "/usr/sbin"
#define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
#endif
#ifdef AIX4
@ -392,11 +395,11 @@ extern int seteuid(uid_t);
extern int setegid(gid_t);
extern int initgroups(const char *, int);
#endif
#define DEF_SENDMAIL_PATH "/usr/lib/sendmail"
#define DEF_MAILQ_PATH "/usr/sbin/mailq"
#define DEF_NEWALIAS_PATH "/usr/sbin/newaliases"
#define DEF_COMMAND_DIR "/usr/sbin"
#define DEF_DAEMON_DIR "/usr/libexec/postfix"
#define NATIVE_SENDMAIL_PATH "/usr/lib/sendmail"
#define NATIVE_MAILQ_PATH "/usr/sbin/mailq"
#define NATIVE_NEWALIAS_PATH "/usr/sbin/newaliases"
#define NATIVE_COMMAND_DIR "/usr/sbin"
#define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
#endif
@ -430,7 +433,7 @@ extern time_t time(time_t *);
extern int seteuid(uid_t);
extern int setegid(gid_t);
extern int initgroups(const char *, int);
#define DEF_SENDMAIL_PATH "/usr/lib/sendmail"
#define NATIVE_SENDMAIL_PATH "/usr/lib/sendmail"
#endif
@ -468,6 +471,7 @@ extern int initgroups(const char *, int);
#if defined(IRIX6)
#define HAS_POSIX_REGEXP
#define PIPES_CANT_FIONREAD
#endif
/*
@ -480,7 +484,7 @@ extern int initgroups(const char *, int);
#define HAS_FLOCK_LOCK
#define HAS_FCNTL_LOCK
#define INTERNAL_LOCK MYFLOCK_STYLE_FLOCK
#define DEF_MAILBOX_LOCK "flock, dotlock"
#define DEF_MAILBOX_LOCK "fcntl, dotlock" /* RedHat >= 4.x */
#define HAS_FSYNC
#define HAS_DB
#define DEF_DB_TYPE "hash"
@ -494,11 +498,39 @@ extern int initgroups(const char *, int);
#define UNIX_DOMAIN_CONNECT_BLOCKS_FOR_ACCEPT
#define PREPEND_PLUS_TO_OPTSTRING
#define HAS_POSIX_REGEXP
#define DEF_SENDMAIL_PATH "/usr/sbin/sendmail"
#define DEF_MAILQ_PATH "/usr/bin/mailq"
#define DEF_NEWALIAS_PATH "/usr/bin/newaliases"
#define DEF_COMMAND_DIR "/usr/sbin"
#define DEF_DAEMON_DIR "/usr/libexec/postfix"
#define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail"
#define NATIVE_MAILQ_PATH "/usr/bin/mailq"
#define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
#define NATIVE_COMMAND_DIR "/usr/sbin"
#define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
#endif
#ifdef LINUX1
#define SUPPORTED
#include <sys/types.h>
#define USE_PATHS_H
#define HAS_FLOCK_LOCK
#define HAS_FCNTL_LOCK
#define INTERNAL_LOCK MYFLOCK_STYLE_FLOCK
#define DEF_MAILBOX_LOCK "dotlock" /* verified RedHat 3.03 */
#define HAS_FSYNC
#define HAS_DB
#define DEF_DB_TYPE "hash"
#define ALIAS_DB_MAP "hash:/etc/aliases"
#define HAS_NIS
#define GETTIMEOFDAY(t) gettimeofday(t,(struct timezone *) 0)
#define ROOT_PATH "/bin:/usr/bin:/sbin:/usr/sbin"
#define FIONREAD_IN_TERMIOS_H /* maybe unnecessary */
#define USE_STATFS
#define STATFS_IN_SYS_VFS_H
#define UNIX_DOMAIN_CONNECT_BLOCKS_FOR_ACCEPT /* unverified */
#define PREPEND_PLUS_TO_OPTSTRING
#define HAS_POSIX_REGEXP
#define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail"
#define NATIVE_MAILQ_PATH "/usr/bin/mailq"
#define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
#define NATIVE_COMMAND_DIR "/usr/sbin"
#define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
#endif
/*
@ -532,11 +564,11 @@ extern int h_errno; /* <netdb.h> imports too much stuff */
#define USE_STATFS
#define STATFS_IN_SYS_VFS_H
#define HAS_POSIX_REGEXP
#define DEF_SENDMAIL_PATH "/usr/sbin/sendmail"
#define DEF_MAILQ_PATH "/usr/bin/mailq"
#define DEF_NEWALIAS_PATH "/usr/bin/newaliases"
#define DEF_COMMAND_DIR "/usr/sbin"
#define DEF_DAEMON_DIR "/usr/libexec/postfix"
#define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail"
#define NATIVE_MAILQ_PATH "/usr/bin/mailq"
#define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
#define NATIVE_COMMAND_DIR "/usr/sbin"
#define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
#endif
#ifdef HPUX10
@ -567,11 +599,11 @@ extern int h_errno; /* <netdb.h> imports too much stuff */
#define USE_STATFS
#define STATFS_IN_SYS_VFS_H
#define HAS_POSIX_REGEXP
#define DEF_SENDMAIL_PATH "/usr/sbin/sendmail"
#define DEF_MAILQ_PATH "/usr/bin/mailq"
#define DEF_NEWALIAS_PATH "/usr/bin/newaliases"
#define DEF_COMMAND_DIR "/usr/sbin"
#define DEF_DAEMON_DIR "/usr/libexec/postfix"
#define NATIVE_SENDMAIL_PATH "/usr/sbin/sendmail"
#define NATIVE_MAILQ_PATH "/usr/bin/mailq"
#define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
#define NATIVE_COMMAND_DIR "/usr/sbin"
#define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
#endif
#ifdef HPUX9
@ -604,10 +636,10 @@ extern int h_errno;
#define USE_STATFS
#define STATFS_IN_SYS_VFS_H
#define HAS_POSIX_REGEXP
#define DEF_SENDMAIL_PATH "/usr/bin/sendmail"
#define DEF_MAILQ_PATH "/usr/bin/mailq"
#define DEF_NEWALIAS_PATH "/usr/bin/newaliases"
#define DEF_DAEMON_DIR "/usr/libexec/postfix"
#define NATIVE_SENDMAIL_PATH "/usr/bin/sendmail"
#define NATIVE_MAILQ_PATH "/usr/bin/mailq"
#define NATIVE_NEWALIAS_PATH "/usr/bin/newaliases"
#define NATIVE_DAEMON_DIR "/usr/libexec/postfix"
#endif
/*
@ -809,6 +841,39 @@ extern int h_errno;
*/
#ifndef SUPPORTED
#error "unsupported platform"
#endif
/*
* Allow command line flags to override native settings
*/
#ifndef DEF_COMMAND_DIR
#ifdef NATIVE_COMMAND_DIR
#define DEF_COMMAND_DIR NATIVE_COMMAND_DIR
#endif
#endif
#ifndef DEF_DAEMON_DIR
#ifdef NATIVE_DAEMON_DIR
#define DEF_DAEMON_DIR NATIVE_DAEMON_DIR
#endif
#endif
#ifndef DEF_SENDMAIL_PATH
#ifdef NATIVE_SENDMAIL_PATH
#define DEF_SENDMAIL_PATH NATIVE_SENDMAIL_PATH
#endif
#endif
#ifndef DEF_MAILQ_PATH
#ifdef NATIVE_MAILQ_PATH
#define DEF_MAILQ_PATH NATIVE_MAILQ_PATH
#endif
#endif
#ifndef DEF_NEWALIAS_PATH
#ifdef NATIVE_NEWALIAS_PATH
#define DEF_NEWALIAS_PATH NATIVE_NEWALIAS_PATH
#endif
#endif
#define CAST_CHAR_PTR_TO_INT(cptr) ((int) (long) (cptr))

View File

@ -13,6 +13,10 @@
/* int valid_hostaddr(addr, gripe)
/* const char *addr;
/* int gripe;
/*
/* int valid_hostliteral(addr, gripe)
/* const char *addr;
/* int gripe;
/* DESCRIPTION
/* valid_hostname() scrutinizes a hostname: the name should be no
/* longer than VALID_HOSTNAME_LEN characters, should contain only
@ -20,9 +24,11 @@
/* no leading or trailing dots or hyphens, no labels longer than
/* VALID_LABEL_LEN characters, and no numeric top-level domain.
/*
/* valid_hostaddr() requirs that the input is a valid string
/* valid_hostaddr() requires that the input is a valid string
/* representation of an internet network address.
/*
/* valid_hostliteral() requires an address enclosed in [].
/*
/* These routines operate silently unless the gripe parameter
/* specifies a non-zero value. The macros DO_GRIPE and DONT_GRIPE
/* provide suitable constants.
@ -147,6 +153,19 @@ int valid_hostaddr(const char *addr, int gripe)
return (0);
}
/*
* Preliminary IPV6 support.
*/
if (strchr(addr, ':')) {
if (*(cp = addr + strspn(addr, ":./0123456789abcdefABCDEF")) != 0) {
if (gripe)
msg_warn("%s: invalid character %d(decimal): %.100s",
myname, *cp, addr);
return (0);
}
return (1);
}
/*
* Scary code to avoid sscanf() overflow nasties.
*/
@ -192,6 +211,39 @@ int valid_hostaddr(const char *addr, int gripe)
return (1);
}
/* valid_hostliteral - validate address literal */
int valid_hostliteral(const char *addr, int gripe)
{
const char *myname = "valid_hostliteral";
char buf[100];
const char *last;
if (*addr != '[') {
if (gripe)
msg_warn("%s: '[' expected at start: %.100s", myname, addr);
return (0);
}
if ((last = strchr(addr, ']')) == 0) {
if (gripe)
msg_warn("%s: ']' expected at end: %.100s", myname, addr);
return (0);
}
if (last[1]) {
if (gripe)
msg_warn("%s: unexpected text after ']': %.100s", myname, addr);
return (0);
}
if (last - addr >= sizeof(buf)) {
if (gripe)
msg_warn("%s: too much text: %.100s", myname, addr);
return (0);
}
strncpy(buf, addr + 1, last - addr - 1);
buf[last - addr - 1] = 0;
return (valid_hostaddr(buf, gripe));
}
#ifdef TEST
/*
@ -216,6 +268,7 @@ int main(int unused_argc, char **argv)
msg_info("testing: \"%s\"", vstring_str(buffer));
valid_hostname(vstring_str(buffer), DO_GRIPE);
valid_hostaddr(vstring_str(buffer), DO_GRIPE);
valid_hostliteral(vstring_str(buffer), DO_GRIPE);
}
exit(0);
}