diff --git a/postfix/HISTORY b/postfix/HISTORY index 79c4f0881..f245078d8 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -18185,9 +18185,16 @@ Apologies for any names omitted. 20121226 - Miscellaneous cleanups of postconf internal APIs, - identifiers and comments. No changes in behavior. + Miscellaneous cleanups of postconf internal APIs, identifiers + and comments. No changes in behavior. - Bugfix (omission in feature 20111203): the SMTP server + Bugfix (omission in feature 20111203): the SMTP server only supported time-dependent address-verification sender addresses - only with RCPT TO but not with MAIL FROM. File: smtpd/smtpd.c. + with RCPT TO but not with MAIL FROM. File: smtpd/smtpd.c. + +20121227 + + Feature: "postconf -o name=value" support to override main.cf + settings (for example, "postconf -x -o stress=whatever" + shows effective settings under overload). Files: + postconf/postconf.c, postconf/postconf_main.c. diff --git a/postfix/RELEASE_NOTES b/postfix/RELEASE_NOTES index ccd464e83..8a70de043 100644 --- a/postfix/RELEASE_NOTES +++ b/postfix/RELEASE_NOTES @@ -36,8 +36,8 @@ expanded parameter values. - "postconf -x" now expands $name in main.cf and master.cf parameter values. -- "postconf -Mn" now shows only master.cf entries with "-o name=value" - parameter settings. +- "postconf -Mn" now shows services that have "-o name=value" + parameter settings in master.cf. - postconf warns about attempts to modify a read-only parameter (process_name, process_id) in main.cf or master.cf. @@ -46,6 +46,12 @@ expanded parameter values. main.cf or master.cf (except for backwards-compatibility parameters such as $virtual_maps). +Added with snapshot 20121227: + +- "postconf -o name=value" overrides main.cf parameter settings. + This can be used, for example, to examine stress-dependent settings + with "postconf -x -o stress=yes". + Incompatible changes with snapshot 20121123 =========================================== diff --git a/postfix/WISHLIST b/postfix/WISHLIST index 130a442d4..2fad322d2 100644 --- a/postfix/WISHLIST +++ b/postfix/WISHLIST @@ -11,6 +11,8 @@ Wish list: Don't forget Apple's code donation for fetching mail from IMAP server. + Should postconf -o refuse to work without the -x option? + Make errno white/blacklist for getpwnam_r etc. and mailbox write errors. diff --git a/postfix/html/postconf.1.html b/postfix/html/postconf.1.html index 3c7f55962..edc146836 100644 --- a/postfix/html/postconf.1.html +++ b/postfix/html/postconf.1.html @@ -12,8 +12,8 @@ POSTCONF(1) POSTCONF(1) SYNOPSIS Managing main.cf: - postconf [-dfhnvx] [-c config_dir] [-C class,...] [parame- - ter ...] + postconf [-dfhnovx] [-c config_dir] [-C class,...] [param- + eter ...] postconf [-ev] [-c config_dir] [parameter=value ...] @@ -21,7 +21,7 @@ POSTCONF(1) POSTCONF(1) Managing master.cf: - postconf [-fMnvx] [-c config_dir] [service ...] + postconf [-fMnovx] [-c config_dir] [service ...] Managing bounce message templates: @@ -115,7 +115,7 @@ POSTCONF(1) POSTCONF(1) for human readability (Postfix 2.9 and later). -e Edit the main.cf configuration file, and update - parameter settings with the "name=value" pairs on + parameter settings with the "name=value" pairs on the postconf(1) command line. The file is copied to a temporary file then renamed into place. Specify quotes to protect special characters and whitespace @@ -295,12 +295,19 @@ POSTCONF(1) POSTCONF(1) This feature is available with Postfix 2.9 and later. - -n Print only name=value parameter settings that are - explicitly specified in main.cf. When specified - with -M, print only master.cf entries that have "-o - name=value" parameter settings (Postfix 2.10 and - later). Specify -nf to fold long lines for human - readability (Postfix 2.9 and later). + -n Show only configuration parameters that have + explicit name=value settings in main.cf. When + specified with -M, show only services that have + explicit "-o name=value" settings in master.cf + (Postfix 2.10 and later). Specify -nf to fold long + lines for human readability (Postfix 2.9 and + later). + + -o name=value + Override main.cf parameter settings. + + This feature is available with Postfix 2.10 and + later. -t [template_file] Display the templates for text that appears at the @@ -333,7 +340,7 @@ POSTCONF(1) POSTCONF(1) parameters named on the postconf(1) command line. The file is copied to a temporary file then renamed into place. Specify a list of parameter names, not - "name=value" pairs. There is no postconf(1) com- + "name=value" pairs. There is no postconf(1) com- mand to perform the reverse operation. This feature is available with Postfix 2.10 and @@ -344,7 +351,7 @@ POSTCONF(1) POSTCONF(1) line, so that those parameters revert to their default values. The file is copied to a temporary file then renamed into place. Specify a list of - parameter names, not "name=value" pairs. There is + parameter names, not "name=value" pairs. There is no postconf(1) command to perform the reverse oper- ation. diff --git a/postfix/man/man1/postconf.1 b/postfix/man/man1/postconf.1 index a9903f4ca..c45a2d7ee 100644 --- a/postfix/man/man1/postconf.1 +++ b/postfix/man/man1/postconf.1 @@ -11,7 +11,7 @@ Postfix configuration utility .fi \fBManaging main.cf:\fR -\fBpostconf\fR [\fB-dfhnvx\fR] [\fB-c \fIconfig_dir\fR] +\fBpostconf\fR [\fB-dfhnovx\fR] [\fB-c \fIconfig_dir\fR] [\fB-C \fIclass,...\fR] [\fIparameter ...\fR] \fBpostconf\fR [\fB-ev\fR] [\fB-c \fIconfig_dir\fR] @@ -22,7 +22,7 @@ Postfix configuration utility \fBManaging master.cf:\fR -\fBpostconf\fR [\fB-fMnvx\fR] [\fB-c \fIconfig_dir\fR] +\fBpostconf\fR [\fB-fMnovx\fR] [\fB-c \fIconfig_dir\fR] [\fIservice ...\fR] \fBManaging bounce message templates:\fR @@ -114,7 +114,7 @@ Specify \fB-df\fR to fold long lines for human readability (Postfix 2.9 and later). .IP \fB-e\fR Edit the \fBmain.cf\fR configuration file, and update -parameter settings with the "\fIname\fR=\fIvalue\fR" pairs +parameter settings with the "\fIname=value\fR" pairs on the \fBpostconf\fR(1) command line. The file is copied to a temporary file then renamed into place. Specify quotes to protect special characters and whitespace @@ -259,13 +259,17 @@ or with a \fIservice-name.service-type\fR pair, where This feature is available with Postfix 2.9 and later. .IP \fB-n\fR -Print only \fIname\fR=\fIvalue\fR parameter settings that -are explicitly specified in \fBmain.cf\fR. When specified -with \fB-M\fR, print only \fBmaster.cf\fR entries that have -"-o \fIname\fR=\fIvalue\fR" parameter settings (Postfix -2.10 and later). +Show only configuration parameters that have explicit +\fIname=value\fR settings in \fBmain.cf\fR. +When specified with \fB-M\fR, show only services that have +explicit "-o \fIname=value\fR" settings in \fBmaster.cf\fR +(Postfix 2.10 and later). Specify \fB-nf\fR to fold long lines for human readability (Postfix 2.9 and later). +.IP "\fB-o \fIname=value\fR" +Override \fBmain.cf\fR parameter settings. + +This feature is available with Postfix 2.10 and later. .IP "\fB-t\fR [\fItemplate_file\fR]" Display the templates for text that appears at the beginning of delivery status notification (DSN) messages, without @@ -294,7 +298,7 @@ Edit the \fBmain.cf\fR configuration file, and remove the parameters named on the \fBpostconf\fR(1) command line. The file is copied to a temporary file then renamed into place. -Specify a list of parameter names, not "\fIname\fR=\fIvalue\fR" +Specify a list of parameter names, not "\fIname=value\fR" pairs. There is no \fBpostconf\fR(1) command to perform the reverse operation. @@ -305,7 +309,7 @@ the parameters named on the \fBpostconf\fR(1) command line, so that those parameters revert to their default values. The file is copied to a temporary file then renamed into place. -Specify a list of parameter names, not "\fIname\fR=\fIvalue\fR" +Specify a list of parameter names, not "\fIname=value\fR" pairs. There is no \fBpostconf\fR(1) command to perform the reverse operation. diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 9cd5501ee..9e5aa210c 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -20,7 +20,7 @@ * Patches change both the patchlevel and the release date. Snapshots have no * patchlevel; they change the release date only. */ -#define MAIL_RELEASE_DATE "20121226" +#define MAIL_RELEASE_DATE "20121227" #define MAIL_VERSION_NUMBER "2.10" #ifdef SNAPSHOT diff --git a/postfix/src/postconf/postconf.c b/postfix/src/postconf/postconf.c index e4619e11b..71969edc3 100644 --- a/postfix/src/postconf/postconf.c +++ b/postfix/src/postconf/postconf.c @@ -7,7 +7,7 @@ /* .fi /* \fBManaging main.cf:\fR /* -/* \fBpostconf\fR [\fB-dfhnvx\fR] [\fB-c \fIconfig_dir\fR] +/* \fBpostconf\fR [\fB-dfhnovx\fR] [\fB-c \fIconfig_dir\fR] /* [\fB-C \fIclass,...\fR] [\fIparameter ...\fR] /* /* \fBpostconf\fR [\fB-ev\fR] [\fB-c \fIconfig_dir\fR] @@ -18,7 +18,7 @@ /* /* \fBManaging master.cf:\fR /* -/* \fBpostconf\fR [\fB-fMnvx\fR] [\fB-c \fIconfig_dir\fR] +/* \fBpostconf\fR [\fB-fMnovx\fR] [\fB-c \fIconfig_dir\fR] /* [\fIservice ...\fR] /* /* \fBManaging bounce message templates:\fR @@ -108,7 +108,7 @@ /* (Postfix 2.9 and later). /* .IP \fB-e\fR /* Edit the \fBmain.cf\fR configuration file, and update -/* parameter settings with the "\fIname\fR=\fIvalue\fR" pairs +/* parameter settings with the "\fIname=value\fR" pairs /* on the \fBpostconf\fR(1) command line. The file is copied /* to a temporary file then renamed into place. /* Specify quotes to protect special characters and whitespace @@ -253,13 +253,17 @@ /* /* This feature is available with Postfix 2.9 and later. /* .IP \fB-n\fR -/* Print only \fIname\fR=\fIvalue\fR parameter settings that -/* are explicitly specified in \fBmain.cf\fR. When specified -/* with \fB-M\fR, print only \fBmaster.cf\fR entries that have -/* "-o \fIname\fR=\fIvalue\fR" parameter settings (Postfix -/* 2.10 and later). +/* Show only configuration parameters that have explicit +/* \fIname=value\fR settings in \fBmain.cf\fR. +/* When specified with \fB-M\fR, show only services that have +/* explicit "-o \fIname=value\fR" settings in \fBmaster.cf\fR +/* (Postfix 2.10 and later). /* Specify \fB-nf\fR to fold long lines for human readability /* (Postfix 2.9 and later). +/* .IP "\fB-o \fIname=value\fR" +/* Override \fBmain.cf\fR parameter settings. +/* +/* This feature is available with Postfix 2.10 and later. /* .IP "\fB-t\fR [\fItemplate_file\fR]" /* Display the templates for text that appears at the beginning /* of delivery status notification (DSN) messages, without @@ -288,7 +292,7 @@ /* the parameters named on the \fBpostconf\fR(1) command line. /* The file is copied to a temporary file then renamed into /* place. -/* Specify a list of parameter names, not "\fIname\fR=\fIvalue\fR" +/* Specify a list of parameter names, not "\fIname=value\fR" /* pairs. There is no \fBpostconf\fR(1) command to perform /* the reverse operation. /* @@ -299,7 +303,7 @@ /* so that those parameters revert to their default values. /* The file is copied to a temporary file then renamed into /* place. -/* Specify a list of parameter names, not "\fIname\fR=\fIvalue\fR" +/* Specify a list of parameter names, not "\fIname=value\fR" /* pairs. There is no \fBpostconf\fR(1) command to perform /* the reverse operation. /* @@ -367,6 +371,7 @@ #include #include #include +#include /* Global library. */ @@ -409,6 +414,7 @@ int main(int argc, char **argv) "all", PC_PARAM_MASK_CLASS, 0, }; + ARGV *override_params = 0; /* * Fingerprint executables and core dumps. @@ -438,7 +444,7 @@ int main(int argc, char **argv) /* * Parse JCL. */ - while ((ch = GETOPT(argc, argv, "aAbc:C:deEf#hlmMntvxX")) > 0) { + while ((ch = GETOPT(argc, argv, "aAbc:C:deEf#hlmMno:tvxX")) > 0) { switch (ch) { case 'a': cmd_mode |= SHOW_SASL_SERV; @@ -469,11 +475,9 @@ int main(int argc, char **argv) case 'f': cmd_mode |= FOLD_LINE; break; - case '#': cmd_mode = COMMENT_OUT; break; - case 'h': cmd_mode &= ~SHOW_NAME; break; @@ -489,6 +493,11 @@ int main(int argc, char **argv) case 'n': cmd_mode |= SHOW_NONDEF; break; + case 'o': + if (override_params == 0) + override_params = argv_alloc(2); + argv_add(override_params, optarg, (char *) 0); + break; case 't': if (ext_argv) msg_fatal("specify one of -b and -t"); @@ -525,6 +534,8 @@ int main(int argc, char **argv) msg_fatal("do not specify -x with -a, -A, -b, -e, -#, -l, -m, or -X"); if ((cmd_mode & SHOW_NONDEF) != 0 && junk != 0 && junk != SHOW_MASTER) msg_fatal("do not specify -n with -a, -A, -b, -d, -e, -#, -l, -m, or -X"); + if (override_params != 0 && junk != 0 && junk != SHOW_MASTER) + msg_fatal("do not specify -o with -a, -A, -b, -d, -e, -#, -l, -m, or -X"); /* * Display bounce template information and exit. @@ -568,6 +579,8 @@ int main(int argc, char **argv) else if (cmd_mode & SHOW_MASTER) { read_master(FAIL_ON_OPEN_ERROR); read_parameters(); + if (override_params) + set_parameters(override_params->argv); register_builtin_parameters(basename(argv[0]), getpid()); register_service_parameters(); register_user_parameters(); @@ -599,6 +612,8 @@ int main(int argc, char **argv) else { if ((cmd_mode & SHOW_DEFS) == 0) { read_parameters(); + if (override_params) + set_parameters(override_params->argv); } register_builtin_parameters(basename(argv[0]), getpid()); diff --git a/postfix/src/postconf/postconf.h b/postfix/src/postconf/postconf.h index 363d4d48d..ca575c125 100644 --- a/postfix/src/postconf/postconf.h +++ b/postfix/src/postconf/postconf.h @@ -141,7 +141,7 @@ extern void set_config_dir(void); * postconf_main.c */ extern void read_parameters(void); -extern void set_parameters(void); +extern void set_parameters(char **); extern void show_parameters(int, int, char **); /* diff --git a/postfix/src/postconf/postconf_main.c b/postfix/src/postconf/postconf_main.c index a2e2e34aa..8b89476ee 100644 --- a/postfix/src/postconf/postconf_main.c +++ b/postfix/src/postconf/postconf_main.c @@ -15,6 +15,9 @@ /* DESCRIPTION /* read_parameters() reads parameters from main.cf. /* +/* set_parameters() takes an array of \fIname=value\fR pairs +/* and overrides settings read with read_parameters(). +/* /* show_parameters() writes main.cf parameters to the standard /* output stream. /* @@ -106,6 +109,23 @@ void read_parameters(void) myfree(path); } +/* set_parameters - add or override name=value pairs */ + +void set_parameters(char **name_val_array) +{ + char *name, *value, *junk; + const char *err; + char **cpp; + + for (cpp = name_val_array; *cpp; cpp++) { + junk = mystrdup(*cpp); + if ((err = split_nameval(junk, &name, &value)) != 0) + msg_fatal("invalid parameter override: %s: %s", *cpp, err); + mail_conf_update(name, value); + myfree(junk); + } +} + /* print_line - show line possibly folded, and with normalized whitespace */ static void print_line(int mode, const char *fmt,...)