2
0
mirror of https://github.com/vdukhovni/postfix synced 2025-08-31 14:17:41 +00:00

postfix-2.0.9-20030419

This commit is contained in:
Wietse Venema
2003-04-19 00:00:00 -05:00
committed by Viktor Dukhovni
parent 840fbea730
commit 6fc47dd726
12 changed files with 172 additions and 36 deletions

View File

@@ -8014,6 +8014,12 @@ Apologies for any names omitted.
Bugfix: "sendmail -t" broke with unrecognized message headers. 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: Open problems:
Low: smtp-source may block when sending large test messages. Low: smtp-source may block when sending large test messages.

View File

@@ -5,25 +5,47 @@ POSTCAT(1) POSTCAT(1)
postcat - show Postfix queue file contents postcat - show Postfix queue file contents
<b>SYNOPSIS</b> <b>SYNOPSIS</b>
<b>postcat</b> [<b>-v</b>] [<i>files</i>...] <b>postcat</b> [<b>-vq</b>] [<b>-c</b> <i>config_dir</i>] [<i>files</i>...]
<b>DESCRIPTION</b> <b>DESCRIPTION</b>
The <b>postcat</b> command prints the contents of the named Post- The <b>postcat</b> command prints the contents of the named <i>files</i>
fix queue <i>files</i> in human-readable form. If no <i>files</i> are in human-readable form. The files are expected to be in
specified on the command line, the program reads from Postfix queue file format. If no <i>files</i> are specified on
standard input. the command line, the program reads from standard input.
Options: Options:
<b>-c</b> <i>config_dir</i>
The <b>main.cf</b> configuration file is in the named
directory instead of the default configuration
directory.
<b>-q</b> Search the Postfix queue for <i>files</i>. By default,
file names are taken literally.
<b>-v</b> Enable verbose logging for debugging purposes. Mul- <b>-v</b> Enable verbose logging for debugging purposes. Mul-
tiple <b>-v</b> options make the software increasingly tiple <b>-v</b> options make the software increasingly
verbose. verbose.
<b>DIAGNOSTICS</b> <b>DIAGNOSTICS</b>
Problems are reported to the standard error stream. Problems are reported to the standard error stream.
<b>ENVIRONMENT</b>
<b>MAIL</b><i>_</i><b>CONFIG</b>
Directory with Postfix configuration files.
<b>CONFIGURATION</b> <b>PARAMETERS</b>
See the Postfix <b>main.cf</b> file for syntax details and for
default values. Use the <b>postfix</b> <b>reload</b> command after a
configuration change.
<b>queue</b><i>_</i><b>directory</b>
Top-level directory of the Postfix queue. This is
also the root directory of Postfix daemons that run
chrooted.
<b>LICENSE</b> <b>LICENSE</b>
The Secure Mailer license must be distributed with this The Secure Mailer license must be distributed with this
software. software.
<b>AUTHOR(S)</b> <b>AUTHOR(S)</b>

View File

@@ -174,6 +174,11 @@ POSTSUPER(1) POSTSUPER(1)
The names of queues that are organized into multi- The names of queues that are organized into multi-
ple levels of subdirectories. ple levels of subdirectories.
<b>queue</b><i>_</i><b>directory</b>
Top-level directory of the Postfix queue. This is
also the root directory of Postfix daemons that run
chrooted.
<b>SEE</b> <b>ALSO</b> <b>SEE</b> <b>ALSO</b>
<a href="sendmail.1.html">sendmail(1)</a> sendmail-compatible user interface <a href="sendmail.1.html">sendmail(1)</a> sendmail-compatible user interface
<a href="postqueue.1.html">postqueue(1)</a> unprivileged queue operations <a href="postqueue.1.html">postqueue(1)</a> unprivileged queue operations

View File

@@ -8,16 +8,23 @@ show Postfix queue file contents
.SH SYNOPSIS .SH SYNOPSIS
.na .na
.nf .nf
\fBpostcat\fR [\fB-v\fR] [\fIfiles\fR...] \fBpostcat\fR [\fB-vq\fR] [\fB-c \fIconfig_dir\fR] [\fIfiles\fR...]
.SH DESCRIPTION .SH DESCRIPTION
.ad .ad
.fi .fi
The \fBpostcat\fR command prints the contents of the named 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 \fIfiles\fR are specified on the command line, the program
reads from standard input. reads from standard input.
Options: 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 .IP \fB-v\fR
Enable verbose logging for debugging purposes. Multiple \fB-v\fR Enable verbose logging for debugging purposes. Multiple \fB-v\fR
options make the software increasingly verbose. options make the software increasingly verbose.
@@ -25,6 +32,24 @@ options make the software increasingly verbose.
.ad .ad
.fi .fi
Problems are reported to the standard error stream. 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 .SH LICENSE
.na .na
.nf .nf

View File

