with insecure MX records. Viktor Dukhovni. Files:
posttls-finger/posttls-finger.c, smtp/smtp_tls_policy.c,
tls/tls.h, tls/tls_client.c, tls/tls_level.c.
+
+20160108
+
+ Cleanup: smtp_reply_footer() now restores state in case of
+ input error; unit tests that cover most if not all error
+ and non-error cases. Files: global/smtp_reply_footer.c,
+ global/smtp_reply_footer.ref.
+
+20160110
+
+ Bitrot: const-ification for OpenSSL 1.1.0. Viktor Dukhovni.
+ File: tls/tls_misc.c.
+
+20160116
+
+ "postconf -H" support (show names without the =value).
+ Initial use case: mass reversal of TLS-related main.cf
+ parameters (postconf -nH | grep _tls_ | xargs postconf -X).
+ This flag also works with "postconf -F" and "postconf -P".
+ Added missing documentation that -h works with "postconf
+ -F" and "postconf -P". Files: postconf.c, postconf.h,
+ postconf_master.c, postconf_main.c.
+
+ Robustness: force html2text to produce ASCII output. File:
+ mantools/html2readme.
src/posttls-finger
MANDIRS = proto man html
LIBEXEC = libexec/post-install libexec/postfix-script libexec/postfix-wrapper \
- libexec/postmulti-script libexec/post-install
+ libexec/postmulti-script
PLUGINS = meta/dynamicmaps.cf
META = meta/main.cf.proto meta/master.cf.proto meta/postfix-files \
meta/makedefs.out $(PLUGINS)
<b>SYNOPSIS</b>
<b>Managing <a href="postconf.5.html">main.cf</a>:</b>
- <b>postconf</b> [<b>-dfhnopvx</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] [<b>-C</b> <i>class,...</i>] [<i>parameter ...</i>]
+ <b>postconf</b> [<b>-dfhHnopvx</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] [<b>-C</b> <i>class,...</i>] [<i>parameter ...</i>]
<b>postconf</b> [<b>-epv</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] <i>parameter</i><b>=</b><i>value ...</i>
<b>Managing <a href="master.5.html">master.cf</a> service fields:</b>
- <b>postconf -F</b> [<b>-fovx</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] [<i>service</i>[<b>/</b><i>type</i>[<b>/</b><i>field</i>]] <i>...</i>]
+ <b>postconf -F</b> [<b>-fhHovx</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] [<i>service</i>[<b>/</b><i>type</i>[<b>/</b><i>field</i>]] <i>...</i>]
<b>postconf -F</b> [<b>-ev</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] <i>service</i><b>/</b><i>type</i><b>/</b><i>field</i><b>=</b><i>value ...</i>
<b>Managing <a href="master.5.html">master.cf</a> service parameters:</b>
- <b>postconf -P</b> [<b>-fovx</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] [<i>service</i>[<b>/</b><i>type</i>[<b>/</b><i>parameter</i>]] <i>...</i>]
+ <b>postconf -P</b> [<b>-fhHovx</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] [<i>service</i>[<b>/</b><i>type</i>[<b>/</b><i>parameter</i>]] <i>...</i>]
<b>postconf -P</b> [<b>-ev</b>] [<b>-c</b> <i>config</i><b>_</b><i>dir</i>] <i>service</i><b>/</b><i>type</i><b>/</b><i>parameter</i><b>=</b><i>value ...</i>
<b>DESCRIPTION</b>
By default, the <a href="postconf.1.html"><b>postconf</b>(1)</a> command displays the values of <a href="postconf.5.html"><b>main.cf</b></a> con-
- figuration parameters, and warns about possible mis-typed parameter
- names (Postfix 2.9 and later). It can also change <a href="postconf.5.html"><b>main.cf</b></a> configura-
+ figuration parameters, and warns about possible mis-typed parameter
+ names (Postfix 2.9 and later). It can also change <a href="postconf.5.html"><b>main.cf</b></a> configura-
tion parameter values, or display other configuration information about
the Postfix mail system.
Options:
- <b>-a</b> List the available SASL server plug-in types. The SASL plug-in
- type is selected with the <b><a href="postconf.5.html#smtpd_sasl_type">smtpd_sasl_type</a></b> configuration parame-
+ <b>-a</b> List the available SASL server plug-in types. The SASL plug-in
+ type is selected with the <b><a href="postconf.5.html#smtpd_sasl_type">smtpd_sasl_type</a></b> configuration parame-
ter by specifying one of the names listed below.
- <b>cyrus</b> This server plug-in is available when Postfix is built
+ <b>cyrus</b> This server plug-in is available when Postfix is built
with Cyrus SASL support.
<b>dovecot</b>
This server plug-in uses the Dovecot authentication
- server, and is available when Postfix is built with any
+ server, and is available when Postfix is built with any
form of SASL support.
This feature is available with Postfix 2.3 and later.
- <b>-A</b> List the available SASL client plug-in types. The SASL plug-in
- type is selected with the <b><a href="postconf.5.html#smtp_sasl_type">smtp_sasl_type</a></b> or <b><a href="postconf.5.html#lmtp_sasl_type">lmtp_sasl_type</a></b> con-
- figuration parameters by specifying one of the names listed
+ <b>-A</b> List the available SASL client plug-in types. The SASL plug-in
+ type is selected with the <b><a href="postconf.5.html#smtp_sasl_type">smtp_sasl_type</a></b> or <b><a href="postconf.5.html#lmtp_sasl_type">lmtp_sasl_type</a></b> con-
+ figuration parameters by specifying one of the names listed
below.
- <b>cyrus</b> This client plug-in is available when Postfix is built
+ <b>cyrus</b> This client plug-in is available when Postfix is built
with Cyrus SASL support.
This feature is available with Postfix 2.3 and later.
<b>-b</b> [<i>template</i><b>_</b><i>file</i>]
Display the message text that appears at the beginning of deliv-
- ery status notification (DSN) messages, replacing $<b>name</b> expres-
+ ery status notification (DSN) messages, replacing $<b>name</b> expres-
sions with actual values as described in <a href="bounce.5.html"><b>bounce</b>(5)</a>.
To override the built-in templates, specify a template file name
- at the end of the <a href="postconf.1.html"><b>postconf</b>(1)</a> command line, or specify a file
+ at the end of the <a href="postconf.1.html"><b>postconf</b>(1)</a> command line, or specify a file
name in <a href="postconf.5.html"><b>main.cf</b></a> with the <b><a href="postconf.5.html#bounce_template_file">bounce_template_file</a></b> parameter.
- To force selection of the built-in templates, specify an empty
- template file name on the <a href="postconf.1.html"><b>postconf</b>(1)</a> command line (in shell
+ To force selection of the built-in templates, specify an empty
+ template file name on the <a href="postconf.1.html"><b>postconf</b>(1)</a> command line (in shell
language: "").
This feature is available with Postfix 2.3 and later.
of the default configuration directory.
<b>-C</b> <i>class,...</i>
- When displaying <a href="postconf.5.html"><b>main.cf</b></a> parameters, select only parameters from
+ When displaying <a href="postconf.5.html"><b>main.cf</b></a> parameters, select only parameters from
the specified class(es):
<b>builtin</b>
This feature is available with Postfix 2.9 and later.
- <b>-d</b> Print <a href="postconf.5.html"><b>main.cf</b></a> default parameter settings instead of actual set-
- tings. Specify <b>-df</b> to fold long lines for human readability
+ <b>-d</b> Print <a href="postconf.5.html"><b>main.cf</b></a> default parameter settings instead of actual set-
+ tings. Specify <b>-df</b> to fold long lines for human readability
(Postfix 2.9 and later).
- <b>-e</b> Edit the <a href="postconf.5.html"><b>main.cf</b></a> configuration file, and update parameter set-
- tings with the "<i>name=value</i>" pairs on the <a href="postconf.1.html"><b>postconf</b>(1)</a> command
+ <b>-e</b> Edit the <a href="postconf.5.html"><b>main.cf</b></a> configuration file, and update parameter set-
+ tings with the "<i>name=value</i>" pairs on the <a href="postconf.1.html"><b>postconf</b>(1)</a> command
line.
- With <b>-M</b>, edit the <a href="master.5.html"><b>master.cf</b></a> configuration file, and replace one
- or more service entries with new values as specified with "<i>ser-</i>
+ With <b>-M</b>, edit the <a href="master.5.html"><b>master.cf</b></a> configuration file, and replace one
+ or more service entries with new values as specified with "<i>ser-</i>
<i>vice/type=value</i>" on the <a href="postconf.1.html"><b>postconf</b>(1)</a> command line.
- With <b>-F</b>, edit the <a href="master.5.html"><b>master.cf</b></a> configuration file, and replace one
- or more service fields with new values as specied with "<i>ser-</i>
- <i>vice/type/field=value</i>" on the <a href="postconf.1.html"><b>postconf</b>(1)</a> command line. Cur-
- rently, the "command" field contains the command name and com-
+ With <b>-F</b>, edit the <a href="master.5.html"><b>master.cf</b></a> configuration file, and replace one
+ or more service fields with new values as specied with "<i>ser-</i>
+ <i>vice/type/field=value</i>" on the <a href="postconf.1.html"><b>postconf</b>(1)</a> command line. Cur-
+ rently, the "command" field contains the command name and com-
mand arguments. this may change in the near future, so that the
"command" field contains only the command name, and a new "argu-
ments" pseudofield contains the command arguments.
- With <b>-P</b>, edit the <a href="master.5.html"><b>master.cf</b></a> configuration file, and add or
- update one or more service parameter settings (-o parame-
- ter=value settings) with new values as specied with "<i>ser-</i>
+ With <b>-P</b>, edit the <a href="master.5.html"><b>master.cf</b></a> configuration file, and add or
+ update one or more service parameter settings (-o parame-
+ ter=value settings) with new values as specied with "<i>ser-</i>
<i>vice/type/parameter=value</i>" on the <a href="postconf.1.html"><b>postconf</b>(1)</a> command line.
In all cases the file is copied to a temporary file then renamed
- into place. Specify quotes to protect special characters and
+ into place. Specify quotes to protect special characters and
whitespace on the <a href="postconf.1.html"><b>postconf</b>(1)</a> command line.
- The <b>-e</b> option is no longer needed with Postfix version 2.8 and
+ The <b>-e</b> option is no longer needed with Postfix version 2.8 and
later.
<b>-f</b> Fold long lines when printing <a href="postconf.5.html"><b>main.cf</b></a> or <a href="master.5.html"><b>master.cf</b></a> configuration
and all fields), formatted as one "<i>service/type/field=value</i>" per
line. Specify <b>-Ff</b> to fold long lines.
- Specify one or more "<i>service/type/field</i>" instances on the <a href="postconf.1.html"><b>post-</b></a>
- <a href="postconf.1.html"><b>conf</b>(1)</a> command line to limit the output to fields of interest.
- Trailing parameter name or service type fields that are omitted
+ Specify one or more "<i>service/type/field</i>" instances on the <a href="postconf.1.html"><b>post-</b></a>
+ <a href="postconf.1.html"><b>conf</b>(1)</a> command line to limit the output to fields of interest.
+ Trailing parameter name or service type fields that are omitted
will be handled as "*" wildcard fields.
This feature is available with Postfix 2.11 and later.
- <b>-h</b> Show parameter or attribute values without the "<i>name</i> = " label
+ <b>-h</b> Show parameter or attribute values without the "<i>name</i> = " label
that normally precedes the value.
+ <b>-H</b> Show parameter or attribute names without the " = <i>value</i>" that
+ normally follows the name.
+
+ This feature is available with Postfix 3.1 and later.
+
<b>-l</b> List the names of all supported mailbox locking methods. Post-
fix supports the following methods:
P.O. Box 704
Yorktown Heights, NY 10598, USA
+ Wietse Venema
+ Google, Inc.
+ 111 8th Avenue
+ New York, NY 10011, USA
+
POSTCONF(1)
</pre> </body> </html>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<title> Postfix manual - postlog(1) </title>
</head> <body> <pre>
-POSTLOG(1) POSTLOG(1)
+POSTLOG(1) General Commands Manual POSTLOG(1)
<b>NAME</b>
postlog - Postfix-compatible logging utility
P.O. Box 704
Yorktown Heights, NY 10598, USA
+ Wietse Venema
+ Google, Inc.
+ 111 8th Avenue
+ New York, NY 10011, USA
+
POSTLOG(1)
</pre> </body> </html>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<title> Postfix manual - posttls-finger(1) </title>
</head> <body> <pre>
-POSTTLS-FINGER(1) POSTTLS-FINGER(1)
+POSTTLS-FINGER(1) General Commands Manual POSTTLS-FINGER(1)
<b>NAME</b>
posttls-finger - Probe the TLS properties of an ESMTP or LMTP server.
reading the remote server's 220 banner.
<b>-T</b> <i>timeout</i> (default: <b>30</b>)
- The SMTP/LMTP command timeout for EHLO/LHLO, STARTTLS and QUIT.
+ The SMTP/LMTP command timeout for EHLO/LHLO, STARTTLS and QUIT.
- <b>-v</b> Enable verbose Postfix logging. Specify more than once to
+ <b>-v</b> Enable verbose Postfix logging. Specify more than once to
increase the level of verbose logging.
- <b>-w</b> Enable outgoing TLS wrapper mode, or SMTPS support. This is
- typically provided on port 465 by servers that are compatible
- with the ad-hoc SMTP in SSL protocol, rather than the standard
+ <b>-w</b> Enable outgoing TLS wrapper mode, or SMTPS support. This is
+ typically provided on port 465 by servers that are compatible
+ with the ad-hoc SMTP in SSL protocol, rather than the standard
STARTTLS protocol. The destination <i>domain</i>:<i>port</i> should of course
provide such a service.
[<b>inet:</b>]<i>domain</i>[:<i>port</i>]
Connect via TCP to domain <i>domain</i>, port <i>port</i>. The default port is
- <b>smtp</b> (or 24 with LMTP). With SMTP an MX lookup is performed to
- resolve the domain to a host, unless the domain is enclosed in
- <b>[]</b>. If you want to connect to a specific MX host, for instance
- <i>mx1.example.com</i>, specify [<i>mx1.example.com</i>] as the destination
+ <b>smtp</b> (or 24 with LMTP). With SMTP an MX lookup is performed to
+ resolve the domain to a host, unless the domain is enclosed in
+ <b>[]</b>. If you want to connect to a specific MX host, for instance
+ <i>mx1.example.com</i>, specify [<i>mx1.example.com</i>] as the destination
and <i>example.com</i> as a <b>match</b> argument. When using DNS, the desti-
- nation domain is assumed fully qualified and no <a href="ADDRESS_CLASS_README.html#default_domain_class">default domain</a>
- or search suffixes are applied; you must use fully-qualified
- names or also enable <b>native</b> host lookups (these don't support
- <b>dane</b> or <b>dane-only</b> as no DNSSEC validation information is avail-
+ nation domain is assumed fully qualified and no default domain
+ or search suffixes are applied; you must use fully-qualified
+ names or also enable <b>native</b> host lookups (these don't support
+ <b>dane</b> or <b>dane-only</b> as no DNSSEC validation information is avail-
able via <b>native</b> lookups).
<b>unix:</b><i>pathname</i>
<b>match ...</b>
With no match arguments specified, certificate peername matching
uses the compiled-in default strategies for each security level.
- If you specify one or more arguments, these will be used as the
- list of certificate or public-key digests to match for the <b>fin-</b>
+ If you specify one or more arguments, these will be used as the
+ list of certificate or public-key digests to match for the <b>fin-</b>
<b>gerprint</b> level, or as the list of DNS names to match in the cer-
tificate at the <b>verify</b> and <b>secure</b> levels. If the security level
is <b>dane</b>, or <b>dane-only</b> the match names are ignored, and <b>hostname,</b>
.fi
\fBManaging main.cf:\fR
-\fBpostconf\fR [\fB\-dfhnopvx\fR] [\fB\-c \fIconfig_dir\fR]
+\fBpostconf\fR [\fB\-dfhHnopvx\fR] [\fB\-c \fIconfig_dir\fR]
[\fB\-C \fIclass,...\fR] [\fIparameter ...\fR]
\fBpostconf\fR [\fB\-epv\fR] [\fB\-c \fIconfig_dir\fR]
\fBManaging master.cf service fields:\fR
-\fBpostconf\fR \fB\-F\fR [\fB\-fovx\fR] [\fB\-c \fIconfig_dir\fR]
+\fBpostconf\fR \fB\-F\fR [\fB\-fhHovx\fR] [\fB\-c \fIconfig_dir\fR]
[\fIservice\fR[\fB/\fItype\fR[\fB/\fIfield\fR]]\fI ...\fR]
\fBpostconf\fR \fB\-F\fR [\fB\-ev\fR] [\fB\-c \fIconfig_dir\fR]
\fBManaging master.cf service parameters:\fR
-\fBpostconf\fR \fB\-P\fR [\fB\-fovx\fR] [\fB\-c \fIconfig_dir\fR]
+\fBpostconf\fR \fB\-P\fR [\fB\-fhHovx\fR] [\fB\-c \fIconfig_dir\fR]
[\fIservice\fR[\fB/\fItype\fR[\fB/\fIparameter\fR]]\fI ...\fR]
\fBpostconf\fR \fB\-P\fR [\fB\-ev\fR] [\fB\-c \fIconfig_dir\fR]
.IP \fB\-h\fR
Show parameter or attribute values without the "\fIname\fR
= " label that normally precedes the value.
+.IP \fB\-H\fR
+Show parameter or attribute names without the " = \fIvalue\fR"
+that normally follows the name.
+
+This feature is available with Postfix 3.1 and later.
.IP \fB\-l\fR
List the names of all supported mailbox locking methods.
Postfix supports the following methods:
IBM T.J. Watson Research
P.O. Box 704
Yorktown Heights, NY 10598, USA
+
+Wietse Venema
+Google, Inc.
+111 8th Avenue
+New York, NY 10011, USA
IBM T.J. Watson Research
P.O. Box 704
Yorktown Heights, NY 10598, USA
+
+Wietse Venema
+Google, Inc.
+111 8th Avenue
+New York, NY 10011, USA
IBM T.J. Watson Research
P.O. Box 704
Yorktown Heights, NY 10598, USA
+.sp
+Wietse Venema
+Google, Inc.
+111 8th Avenue
+New York, NY 10011, USA
+.sp
+Viktor Dukhovni
#!/bin/sh
-HTML2TEXT="html2text -style pretty -rcfile html2text.rc"
+HTML2TEXT="html2text -ascii -style pretty -rcfile html2text.rc"
#case $# in
# 0) $HTML2TEXT;;
IBM T.J. Watson Research
P.O. Box 704
Yorktown Heights, NY 10598, USA
+.sp
+Wietse Venema
+Google, Inc.
+111 8th Avenue
+New York, NY 10011, USA
+.sp
+Viktor Dukhovni
valid_mailhost_addr own_inet_addr header_body_checks \
data_redirect addr_match_list safe_ultostr verify_sender_addr \
mail_version mail_dict server_acl uxtext mail_parm_split \
- fold_addr
+ fold_addr smtp_reply_footer
LIBS = ../../lib/lib$(LIB_PREFIX)util$(LIB_SUFFIX)
LIB_DIR = ../../lib
fold_addr: fold_addr.c $(LIB) $(LIBS)
$(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
+smtp_reply_footer: smtp_reply_footer.c $(LIB) $(LIBS)
+ $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(LIBS) $(SYSLIBS)
+
tests: tok822_test mime_tests strip_addr_test tok822_limit_test \
xtext_test scache_multi_test ehlo_mask_test \
namadr_list_test mail_conf_time_test header_body_checks_tests \
mail_version_test server_acl_test resolve_local_test maps_test \
- safe_ultostr_test mail_parm_split_test fold_addr_test
+ safe_ultostr_test mail_parm_split_test fold_addr_test \
+ smtp_reply_footer_test
mime_tests: mime_test mime_nest mime_8bit mime_dom mime_trunc mime_cvt \
mime_cvt2 mime_cvt3 mime_garb1 mime_garb2 mime_garb3 mime_garb4
diff fold_addr_test.ref fold_addr_test.tmp
rm -f fold_addr_test.tmp
+smtp_reply_footer_test: smtp_reply_footer smtp_reply_footer.ref
+ $(SHLIB_ENV) ./smtp_reply_footer >smtp_reply_footer.tmp 2>&1
+ diff smtp_reply_footer.ref smtp_reply_footer.tmp
+ rm -f smtp_reply_footer.tmp
+
printfck: $(OBJS) $(PROG)
rm -rf printfck
mkdir printfck
* Patches change both the patchlevel and the release date. Snapshots have no
* patchlevel; they change the release date only.
*/
-#define MAIL_RELEASE_DATE "20160104"
+#define MAIL_RELEASE_DATE "20160117"
#define MAIL_VERSION_NUMBER "3.1"
#ifdef SNAPSHOT
/* lookup, context)
/* VSTRING *buffer;
/* ssize_t start;
-/* char *template;
+/* const char *template;
/* const char *filter;
/* const char *(*lookup) (const char *name, void *context);
/* void *context;
/* SEE ALSO
/* mac_expand(3) macro expansion
/* DIAGNOSTICS
-/* smtp_reply_footer() returns 0 upon success, -1 if the
-/* existing reply text is malformed.
+/* smtp_reply_footer() returns 0 upon success, -1 if the existing
+/* reply text is malformed, -2 in the case of a template macro
+/* parsing error (an undefined macro value is not an error).
/*
/* Fatal errors: memory allocation problem.
/* LICENSE
/* IBM T.J. Watson Research
/* P.O. Box 704
/* Yorktown Heights, NY 10598, USA
+/*
+/* Wietse Venema
+/* Google, Inc.
+/* 111 8th Avenue
+/* New York, NY 10011, USA
/*--*/
/* System library. */
/* Utility library. */
#include <msg.h>
+#include <mymalloc.h>
#include <vstring.h>
/* Global library. */
#define STR vstring_str
int smtp_reply_footer(VSTRING *buffer, ssize_t start,
- char *template,
+ const char *template,
const char *filter,
MAC_EXP_LOOKUP_FN lookup,
void *context)
char *cp;
char *next;
char *end;
- ssize_t dsn_len;
+ ssize_t dsn_len; /* last status code length */
+ ssize_t dsn_offs = -1; /* last status code offset */
int crlf_at_end = 0;
- ssize_t reply_patch_undo_offs = -1;
+ ssize_t reply_code_offs = -1; /* last SMTP reply code offset */
+ ssize_t reply_patch_undo_len; /* length without final CRLF */
+ int mac_expand_error = 0;
+ int line_added;
+ char *saved_template;
/*
* Sanity check.
msg_panic("%s: empty template", myname);
/*
- * Scan and patch the original response. If the response is not what we
- * expect, we stop making changes.
+ * Scan the original response without making changes. If the response is
+ * not what we expect, report an error. Otherwise, remember the offset of
+ * the last SMTP reply code.
*/
for (cp = STR(buffer) + start, end = cp + strlen(cp);;) {
if (!ISDIGIT(cp[0]) || !ISDIGIT(cp[1]) || !ISDIGIT(cp[2])
|| (cp[3] != ' ' && cp[3] != '-'))
return (-1);
- cp[3] = '-';
- reply_patch_undo_offs = cp + 3 - STR(buffer);
+ reply_code_offs = cp - STR(buffer);
if ((next = strstr(cp, "\r\n")) == 0) {
next = end;
break;
break;
}
}
+ if (reply_code_offs < 0)
+ return (-1);
/*
* Truncate text after the first null, and truncate the trailing CRLF.
*/
if (next < vstring_end(buffer))
vstring_truncate(buffer, next - STR(buffer));
+ reply_patch_undo_len = VSTRING_LEN(buffer);
/*
* Append the footer text one line at a time. Caution: before we append
* parts from the buffer to itself, we must extend the buffer first,
* otherwise we would have a dangling pointer "read" bug.
+ *
+ * XXX mac_expand() has no template length argument, so we must
+ * null-terminate the template in the middle.
*/
- dsn_len = dsn_valid(STR(buffer) + start + 4);
- for (cp = template, end = cp + strlen(cp);;) {
+ dsn_offs = reply_code_offs + 4;
+ dsn_len = dsn_valid(STR(buffer) + dsn_offs);
+ line_added = 0;
+ saved_template = mystrdup(template);
+ for (cp = saved_template, end = cp + strlen(cp);;) {
if ((next = strstr(cp, "\\n")) != 0) {
*next = 0;
} else {
next = end;
}
- if (cp == template && strncmp(cp, "\\c", 2) == 0) {
+ if (cp == saved_template && strncmp(cp, "\\c", 2) == 0) {
/* Handle \c at start of template. */
cp += 2;
} else {
/* Append a clone of the SMTP reply code. */
vstring_strcat(buffer, "\r\n");
VSTRING_SPACE(buffer, 3);
- vstring_strncat(buffer, STR(buffer) + start, 3);
+ vstring_strncat(buffer, STR(buffer) + reply_code_offs, 3);
vstring_strcat(buffer, next != end ? "-" : " ");
/* Append a clone of the optional enhanced status code. */
if (dsn_len > 0) {
VSTRING_SPACE(buffer, dsn_len);
- vstring_strncat(buffer, STR(buffer) + start + 4, dsn_len);
+ vstring_strncat(buffer, STR(buffer) + dsn_offs, dsn_len);
vstring_strcat(buffer, " ");
}
- reply_patch_undo_offs = -1;
+ line_added = 1;
}
/* Append one line of footer text. */
- mac_expand(buffer, cp, MAC_EXP_FLAG_APPEND, filter, lookup, context);
+ mac_expand_error = (mac_expand(buffer, cp, MAC_EXP_FLAG_APPEND, filter,
+ lookup, context) & MAC_PARSE_ERROR);
+ if (mac_expand_error)
+ break;
if (next < end) {
- *next = '\\';
cp = next + 2;
} else
break;
}
- if (reply_patch_undo_offs > 0)
- STR(buffer)[reply_patch_undo_offs] = ' ';
+ myfree(saved_template);
+ /* Discard appended text after error, or finalize the result. */
+ if (mac_expand_error) {
+ vstring_truncate(buffer, reply_patch_undo_len);
+ VSTRING_TERMINATE(buffer);
+ } else if (line_added > 0) {
+ STR(buffer)[reply_code_offs + 3] = '-';
+ }
+ /* Restore CRLF at end. */
if (crlf_at_end)
vstring_strcat(buffer, "\r\n");
- return (0);
+ return (mac_expand_error ? -2 : 0);
}
+
+#ifdef TEST
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <msg.h>
+#include <vstream.h>
+#include <vstring_vstream.h>
+#include <msg_vstream.h>
+
+struct test_case {
+ const char *title;
+ const char *orig_reply;
+ const char *template;
+ const char *filter;
+ int expected_status;
+ const char *expected_reply;
+};
+
+#define NO_FILTER ((char *) 0)
+#define NO_TEMPLATE "NO_TEMPLATE"
+#define NO_ERROR (0)
+#define BAD_SMTP (-1)
+#define BAD_MACRO (-2)
+
+static struct test_case test_cases[] = {
+ {"missing reply", "", NO_TEMPLATE, NO_FILTER, BAD_SMTP, 0},
+ {"long smtp_code", "1234 foo", NO_TEMPLATE, NO_FILTER, BAD_SMTP, 0},
+ {"short smtp_code", "12 foo", NO_TEMPLATE, NO_FILTER, BAD_SMTP, 0},
+ {"good+bad smtp_code", "321 foo\r\n1234 foo", NO_TEMPLATE, NO_FILTER, BAD_SMTP, 0},
+ {"1-line no dsn", "550 Foo", "\\c footer", NO_FILTER, NO_ERROR, "550 Foo footer"},
+ {"1-line no dsn", "550 Foo", "Bar", NO_FILTER, NO_ERROR, "550-Foo\r\n550 Bar"},
+ {"2-line no dsn", "550-Foo\r\n550 Bar", "Baz", NO_FILTER, NO_ERROR, "550-Foo\r\n550-Bar\r\n550 Baz"},
+ {"1-line with dsn", "550 5.1.1 Foo", "Bar", NO_FILTER, NO_ERROR, "550-5.1.1 Foo\r\n550 5.1.1 Bar"},
+ {"2-line with dsn", "550-5.1.1 Foo\r\n450 4.1.1 Bar", "Baz", NO_FILTER, NO_ERROR, "550-5.1.1 Foo\r\n450-4.1.1 Bar\r\n450 4.1.1 Baz"},
+ {"bad macro", "220 myhostname", "\\c ${whatever", NO_FILTER, BAD_MACRO, 0},
+ {"bad macroCRLF", "220 myhostname\r\n", "\\c ${whatever", NO_FILTER, BAD_MACRO, 0},
+ {"good macro", "220 myhostname", "\\c $whatever", NO_FILTER, NO_ERROR, "220 myhostname DUMMY"},
+ {"good macroCRLF", "220 myhostname\r\n", "\\c $whatever", NO_FILTER, NO_ERROR, "220 myhostname DUMMY\r\n"},
+ 0,
+};
+
+static const char *lookup(const char *name, int unused_mode, void *context)
+{
+ return "DUMMY";
+}
+
+int main(int argc, char **argv)
+{
+ struct test_case *tp;
+ int status;
+ VSTRING *buf = vstring_alloc(10);
+ void *context = 0;
+
+ msg_vstream_init(argv[0], VSTREAM_ERR);
+
+ for (tp = test_cases; tp->title != 0; tp++) {
+ vstring_strcpy(buf, tp->orig_reply);
+ status = smtp_reply_footer(buf, 0, tp->template, tp->filter,
+ lookup, context);
+ if (status != tp->expected_status) {
+ msg_warn("test \"%s\": status %d, expected %d",
+ tp->title, status, tp->expected_status);
+ } else if (status < 0 && strcmp(STR(buf), tp->orig_reply) != 0) {
+ msg_warn("test \"%s\": result \"%s\", expected \"%s\"",
+ tp->title, STR(buf), tp->orig_reply);
+ } else if (status == 0 && strcmp(STR(buf), tp->expected_reply) != 0) {
+ msg_warn("test \"%s\": result \"%s\", expected \"%s\"",
+ tp->title, STR(buf), tp->expected_reply);
+ } else {
+ msg_info("test \"%s\": pass", tp->title);
+ }
+ }
+ vstring_free(buf);
+ exit(0);
+}
+
+#endif
/*
* External interface.
*/
-extern int smtp_reply_footer(VSTRING *, ssize_t, char *, const char *,
+extern int smtp_reply_footer(VSTRING *, ssize_t, const char *, const char *,
MAC_EXP_LOOKUP_FN, void *);
/* LICENSE
/* IBM T.J. Watson Research
/* P.O. Box 704
/* Yorktown Heights, NY 10598, USA
+/*
+/* Wietse Venema
+/* Google, Inc.
+/* 111 8th Avenue
+/* New York, NY 10011, USA
/*--*/
#endif
--- /dev/null
+./smtp_reply_footer: test "missing reply": pass
+./smtp_reply_footer: test "long smtp_code": pass
+./smtp_reply_footer: test "short smtp_code": pass
+./smtp_reply_footer: test "good+bad smtp_code": pass
+./smtp_reply_footer: test "1-line no dsn": pass
+./smtp_reply_footer: test "1-line no dsn": pass
+./smtp_reply_footer: test "2-line no dsn": pass
+./smtp_reply_footer: test "1-line with dsn": pass
+./smtp_reply_footer: test "2-line with dsn": pass
+./smtp_reply_footer: warning: truncated macro reference: " ${whatever"
+./smtp_reply_footer: test "bad macro": pass
+./smtp_reply_footer: warning: truncated macro reference: " ${whatever"
+./smtp_reply_footer: test "bad macroCRLF": pass
+./smtp_reply_footer: test "good macro": pass
+./smtp_reply_footer: test "good macroCRLF": pass
test22 test23 test24 test25 test26 test27 test28 test29 test30 test4b \
test31 test32 test33 test34 test35 test36 test37 test39 test40 test41 \
test42 test43 test44 test45 test46 test47 test48 test49 test50 test51 \
- test52 test53 test54 test55 test56 test57 test58 test59
+ test52 test53 test54 test55 test56 test57 test58 test59 test60 test61 \
+ test62 test63
root_tests:
diff test59.ref test59.tmp
rm -f main.cf master.cf test59.tmp
+test60: $(PROG) test60.ref
+ rm -f main.cf master.cf
+ touch main.cf master.cf
+ echo foo unix - n n - 0 other >> master.cf
+ echo ' -o always_bcc=bar' >> master.cf
+ touch -t 197101010000 main.cf
+ $(SHLIB_ENV) ./$(PROG) -Fhc. >test60.tmp 2>&1 || true
+ diff test60.ref test60.tmp
+ rm -f main.cf master.cf test60.tmp
+
+test61: $(PROG) test61.ref
+ rm -f main.cf master.cf
+ touch main.cf master.cf
+ echo foo unix - n n - 0 other >> master.cf
+ echo ' -o always_bcc=bar' >> master.cf
+ touch -t 197101010000 main.cf
+ $(SHLIB_ENV) ./$(PROG) -Phc. >test61.tmp 2>&1 || true
+ diff test61.ref test61.tmp
+ rm -f main.cf master.cf test61.tmp
+
+test62: $(PROG) test62.ref
+ rm -f main.cf master.cf
+ touch main.cf master.cf
+ echo foo unix - n n - 0 other >> master.cf
+ echo ' -o always_bcc=bar' >> master.cf
+ touch -t 197101010000 main.cf
+ $(SHLIB_ENV) ./$(PROG) -FHc. >test62.tmp 2>&1 || true
+ diff test62.ref test62.tmp
+ rm -f main.cf master.cf test62.tmp
+
+test63: $(PROG) test63.ref
+ rm -f main.cf master.cf
+ touch main.cf master.cf
+ echo foo unix - n n - 0 other >> master.cf
+ echo ' -o always_bcc=bar' >> master.cf
+ touch -t 197101010000 main.cf
+ $(SHLIB_ENV) ./$(PROG) -PHc. >test63.tmp 2>&1 || true
+ diff test63.ref test63.tmp
+ rm -f main.cf master.cf test63.tmp
+
printfck: $(OBJS) $(PROG)
rm -rf printfck
mkdir printfck
/* .fi
/* \fBManaging main.cf:\fR
/*
-/* \fBpostconf\fR [\fB-dfhnopvx\fR] [\fB-c \fIconfig_dir\fR]
+/* \fBpostconf\fR [\fB-dfhHnopvx\fR] [\fB-c \fIconfig_dir\fR]
/* [\fB-C \fIclass,...\fR] [\fIparameter ...\fR]
/*
/* \fBpostconf\fR [\fB-epv\fR] [\fB-c \fIconfig_dir\fR]
/*
/* \fBManaging master.cf service fields:\fR
/*
-/* \fBpostconf\fR \fB-F\fR [\fB-fovx\fR] [\fB-c \fIconfig_dir\fR]
+/* \fBpostconf\fR \fB-F\fR [\fB-fhHovx\fR] [\fB-c \fIconfig_dir\fR]
/* [\fIservice\fR[\fB/\fItype\fR[\fB/\fIfield\fR]]\fI ...\fR]
/*
/* \fBpostconf\fR \fB-F\fR [\fB-ev\fR] [\fB-c \fIconfig_dir\fR]
/*
/* \fBManaging master.cf service parameters:\fR
/*
-/* \fBpostconf\fR \fB-P\fR [\fB-fovx\fR] [\fB-c \fIconfig_dir\fR]
+/* \fBpostconf\fR \fB-P\fR [\fB-fhHovx\fR] [\fB-c \fIconfig_dir\fR]
/* [\fIservice\fR[\fB/\fItype\fR[\fB/\fIparameter\fR]]\fI ...\fR]
/*
/* \fBpostconf\fR \fB-P\fR [\fB-ev\fR] [\fB-c \fIconfig_dir\fR]
/* .IP \fB-h\fR
/* Show parameter or attribute values without the "\fIname\fR
/* = " label that normally precedes the value.
+/* .IP \fB-H\fR
+/* Show parameter or attribute names without the " = \fIvalue\fR"
+/* that normally follows the name.
+/*
+/* This feature is available with Postfix 3.1 and later.
/* .IP \fB-l\fR
/* List the names of all supported mailbox locking methods.
/* Postfix supports the following methods:
/* IBM T.J. Watson Research
/* P.O. Box 704
/* Yorktown Heights, NY 10598, USA
+/*
+/* Wietse Venema
+/* Google, Inc.
+/* 111 8th Avenue
+/* New York, NY 10011, USA
/*--*/
/* System library. */
PCF_SHOW_EVAL | PCF_EDIT_CONF | PCF_COMMENT_OUT | PCF_EDIT_EXCL,
PCF_MAIN_OVER | PCF_SHOW_DEFS | PCF_EDIT_CONF | PCF_COMMENT_OUT \
|PCF_EDIT_EXCL,
- PCF_HIDE_NAME | PCF_EDIT_CONF | PCF_COMMENT_OUT | PCF_EDIT_EXCL,
+ PCF_HIDE_NAME | PCF_EDIT_CONF | PCF_COMMENT_OUT | PCF_EDIT_EXCL \
+ |PCF_HIDE_VALUE,
0,
};
{PCF_MAIN_PARAM, (PCF_EDIT_CONF | PCF_EDIT_EXCL | PCF_COMMENT_OUT \
|PCF_FOLD_LINE | PCF_HIDE_NAME | PCF_PARAM_CLASS \
|PCF_SHOW_EVAL | PCF_SHOW_DEFS | PCF_SHOW_NONDEF \
- |PCF_MAIN_OVER)},
+ |PCF_MAIN_OVER | PCF_HIDE_VALUE)},
{PCF_MASTER_ENTRY, (PCF_EDIT_CONF | PCF_EDIT_EXCL | PCF_COMMENT_OUT \
|PCF_FOLD_LINE | PCF_MAIN_OVER | PCF_SHOW_EVAL)},
{PCF_MASTER_FLD, (PCF_EDIT_CONF | PCF_FOLD_LINE | PCF_HIDE_NAME \
- |PCF_MAIN_OVER | PCF_SHOW_EVAL)},
+ |PCF_MAIN_OVER | PCF_SHOW_EVAL | PCF_HIDE_VALUE)},
{PCF_MASTER_PARAM, (PCF_EDIT_CONF | PCF_EDIT_EXCL | PCF_FOLD_LINE \
- |PCF_HIDE_NAME | PCF_MAIN_OVER | PCF_SHOW_EVAL)},
+ |PCF_HIDE_NAME | PCF_MAIN_OVER | PCF_SHOW_EVAL \
+ |PCF_HIDE_VALUE)},
/* Modifiers. */
{PCF_PARAM_CLASS, (PCF_MAIN_PARAM | PCF_SHOW_DEFS | PCF_SHOW_NONDEF)},
0,
"-f", PCF_FOLD_LINE,
"-F", PCF_MASTER_FLD,
"-h", PCF_HIDE_NAME,
+ "-H", PCF_HIDE_VALUE,
"-l", PCF_SHOW_LOCKS,
"-m", PCF_SHOW_MAPS,
"-M", PCF_MASTER_ENTRY,
" [-f (fold lines)]"
" [-F (master.cf fields)]"
" [-h (no names)]"
+ " [-H (no values)]"
" [-l (lock types)]"
" [-m (map types)]"
" [-M (master.cf)]"
/*
* Parse JCL.
*/
- while ((ch = GETOPT(argc, argv, "aAbc:C:deEfFhlmMno:pPtvxX#")) > 0) {
+ while ((ch = GETOPT(argc, argv, "aAbc:C:deEfFhHlmMno:pPtvxX#")) > 0) {
switch (ch) {
case 'a':
pcf_cmd_mode |= PCF_SHOW_SASL_SERV;
case 'h':
pcf_cmd_mode |= PCF_HIDE_NAME;
break;
+ case 'H':
+ pcf_cmd_mode |= PCF_HIDE_VALUE;
+ break;
case 'l':
pcf_cmd_mode |= PCF_SHOW_LOCKS;
break;
#define PCF_MAIN_OVER (1<<17) /* override parameter values */
#define PCF_DUMP_DSN_TEMPL (1<<18) /* show bounce templates */
#define PCF_MASTER_PARAM (1<<19) /* manage master.cf -o name=value */
+#define PCF_HIDE_VALUE (1<<20) /* hide main.cf/master.cf =value */
#define PCF_DEF_MODE 0
/* IBM T.J. Watson Research
/* P.O. Box 704
/* Yorktown Heights, NY 10598, USA
+/*
+/* Wietse Venema
+/* Google, Inc.
+/* 111 8th Avenue
+/* New York, NY 10011, USA
/*--*/
/* IBM T.J. Watson Research
/* P.O. Box 704
/* Yorktown Heights, NY 10598, USA
+/*
+/* Wietse Venema
+/* Google, Inc.
+/* 111 8th Avenue
+/* New York, NY 10011, USA
/*--*/
/* System library. */
/* IBM T.J. Watson Research
/* P.O. Box 704
/* Yorktown Heights, NY 10598, USA
+/*
+/* Wietse Venema
+/* Google, Inc.
+/* 111 8th Avenue
+/* New York, NY 10011, USA
/*--*/
/* System library. */
* or without the name= prefix.
*/
if (value != 0) {
- if ((mode & PCF_SHOW_EVAL) != 0 && PCF_RAW_PARAMETER(node) == 0)
- value = pcf_expand_parameter_value((VSTRING *) 0, mode, value,
- (PCF_MASTER_ENT *) 0);
- if ((mode & PCF_HIDE_NAME) == 0) {
- pcf_print_line(fp, mode, "%s = %s\n", name, value);
+ if (mode & PCF_HIDE_VALUE) {
+ pcf_print_line(fp, mode, "%s\n", name);
} else {
- pcf_print_line(fp, mode, "%s\n", value);
+ if ((mode & PCF_SHOW_EVAL) != 0 && PCF_RAW_PARAMETER(node) == 0)
+ value = pcf_expand_parameter_value((VSTRING *) 0, mode, value,
+ (PCF_MASTER_ENT *) 0);
+ if ((mode & PCF_HIDE_NAME) == 0) {
+ pcf_print_line(fp, mode, "%s = %s\n", name, value);
+ } else {
+ pcf_print_line(fp, mode, "%s\n", value);
+ }
}
if (msg_verbose)
vstream_fflush(fp);
/* IBM T.J. Watson Research
/* P.O. Box 704
/* Yorktown Heights, NY 10598, USA
+/*
+/* Wietse Venema
+/* Google, Inc.
+/* 111 8th Avenue
+/* New York, NY 10011, USA
/*--*/
/* System library. */
ADD_TEXT(argv[1], strlen(argv[1]));
ADD_CHAR(PCF_NAMESP_SEP_STR);
ADD_TEXT(pcf_str_field_pattern(field), strlen(pcf_str_field_pattern(field)));
+ }
+ if ((mode & (PCF_HIDE_NAME | PCF_HIDE_VALUE)) == 0) {
ADD_TEXT(" = ", 3);
- if (line_len + strlen(argv[field]) > PCF_LINE_LIMIT) {
+ }
+ if ((mode & PCF_HIDE_VALUE) == 0) {
+ if (line_len > 0 && line_len + strlen(argv[field]) > PCF_LINE_LIMIT) {
vstream_fputs("\n" PCF_INDENT_TEXT, fp);
line_len = PCF_INDENT_LEN;
}
+ ADD_TEXT(argv[field], strlen(argv[field]));
}
- ADD_TEXT(argv[field], strlen(argv[field]));
/*
* Format the daemon command-line options and non-option arguments. Here,
* we have no data-dependent preference for column positions, but we do
* have argument grouping preferences.
*/
- if (field == PCF_MASTER_FLD_CMD) {
+ if (field == PCF_MASTER_FLD_CMD && (mode & PCF_HIDE_VALUE) == 0) {
in_daemon_options = 1;
for (field += 1; (arg = argv[field]) != 0; field++) {
arg_len = strlen(arg);
const char *param_name,
const char *param_value)
{
- if ((mode & PCF_SHOW_EVAL) != 0)
- param_value = pcf_expand_parameter_value((VSTRING *) 0, mode,
- param_value, masterp);
- if ((mode & PCF_HIDE_NAME) == 0) {
- pcf_print_line(fp, mode, "%s%c%s = %s\n",
+ if (mode & PCF_HIDE_VALUE) {
+ pcf_print_line(fp, mode, "%s%c%s\n",
masterp->name_space, PCF_NAMESP_SEP_CH,
- param_name, param_value);
+ param_name);
} else {
- pcf_print_line(fp, mode, "%s\n", param_value);
+ if ((mode & PCF_SHOW_EVAL) != 0)
+ param_value = pcf_expand_parameter_value((VSTRING *) 0, mode,
+ param_value, masterp);
+ if ((mode & PCF_HIDE_NAME) == 0) {
+ pcf_print_line(fp, mode, "%s%c%s = %s\n",
+ masterp->name_space, PCF_NAMESP_SEP_CH,
+ param_name, param_value);
+ } else {
+ pcf_print_line(fp, mode, "%s\n", param_value);
+ }
}
if (msg_verbose)
vstream_fflush(fp);
/* IBM T.J. Watson Research
/* P.O. Box 704
/* Yorktown Heights, NY 10598, USA
+/*
+/* Wietse Venema
+/* Google, Inc.
+/* 111 8th Avenue
+/* New York, NY 10011, USA
/*--*/
/* System library. */
whatevershebrings_recipient_limit = $default_recipient_limit
whatevershebrings_recipient_refill_delay = $default_recipient_refill_delay
whatevershebrings_recipient_refill_limit = $default_recipient_refill_limit
+whatevershebrings_transport_rate_delay = $default_transport_rate_delay
whatevershebrings_recipient_limit = $default_recipient_limit
whatevershebrings_recipient_refill_delay = $default_recipient_refill_delay
whatevershebrings_recipient_refill_limit = $default_recipient_refill_limit
+whatevershebrings_transport_rate_delay = $default_transport_rate_delay
whatevershebrings_recipient_limit = $default_recipient_limit
whatevershebrings_recipient_refill_delay = $default_recipient_refill_delay
whatevershebrings_recipient_refill_limit = $default_recipient_refill_limit
+whatevershebrings_transport_rate_delay = $default_transport_rate_delay
whatevershebrings_recipient_refill_delay = $default_recipient_refill_delay
whatevershebrings_recipient_refill_limit = $default_recipient_refill_limit
whatevershebrings_time_limit = $command_time_limit
+whatevershebrings_transport_rate_delay = $default_transport_rate_delay
--- /dev/null
+foo
+unix
+-
+n
+n
+-
+0
+other -o always_bcc=bar
--- /dev/null
+foo/unix/service
+foo/unix/type
+foo/unix/private
+foo/unix/unprivileged
+foo/unix/chroot
+foo/unix/wakeup
+foo/unix/process_limit
+foo/unix/command
--- /dev/null
+foo/unix/always_bcc
/* IBM T.J. Watson Research
/* P.O. Box 704
/* Yorktown Heights, NY 10598, USA
+/*
+/* Wietse Venema
+/* Google, Inc.
+/* 111 8th Avenue
+/* New York, NY 10011, USA
/*--*/
/* System library. */
static ARGV *exclude; /* Cached */
SSL *s = 0;
ssl_cipher_stack_t *ciphers;
- SSL_CIPHER *c;
+ const SSL_CIPHER *c;
const cipher_probe_t *probe;
int alg_bits;
int num;