From 6fc47dd726b0b5e7837acfa56cab301723c4008d Mon Sep 17 00:00:00 2001 From: Wietse Venema Date: Sat, 19 Apr 2003 00:00:00 -0500 Subject: [PATCH] postfix-2.0.9-20030419 --- postfix/HISTORY | 6 ++ postfix/html/postcat.1.html | 36 +++++++++--- postfix/html/postsuper.1.html | 5 ++ postfix/man/man1/postcat.1 | 29 ++++++++- postfix/man/man1/postsuper.1 | 3 + postfix/src/global/mail_version.h | 2 +- postfix/src/global/rec_type.c | 16 ++--- postfix/src/postcat/Makefile.in | 3 + postfix/src/postcat/postcat.c | 97 ++++++++++++++++++++++++++----- postfix/src/postfix/postfix.c | 4 +- postfix/src/postsuper/postsuper.c | 3 + postfix/src/sendmail/sendmail.c | 4 +- 12 files changed, 172 insertions(+), 36 deletions(-) diff --git a/postfix/HISTORY b/postfix/HISTORY index 3e6bca4a4..54ca787a7 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -8014,6 +8014,12 @@ Apologies for any names omitted. Bugfix: "sendmail -t" broke with unrecognized message headers. +20030419 + + Feature: "postcat -q" searches the queue for the named file. + + Cleanup: made postcat "record names" output more consistent. + Open problems: Low: smtp-source may block when sending large test messages. diff --git a/postfix/html/postcat.1.html b/postfix/html/postcat.1.html index 94e6d8ee0..3d70fb129 100644 --- a/postfix/html/postcat.1.html +++ b/postfix/html/postcat.1.html @@ -5,25 +5,47 @@ POSTCAT(1) POSTCAT(1) postcat - show Postfix queue file contents SYNOPSIS - postcat [-v] [files...] + postcat [-vq] [-c config_dir] [files...] DESCRIPTION - The postcat command prints the contents of the named Post- - fix queue files in human-readable form. If no files are - specified on the command line, the program reads from - standard input. + The postcat command prints the contents of the named files + in human-readable form. The files are expected to be in + Postfix queue file format. If no files are specified on + the command line, the program reads from standard input. Options: + -c config_dir + The main.cf configuration file is in the named + directory instead of the default configuration + directory. + + -q Search the Postfix queue for files. By default, + file names are taken literally. + -v Enable verbose logging for debugging purposes. Mul- - tiple -v options make the software increasingly + tiple -v options make the software increasingly verbose. DIAGNOSTICS Problems are reported to the standard error stream. +ENVIRONMENT + MAIL_CONFIG + Directory with Postfix configuration files. + +CONFIGURATION PARAMETERS + See the Postfix main.cf file for syntax details and for + default values. Use the postfix reload command after a + configuration change. + + queue_directory + Top-level directory of the Postfix queue. This is + also the root directory of Postfix daemons that run + chrooted. + LICENSE - The Secure Mailer license must be distributed with this + The Secure Mailer license must be distributed with this software. AUTHOR(S) diff --git a/postfix/html/postsuper.1.html b/postfix/html/postsuper.1.html index f80d1da04..2a8ff15ac 100644 --- a/postfix/html/postsuper.1.html +++ b/postfix/html/postsuper.1.html @@ -174,6 +174,11 @@ POSTSUPER(1) POSTSUPER(1) The names of queues that are organized into multi- ple levels of subdirectories. + queue_directory + Top-level directory of the Postfix queue. This is + also the root directory of Postfix daemons that run + chrooted. + SEE ALSO sendmail(1) sendmail-compatible user interface postqueue(1) unprivileged queue operations diff --git a/postfix/man/man1/postcat.1 b/postfix/man/man1/postcat.1 index 2ab5fe048..5b7f28a5f 100644 --- a/postfix/man/man1/postcat.1 +++ b/postfix/man/man1/postcat.1 @@ -8,16 +8,23 @@ show Postfix queue file contents .SH SYNOPSIS .na .nf -\fBpostcat\fR [\fB-v\fR] [\fIfiles\fR...] +\fBpostcat\fR [\fB-vq\fR] [\fB-c \fIconfig_dir\fR] [\fIfiles\fR...] .SH DESCRIPTION .ad .fi The \fBpostcat\fR command prints the contents of the named -Postfix queue \fIfiles\fR in human-readable form. If no +\fIfiles\fR in human-readable form. The files are expected +to be in Postfix queue file format. If no \fIfiles\fR are specified on the command line, the program reads from standard input. Options: +.IP "\fB-c \fIconfig_dir\fR" +The \fBmain.cf\fR configuration file is in the named directory +instead of the default configuration directory. +.IP \fB-q\fR +Search the Postfix queue for \fIfiles\fR. By default, +file names are taken literally. .IP \fB-v\fR Enable verbose logging for debugging purposes. Multiple \fB-v\fR options make the software increasingly verbose. @@ -25,6 +32,24 @@ options make the software increasingly verbose. .ad .fi Problems are reported to the standard error stream. +.SH ENVIRONMENT +.na +.nf +.ad +.fi +.IP \fBMAIL_CONFIG\fR +Directory with Postfix configuration files. +.SH CONFIGURATION PARAMETERS +.na +.nf +.ad +.fi +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 \fBqueue_directory\fR +Top-level directory of the Postfix queue. This is also the root +directory of Postfix daemons that run chrooted. .SH LICENSE .na .nf diff --git a/postfix/man/man1/postsuper.1 b/postfix/man/man1/postsuper.1 index cbd50485d..5cbbbc027 100644 --- a/postfix/man/man1/postsuper.1 +++ b/postfix/man/man1/postsuper.1 @@ -178,6 +178,9 @@ Number of subdirectory levels for hashed queues. .IP \fBhash_queue_names\fR The names of queues that are organized into multiple levels of subdirectories. +.IP \fBqueue_directory\fR +Top-level directory of the Postfix queue. This is also the root +directory of Postfix daemons that run chrooted. .SH SEE ALSO .na .nf diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 35ca549af..fef966f82 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -20,7 +20,7 @@ * Patches change the patchlevel and the release date. Snapshots change the * release date only, unless they include the same bugfix as a patch release. */ -#define MAIL_RELEASE_DATE "20030418" +#define MAIL_RELEASE_DATE "20030419" #define VAR_MAIL_VERSION "mail_version" #define DEF_MAIL_VERSION "2.0.9-" MAIL_RELEASE_DATE diff --git a/postfix/src/global/rec_type.c b/postfix/src/global/rec_type.c index d1e630b37..2f9935919 100644 --- a/postfix/src/global/rec_type.c +++ b/postfix/src/global/rec_type.c @@ -41,25 +41,27 @@ REC_TYPE_NAME rec_type_names[] = { REC_TYPE_EOF, "end-of-file", /* not Postfix-specific. */ REC_TYPE_ERROR, "error", /* not Postfix-specific. */ REC_TYPE_SIZE, "message_size", - REC_TYPE_TIME, "time", - REC_TYPE_FULL, "fullname", + REC_TYPE_TIME, "message_arrival_time", + REC_TYPE_FULL, "sender_fullname", REC_TYPE_INSP, "content_inspector", REC_TYPE_FILT, "content_filter", REC_TYPE_FROM, "sender", - REC_TYPE_DONE, "done", + REC_TYPE_DONE, "done_recipient", REC_TYPE_RCPT, "recipient", - REC_TYPE_ORCP, "original recipient", + REC_TYPE_ORCP, "original_recipient", REC_TYPE_WARN, "warning_message_time", - REC_TYPE_ATTR, "named attribute", + REC_TYPE_ATTR, "named_attribute", REC_TYPE_MESG, "message_content", - REC_TYPE_CONT, "unterminated", - REC_TYPE_NORM, "normal_data", + REC_TYPE_CONT, "unterminated_text", + REC_TYPE_NORM, "regular_text", REC_TYPE_XTRA, "extracted_info", REC_TYPE_RRTO, "return_receipt", REC_TYPE_ERTO, "errors_to", REC_TYPE_PRIO, "priority", REC_TYPE_VERP, "verp_delimiters", REC_TYPE_END, "message_end", + REC_TYPE_RDR, "redirect_to", + REC_TYPE_FLGS, "flags", 0, 0, }; diff --git a/postfix/src/postcat/Makefile.in b/postfix/src/postcat/Makefile.in index 65cf7576f..dca610880 100644 --- a/postfix/src/postcat/Makefile.in +++ b/postfix/src/postcat/Makefile.in @@ -65,3 +65,6 @@ postcat.o: ../../include/msg_vstream.h postcat.o: ../../include/vstring_vstream.h postcat.o: ../../include/record.h postcat.o: ../../include/rec_type.h +postcat.o: ../../include/mail_queue.h +postcat.o: ../../include/mail_conf.h +postcat.o: ../../include/mail_params.h diff --git a/postfix/src/postcat/postcat.c b/postfix/src/postcat/postcat.c index 824c95422..993528a17 100644 --- a/postfix/src/postcat/postcat.c +++ b/postfix/src/postcat/postcat.c @@ -4,19 +4,40 @@ /* SUMMARY /* show Postfix queue file contents /* SYNOPSIS -/* \fBpostcat\fR [\fB-v\fR] [\fIfiles\fR...] +/* \fBpostcat\fR [\fB-vq\fR] [\fB-c \fIconfig_dir\fR] [\fIfiles\fR...] /* DESCRIPTION /* The \fBpostcat\fR command prints the contents of the named -/* Postfix queue \fIfiles\fR in human-readable form. If no +/* \fIfiles\fR in human-readable form. The files are expected +/* to be in Postfix queue file format. If no /* \fIfiles\fR are specified on the command line, the program /* reads from standard input. /* /* Options: +/* .IP "\fB-c \fIconfig_dir\fR" +/* The \fBmain.cf\fR configuration file is in the named directory +/* instead of the default configuration directory. +/* .IP \fB-q\fR +/* Search the Postfix queue for \fIfiles\fR. By default, +/* file names are taken literally. /* .IP \fB-v\fR /* Enable verbose logging for debugging purposes. Multiple \fB-v\fR /* options make the software increasingly verbose. /* DIAGNOSTICS /* Problems are reported to the standard error stream. +/* ENVIRONMENT +/* .ad +/* .fi +/* .IP \fBMAIL_CONFIG\fR +/* Directory with Postfix configuration files. +/* CONFIGURATION PARAMETERS +/* .ad +/* .fi +/* 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 \fBqueue_directory\fR +/* Top-level directory of the Postfix queue. This is also the root +/* directory of Postfix daemons that run chrooted. /* LICENSE /* .ad /* .fi @@ -49,9 +70,14 @@ #include #include +#include +#include +#include /* Application-specific. */ +#define PC_FLAG_QUEUE (1<<0) /* search queue */ + #define STR vstring_str /* postcat - visualize Postfix queue file contents */ @@ -86,7 +112,7 @@ static void postcat(VSTREAM *fp, VSTRING *buffer) if (rec_type == REC_TYPE_ERROR) msg_fatal("record read error"); if (rec_type == REC_TYPE_EOF) - return; + break; if (first == 1) { vstream_printf("*** ENVELOPE RECORDS %s ***\n", VSTREAM_PATH(fp)); first = 0; @@ -94,26 +120,23 @@ static void postcat(VSTREAM *fp, VSTRING *buffer) if (prev_type == REC_TYPE_CONT && !TEXT_RECORD(rec_type)) VSTREAM_PUTCHAR('\n'); switch (rec_type) { - case REC_TYPE_SIZE: - vstream_printf("message_size: %s\n", STR(buffer)); - break; case REC_TYPE_TIME: - time = atol(STR(buffer)); - vstream_printf("arrival_time: %s", asctime(localtime(&time))); - break; case REC_TYPE_WARN: time = atol(STR(buffer)); - vstream_printf("defer_warn_time: %s", asctime(localtime(&time))); + vstream_printf("%s: %s", rec_type_name(rec_type), + asctime(localtime(&time))); break; case REC_TYPE_CONT: if (msg_verbose) - vstream_printf("non-final line fragment: %s\n", STR(buffer)); + vstream_printf("%s: %s\n", rec_type_name(rec_type), + STR(buffer)); else vstream_printf("%s", STR(buffer)); break; case REC_TYPE_NORM: if (msg_verbose) - vstream_printf("final line fragment: %s\n", STR(buffer)); + vstream_printf("%s: %s\n", rec_type_name(rec_type), + STR(buffer)); else vstream_printf("%s\n", STR(buffer)); break; @@ -131,15 +154,16 @@ static void postcat(VSTREAM *fp, VSTRING *buffer) break; } prev_type = rec_type; - vstream_fflush(VSTREAM_OUT); } + vstream_fflush(VSTREAM_OUT); } /* usage - explain and terminate */ static NORETURN usage(char *myname) { - msg_fatal("usage: %s [-v] [file(s)...]", myname); + msg_fatal("usage: %s [-c config_dir] [-q (access queue)] [-v] [file(s)...]", + myname); } int main(int argc, char **argv) @@ -149,6 +173,17 @@ int main(int argc, char **argv) int ch; int fd; struct stat st; + int flags = 0; + static char *queue_names[] = { + MAIL_QUEUE_MAILDROP, + MAIL_QUEUE_INCOMING, + MAIL_QUEUE_ACTIVE, + MAIL_QUEUE_DEFERRED, + MAIL_QUEUE_HOLD, + 0, + }; + char **cpp; + int tries; /* * To minimize confusion, make sure that the standard file descriptors @@ -168,8 +203,15 @@ int main(int argc, char **argv) /* * Parse JCL. */ - while ((ch = GETOPT(argc, argv, "v")) > 0) { + while ((ch = GETOPT(argc, argv, "c:qv")) > 0) { switch (ch) { + case 'c': + if (setenv(CONF_ENV_PATH, optarg, 1) < 0) + msg_fatal("out of memory"); + break; + case 'q': + flags |= PC_FLAG_QUEUE; + break; case 'v': msg_verbose++; break; @@ -178,6 +220,11 @@ int main(int argc, char **argv) } } + /* + * Further initialization... + */ + mail_conf_read(); + /* * Initialize. */ @@ -193,6 +240,22 @@ int main(int argc, char **argv) postcat(VSTREAM_IN, buffer); } + /* + * Copy the named queue files in the specified order. + */ + else if (flags & PC_FLAG_QUEUE) { + if (chdir(var_queue_dir)) + msg_fatal("chdir %s: %m", var_queue_dir); + while (optind < argc) { + for (fp = 0, tries = 0; fp == 0 && tries < 2; tries++) + for (cpp = queue_names; fp == 0 && *cpp != 0; cpp++) + fp = mail_queue_open(*cpp, argv[optind], O_RDONLY, 0); + if (fp == 0) + msg_fatal("open queue file %s: %m", argv[optind]); + optind++; + } + } + /* * Copy the named files in the specified order. */ @@ -206,6 +269,10 @@ int main(int argc, char **argv) optind++; } } + + /* + * Clean up. + */ vstring_free(buffer); exit(0); } diff --git a/postfix/src/postfix/postfix.c b/postfix/src/postfix/postfix.c index 5912b7bf0..51ee0ea9a 100644 --- a/postfix/src/postfix/postfix.c +++ b/postfix/src/postfix/postfix.c @@ -257,9 +257,7 @@ int main(int argc, char **argv) /* * Copy a bunch of configuration parameters into the environment for easy - * access by the maintenance shell script. XXX There should be a postconf - * utility that makes config parameters easily accessible for shell - * scripts. + * access by the maintenance shell script. */ mail_conf_read(); get_mail_conf_str_table(str_table); diff --git a/postfix/src/postsuper/postsuper.c b/postfix/src/postsuper/postsuper.c index a5c4ded86..7c8989893 100644 --- a/postfix/src/postsuper/postsuper.c +++ b/postfix/src/postsuper/postsuper.c @@ -164,6 +164,9 @@ /* .IP \fBhash_queue_names\fR /* The names of queues that are organized into multiple levels of /* subdirectories. +/* .IP \fBqueue_directory\fR +/* Top-level directory of the Postfix queue. This is also the root +/* directory of Postfix daemons that run chrooted. /* SEE ALSO /* sendmail(1) sendmail-compatible user interface /* postqueue(1) unprivileged queue operations diff --git a/postfix/src/sendmail/sendmail.c b/postfix/src/sendmail/sendmail.c index 184d28304..fd12206f1 100644 --- a/postfix/src/sendmail/sendmail.c +++ b/postfix/src/sendmail/sendmail.c @@ -633,7 +633,9 @@ static void enqueue(const int flags, const char *encoding, const char *sender, } /* - * Finish up MIME processing. + * Finish MIME processing. We need a final mime_state_update() call in + * order to flush text that is still buffered. That can happen when the + * last line did not end in newline. */ if (mime_state) { mime_errs = mime_state_update(mime_state, REC_TYPE_EOF, "", 0);