@@ -178,6 +178,9 @@ Number of subdirectory levels for hashed queues.
.IP \fBhash_queue_names\fR .IP \fBhash_queue_names\fR
The names of queues that are organized into multiple levels of The names of queues that are organized into multiple levels of
subdirectories. 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 .SH SEE ALSO
.na .na
.nf .nf

View File

@@ -20,7 +20,7 @@
* Patches change the patchlevel and the release date. Snapshots change the * Patches change the patchlevel and the release date. Snapshots change the
* release date only, unless they include the same bugfix as a patch release. * 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 VAR_MAIL_VERSION "mail_version"
#define DEF_MAIL_VERSION "2.0.9-" MAIL_RELEASE_DATE #define DEF_MAIL_VERSION "2.0.9-" MAIL_RELEASE_DATE

View File

@@ -41,25 +41,27 @@ REC_TYPE_NAME rec_type_names[] = {
REC_TYPE_EOF, "end-of-file", /* not Postfix-specific. */ REC_TYPE_EOF, "end-of-file", /* not Postfix-specific. */
REC_TYPE_ERROR, "error", /* not Postfix-specific. */ REC_TYPE_ERROR, "error", /* not Postfix-specific. */
REC_TYPE_SIZE, "message_size", REC_TYPE_SIZE, "message_size",
REC_TYPE_TIME, "time", REC_TYPE_TIME, "message_arrival_time",
REC_TYPE_FULL, "fullname", REC_TYPE_FULL, "sender_fullname",
REC_TYPE_INSP, "content_inspector", REC_TYPE_INSP, "content_inspector",
REC_TYPE_FILT, "content_filter", REC_TYPE_FILT, "content_filter",
REC_TYPE_FROM, "sender", REC_TYPE_FROM, "sender",
REC_TYPE_DONE, "done", REC_TYPE_DONE, "done_recipient",
REC_TYPE_RCPT, "recipient", REC_TYPE_RCPT, "recipient",
REC_TYPE_ORCP, "original recipient", REC_TYPE_ORCP, "original_recipient",
REC_TYPE_WARN, "warning_message_time", REC_TYPE_WARN, "warning_message_time",
REC_TYPE_ATTR, "named attribute", REC_TYPE_ATTR, "named_attribute",
REC_TYPE_MESG, "message_content", REC_TYPE_MESG, "message_content",
REC_TYPE_CONT, "unterminated", REC_TYPE_CONT, "unterminated_text",
REC_TYPE_NORM, "normal_data", REC_TYPE_NORM, "regular_text",
REC_TYPE_XTRA, "extracted_info", REC_TYPE_XTRA, "extracted_info",
REC_TYPE_RRTO, "return_receipt", REC_TYPE_RRTO, "return_receipt",
REC_TYPE_ERTO, "errors_to", REC_TYPE_ERTO, "errors_to",
REC_TYPE_PRIO, "priority", REC_TYPE_PRIO, "priority",
REC_TYPE_VERP, "verp_delimiters", REC_TYPE_VERP, "verp_delimiters",
REC_TYPE_END, "message_end", REC_TYPE_END, "message_end",
REC_TYPE_RDR, "redirect_to",
REC_TYPE_FLGS, "flags",
0, 0, 0, 0,
}; };

View File

@@ -65,3 +65,6 @@ postcat.o: ../../include/msg_vstream.h
postcat.o: ../../include/vstring_vstream.h postcat.o: ../../include/vstring_vstream.h
postcat.o: ../../include/record.h postcat.o: ../../include/record.h
postcat.o: ../../include/rec_type.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

View File

@@ -4,19 +4,40 @@
/* SUMMARY /* SUMMARY
/* show Postfix queue file contents /* show Postfix queue file contents
/* SYNOPSIS /* SYNOPSIS
/* \fBpostcat\fR [\fB-v\fR] [\fIfiles\fR...] /* \fBpostcat\fR [\fB-vq\fR] [\fB-c \fIconfig_dir\fR] [\fIfiles\fR...]
/* DESCRIPTION /* DESCRIPTION
/* The \fBpostcat\fR command prints the contents of the named /* 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 /* \fIfiles\fR are specified on the command line, the program
/* reads from standard input. /* reads from standard input.
/* /*
/* Options: /* 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 /* .IP \fB-v\fR
/* Enable verbose logging for debugging purposes. Multiple \fB-v\fR /* Enable verbose logging for debugging purposes. Multiple \fB-v\fR
/* options make the software increasingly verbose. /* options make the software increasingly verbose.
/* DIAGNOSTICS /* DIAGNOSTICS
/* Problems are reported to the standard error stream. /* 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 /* LICENSE
/* .ad /* .ad
/* .fi /* .fi
@@ -49,9 +70,14 @@
#include <record.h> #include <record.h>
#include <rec_type.h> #include <rec_type.h>
#include <mail_queue.h>
#include <mail_conf.h>
#include <mail_params.h>
/* Application-specific. */ /* Application-specific. */
#define PC_FLAG_QUEUE (1<<0) /* search queue */
#define STR vstring_str #define STR vstring_str
/* postcat - visualize Postfix queue file contents */ /* postcat - visualize Postfix queue file contents */
@@ -86,7 +112,7 @@ static void postcat(VSTREAM *fp, VSTRING *buffer)
if (rec_type == REC_TYPE_ERROR) if (rec_type == REC_TYPE_ERROR)
msg_fatal("record read error"); msg_fatal("record read error");
if (rec_type == REC_TYPE_EOF) if (rec_type == REC_TYPE_EOF)
return; break;
if (first == 1) { if (first == 1) {
vstream_printf("*** ENVELOPE RECORDS %s ***\n", VSTREAM_PATH(fp)); vstream_printf("*** ENVELOPE RECORDS %s ***\n", VSTREAM_PATH(fp));
first = 0; first = 0;
@@ -94,26 +120,23 @@ static void postcat(VSTREAM *fp, VSTRING *buffer)
if (prev_type == REC_TYPE_CONT && !TEXT_RECORD(rec_type)) if (prev_type == REC_TYPE_CONT && !TEXT_RECORD(rec_type))
VSTREAM_PUTCHAR('\n'); VSTREAM_PUTCHAR('\n');
switch (rec_type) { switch (rec_type) {
case REC_TYPE_SIZE:
vstream_printf("message_size: %s\n", STR(buffer));
break;
case REC_TYPE_TIME: case REC_TYPE_TIME:
time = atol(STR(buffer));
vstream_printf("arrival_time: %s", asctime(localtime(&time)));
break;
case REC_TYPE_WARN: case REC_TYPE_WARN:
time = atol(STR(buffer)); 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; break;
case REC_TYPE_CONT: case REC_TYPE_CONT:
if (msg_verbose) 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 else
vstream_printf("%s", STR(buffer)); vstream_printf("%s", STR(buffer));
break; break;
case REC_TYPE_NORM: case REC_TYPE_NORM:
if (msg_verbose) 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 else
vstream_printf("%s\n", STR(buffer)); vstream_printf("%s\n", STR(buffer));
break; break;
@@ -131,15 +154,16 @@ static void postcat(VSTREAM *fp, VSTRING *buffer)
break; break;
} }
prev_type = rec_type; prev_type = rec_type;
vstream_fflush(VSTREAM_OUT);
} }
vstream_fflush(VSTREAM_OUT);
} }
/* usage - explain and terminate */ /* usage - explain and terminate */
static NORETURN usage(char *myname) 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) int main(int argc, char **argv)
@@ -149,6 +173,17 @@ int main(int argc, char **argv)
int ch; int ch;
int fd; int fd;
struct stat st; 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 * To minimize confusion, make sure that the standard file descriptors
@@ -168,8 +203,15 @@ int main(int argc, char **argv)
/* /*
* Parse JCL. * Parse JCL.
*/ */
while ((ch = GETOPT(argc, argv, "v")) > 0) { while ((ch = GETOPT(argc, argv, "c:qv")) > 0) {
switch (ch) { 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': case 'v':
msg_verbose++; msg_verbose++;
break; break;
@@ -178,6 +220,11 @@ int main(int argc, char **argv)
} }
} }
/*
* Further initialization...
*/
mail_conf_read();
/* /*
* Initialize. * Initialize.
*/ */
@@ -193,6 +240,22 @@ int main(int argc, char **argv)
postcat(VSTREAM_IN, buffer); 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. * Copy the named files in the specified order.
*/ */
@@ -206,6 +269,10 @@ int main(int argc, char **argv)
optind++; optind++;
} }
} }
/*
* Clean up.
*/
vstring_free(buffer); vstring_free(buffer);
exit(0); exit(0);
} }

View File

@@ -257,9 +257,7 @@ int main(int argc, char **argv)
/* /*
* Copy a bunch of configuration parameters into the environment for easy * Copy a bunch of configuration parameters into the environment for easy
* access by the maintenance shell script. XXX There should be a postconf * access by the maintenance shell script.
* utility that makes config parameters easily accessible for shell
* scripts.
*/ */
mail_conf_read(); mail_conf_read();
get_mail_conf_str_table(str_table); get_mail_conf_str_table(str_table);

View File

@@ -164,6 +164,9 @@
/* .IP \fBhash_queue_names\fR /* .IP \fBhash_queue_names\fR
/* The names of queues that are organized into multiple levels of /* The names of queues that are organized into multiple levels of
/* subdirectories. /* 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 /* SEE ALSO
/* sendmail(1) sendmail-compatible user interface /* sendmail(1) sendmail-compatible user interface
/* postqueue(1) unprivileged queue operations /* postqueue(1) unprivileged queue operations

View File

@@ -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) { if (mime_state) {
mime_errs = mime_state_update(mime_state, REC_TYPE_EOF, "", 0); mime_errs = mime_state_update(mime_state, REC_TYPE_EOF, "", 0);