From 3759ff00b1c816640cf1554831020c19c689201b Mon Sep 17 00:00:00 2001 From: Wietse Venema Date: Thu, 8 Mar 2012 00:00:00 -0500 Subject: [PATCH] postfix-2.10-20120308 --- postfix/HISTORY | 16 +++++ postfix/RELEASE_NOTES | 10 +++ postfix/conf/postfix-script | 6 +- postfix/html/master.8.html | 52 ++++++++------ postfix/html/postconf.1.html | 12 +++- postfix/man/man1/postconf.1 | 12 +++- postfix/man/man8/master.8 | 14 +++- postfix/src/global/mail_version.h | 2 +- postfix/src/master/Makefile.in | 11 ++- postfix/src/master/master.c | 42 +++++++++-- postfix/src/master/master.h | 5 ++ postfix/src/master/master_monitor.c | 100 +++++++++++++++++++++++++++ postfix/src/postconf/postconf.c | 31 ++++++--- postfix/src/postconf/postconf.h | 3 +- postfix/src/postconf/postconf_edit.c | 12 ++-- 15 files changed, 280 insertions(+), 48 deletions(-) create mode 100644 postfix/src/master/master_monitor.c diff --git a/postfix/HISTORY b/postfix/HISTORY index de788f25a..4a35978d6 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -17668,3 +17668,19 @@ Apologies for any names omitted. of specific permit-like actions in Postfix SMTP server access lists. Files: mantools/postlink, proto/postconf.proto, global/mail_params.h, smtpd/smtpd.c, smtpd/smtpd_check.c. + +20120306 + + To improve the interaction with start-up scripts, "postfix + start" now waits for master daemon process initialization + to complete, and returns a non-zero exit status if daemon + initialization failed or if it did not complete in a + reasonable amount of time. This involves a new "-w" master + option. Files: conf/postfix-script, master/master.c, + master/master.h. master/master_monitor.c. + +20120307 + + postconf -X option to exclude parameters from main.cf + (require two-finger action, because this is irreversible). + Files: postconf/postconf.[hc], postconf/postconf_edit.c. diff --git a/postfix/RELEASE_NOTES b/postfix/RELEASE_NOTES index aeed5bf10..dea294e29 100644 --- a/postfix/RELEASE_NOTES +++ b/postfix/RELEASE_NOTES @@ -14,6 +14,16 @@ specifies the release date of a stable release or snapshot release. If you upgrade from Postfix 2.8 or earlier, read RELEASE_NOTES-2.9 before proceeding. +Major changes with snapshot 20120306 +==================================== + +New master "-w" option, to wait for daemon process initialization +to complete. This feature returns an error exit status if master +daemon initialization fails, or if it does not complete in a +reasonable amount of time. The exit status is used by "postfix +start" to provide more accurate information to system start-up +scripts. + Major changes with snapshot 20120303 ==================================== diff --git a/postfix/conf/postfix-script b/postfix/conf/postfix-script index 805e288e7..68c663fd1 100644 --- a/postfix/conf/postfix-script +++ b/postfix/conf/postfix-script @@ -124,7 +124,11 @@ start) $daemon_directory/postfix-script check-warn fi $INFO starting the Postfix mail system - $daemon_directory/master & + # NOTE: wait in foreground process to get the initialization status. + $daemon_directory/master -w || { + $FATAL "mail system startup failed" + exit 1 + } ;; drain) diff --git a/postfix/html/master.8.html b/postfix/html/master.8.html index db08b69fe..87e764451 100644 --- a/postfix/html/master.8.html +++ b/postfix/html/master.8.html @@ -10,7 +10,7 @@ MASTER(8) MASTER(8) master - Postfix master process SYNOPSIS - master [-Ddtv] [-c config_dir] [-e exit_time] + master [-Ddtvw] [-c config_dir] [-e exit_time] DESCRIPTION The master(8) daemon is the resident process that runs @@ -61,6 +61,16 @@ MASTER(8) MASTER(8) option is passed on to child processes. Multiple -v options make the software increasingly verbose. + -w Wait in a dummy foreground process, while the real + master daemon initializes in a background process. + The dummy foreground process returns a zero exit + status only if the master daemon initialization is + successful, and if it completes in a reasonable + amount of time. + + This feature is available in Postfix 2.10 and + later. + Signals: SIGHUP Upon receipt of a HUP signal (e.g., after "postfix @@ -81,12 +91,14 @@ MASTER(8) MASTER(8) running processes to finish what they are doing. DIAGNOSTICS - Problems are reported to syslogd(8). + Problems are reported to syslogd(8). The exit status is + non-zero in case of problems, including problems while + initializing as a master daemon process in the background. ENVIRONMENT MAIL_DEBUG After initialization, start a debugger as specified - with the debugger_command configuration parameter + with the debugger_command configuration parameter in the main.cf configuration file. MAIL_CONFIG @@ -95,22 +107,22 @@ MASTER(8) MASTER(8) CONFIGURATION PARAMETERS Unlike most Postfix daemon processes, the master(8) server does not automatically pick up changes to main.cf. Changes - to master.cf are never picked up automatically. Use the + to master.cf are never picked up automatically. Use the "postfix reload" command after a configuration change. RESOURCE AND RATE CONTROLS default_process_limit (100) - The default maximal number of Postfix child pro- + The default maximal number of Postfix child pro- cesses that provide a given service. max_idle (100s) - The maximum amount of time that an idle Postfix - daemon process waits for an incoming connection + The maximum amount of time that an idle Postfix + daemon process waits for an incoming connection before terminating voluntarily. max_use (100) - The maximal number of incoming connections that a - Postfix daemon process will service before termi- + The maximal number of incoming connections that a + Postfix daemon process will service before termi- nating voluntarily. service_throttle_time (60s) @@ -120,16 +132,16 @@ MASTER(8) MASTER(8) Available in Postfix version 2.6 and later: master_service_disable (empty) - Selectively disable master(8) listener ports by + Selectively disable master(8) listener ports by service type or by service name and type. MISCELLANEOUS CONTROLS config_directory (see 'postconf -d' output) - The default location of the Postfix main.cf and + The default location of the Postfix main.cf and master.cf configuration files. daemon_directory (see 'postconf -d' output) - The directory with Postfix support programs and + The directory with Postfix support programs and daemon programs. debugger_command (empty) @@ -141,11 +153,11 @@ MASTER(8) MASTER(8) tem receives mail on. inet_protocols (all) - The Internet protocols Postfix will attempt to use + The Internet protocols Postfix will attempt to use when making or accepting connections. import_environment (see 'postconf -d' output) - The list of environment parameters that a Postfix + The list of environment parameters that a Postfix process will import from a non-Postfix parent process. @@ -154,23 +166,23 @@ MASTER(8) MASTER(8) and most Postfix daemon processes. process_id (read-only) - The process ID of a Postfix command or daemon + The process ID of a Postfix command or daemon process. process_name (read-only) - The process name of a Postfix command or daemon + The process name of a Postfix command or daemon process. queue_directory (see 'postconf -d' output) - The location of the Postfix top-level queue direc- + The location of the Postfix top-level queue direc- tory. syslog_facility (mail) The syslog facility of Postfix logging. syslog_name (see 'postconf -d' output) - The mail system name that is prepended to the - process name in syslog records, so that "smtpd" + The mail system name that is prepended to the + process name in syslog records, so that "smtpd" becomes, for example, "postfix/smtpd". FILES @@ -190,7 +202,7 @@ MASTER(8) MASTER(8) syslogd(8), system logging 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/postconf.1.html b/postfix/html/postconf.1.html index a07120b6e..783d5b45d 100644 --- a/postfix/html/postconf.1.html +++ b/postfix/html/postconf.1.html @@ -17,7 +17,7 @@ POSTCONF(1) POSTCONF(1) postconf [-ev] [-c config_dir] [parameter=value ...] - postconf [-#v] [-c config_dir] [parameter ...] + postconf [-#vX] [-c config_dir] [parameter ...] Managing master.cf: @@ -312,6 +312,16 @@ POSTCONF(1) POSTCONF(1) tiple -v options make the software increasingly verbose. + -X Edit the main.cf configuration file, and remove the + parameters given 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) command + to perform the reverse operation. + + This feature is available with Postfix 2.10 and + later. + -# Edit the main.cf configuration file, and comment out the parameters given on the postconf(1) command line, so that those parameters revert to their diff --git a/postfix/man/man1/postconf.1 b/postfix/man/man1/postconf.1 index 9717c9cf2..7f52555b1 100644 --- a/postfix/man/man1/postconf.1 +++ b/postfix/man/man1/postconf.1 @@ -17,7 +17,7 @@ Postfix configuration utility \fBpostconf\fR [\fB-ev\fR] [\fB-c \fIconfig_dir\fR] [\fIparameter=value ...\fR] -\fBpostconf\fR [\fB-#v\fR] [\fB-c \fIconfig_dir\fR] +\fBpostconf\fR [\fB-#vX\fR] [\fB-c \fIconfig_dir\fR] [\fIparameter ...\fR] \fBManaging master.cf:\fR @@ -273,6 +273,16 @@ This feature is available with Postfix 2.3 and later. .IP \fB-v\fR Enable verbose logging for debugging purposes. Multiple \fB-v\fR options make the software increasingly verbose. +.IP \fB-X\fR +Edit the \fBmain.cf\fR configuration file, and remove +the parameters given 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 +pairs. There is no \fBpostconf\fR(1) command to perform +the reverse operation. + +This feature is available with Postfix 2.10 and later. .IP \fB-#\fR Edit the \fBmain.cf\fR configuration file, and comment out the parameters given on the \fBpostconf\fR(1) command line, diff --git a/postfix/man/man8/master.8 b/postfix/man/man8/master.8 index 0953cce38..45bdbde12 100644 --- a/postfix/man/man8/master.8 +++ b/postfix/man/man8/master.8 @@ -8,7 +8,7 @@ Postfix master process .SH "SYNOPSIS" .na .nf -\fBmaster\fR [\fB-Ddtv\fR] [\fB-c \fIconfig_dir\fR] [\fB-e \fIexit_time\fR] +\fBmaster\fR [\fB-Ddtvw\fR] [\fB-c \fIconfig_dir\fR] [\fB-e \fIexit_time\fR] .SH DESCRIPTION .ad .fi @@ -51,6 +51,14 @@ that the \fBmaster\fR(8) daemon is not running. Enable verbose logging for debugging purposes. This option is passed on to child processes. Multiple \fB-v\fR options make the software increasingly verbose. +.IP \fB-w\fR +Wait in a dummy foreground process, while the real master +daemon initializes in a background process. The dummy +foreground process returns a zero exit status only if the +master daemon initialization is successful, and if it +completes in a reasonable amount of time. +.sp +This feature is available in Postfix 2.10 and later. .PP Signals: .IP \fBSIGHUP\fR @@ -71,7 +79,9 @@ processes to finish what they are doing. .SH DIAGNOSTICS .ad .fi -Problems are reported to \fBsyslogd\fR(8). +Problems are reported to \fBsyslogd\fR(8). The exit status +is non-zero in case of problems, including problems while +initializing as a master daemon process in the background. .SH "ENVIRONMENT" .na .nf diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 2ac9de75b..c0f057eb9 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 "20120305" +#define MAIL_RELEASE_DATE "20120308" #define MAIL_VERSION_NUMBER "2.10" #ifdef SNAPSHOT diff --git a/postfix/src/master/Makefile.in b/postfix/src/master/Makefile.in index f1a59f615..2305da346 100644 --- a/postfix/src/master/Makefile.in +++ b/postfix/src/master/Makefile.in @@ -2,10 +2,12 @@ SHELL = /bin/sh SRCS = master.c master_conf.c master_ent.c master_sig.c master_avail.c \ master_spawn.c master_service.c master_status.c master_listen.c \ master_proto.c single_server.c multi_server.c master_vars.c \ - master_wakeup.c master_flow.c master_watch.c mail_flow.c + master_wakeup.c master_flow.c master_watch.c mail_flow.c \ + master_monitor.c OBJS = master.o master_conf.o master_ent.o master_sig.o master_avail.o \ master_spawn.o master_service.o master_status.o master_listen.o \ - master_vars.o master_wakeup.o master_watch.o master_flow.o + master_vars.o master_wakeup.o master_watch.o master_flow.o \ + master_monitor.o LIB_OBJ = single_server.o multi_server.o trigger_server.o master_proto.o \ mail_flow.o event_server.o HDRS = mail_server.h master_proto.h mail_flow.h @@ -207,6 +209,11 @@ master_listen.o: ../../include/vbuf.h master_listen.o: ../../include/vstring.h master_listen.o: master.h master_listen.o: master_listen.c +master_monitor.o: ../../include/iostuff.h +master_monitor.o: ../../include/msg.h +master_monitor.o: ../../include/sys_defs.h +master_monitor.o: master.h +master_monitor.o: master_monitor.c master_proto.o: ../../include/msg.h master_proto.o: ../../include/sys_defs.h master_proto.o: master_proto.c diff --git a/postfix/src/master/master.c b/postfix/src/master/master.c index 532eb789e..be9e6d5b3 100644 --- a/postfix/src/master/master.c +++ b/postfix/src/master/master.c @@ -4,7 +4,7 @@ /* SUMMARY /* Postfix master process /* SYNOPSIS -/* \fBmaster\fR [\fB-Ddtv\fR] [\fB-c \fIconfig_dir\fR] [\fB-e \fIexit_time\fR] +/* \fBmaster\fR [\fB-Ddtvw\fR] [\fB-c \fIconfig_dir\fR] [\fB-e \fIexit_time\fR] /* DESCRIPTION /* The \fBmaster\fR(8) daemon is the resident process that runs Postfix /* daemons on demand: daemons to send or receive messages via the @@ -45,6 +45,14 @@ /* Enable verbose logging for debugging purposes. This option /* is passed on to child processes. Multiple \fB-v\fR options /* make the software increasingly verbose. +/* .IP \fB-w\fR +/* Wait in a dummy foreground process, while the real master +/* daemon initializes in a background process. The dummy +/* foreground process returns a zero exit status only if the +/* master daemon initialization is successful, and if it +/* completes in a reasonable amount of time. +/* .sp +/* This feature is available in Postfix 2.10 and later. /* .PP /* Signals: /* .IP \fBSIGHUP\fR @@ -63,7 +71,9 @@ /* terminate only the master ("\fBpostfix stop\fR") and allow running /* processes to finish what they are doing. /* DIAGNOSTICS -/* Problems are reported to \fBsyslogd\fR(8). +/* Problems are reported to \fBsyslogd\fR(8). The exit status +/* is non-zero in case of problems, including problems while +/* initializing as a master daemon process in the background. /* ENVIRONMENT /* .ad /* .fi @@ -221,7 +231,7 @@ static void master_exit_event(int unused_event, char *unused_context) static NORETURN usage(const char *me) { - msg_fatal("usage: %s [-c config_dir] [-D (debug)] [-d (don't detach from terminal)] [-e exit_time] [-t (test)] [-v]", me); + msg_fatal("usage: %s [-c config_dir] [-D (debug)] [-d (don't detach from terminal)] [-e exit_time] [-t (test)] [-v] [-w (wait for initialization)]", me); } MAIL_VERSION_STAMP_DECLARE; @@ -243,6 +253,8 @@ int main(int argc, char **argv) VSTRING *why; WATCHDOG *watchdog; ARGV *import_env; + int wait_flag = 0; + int monitor_fd = -1; /* * Fingerprint executables and core dumps. @@ -311,7 +323,7 @@ int main(int argc, char **argv) /* * Process JCL. */ - while ((ch = GETOPT(argc, argv, "c:Dde:tv")) > 0) { + while ((ch = GETOPT(argc, argv, "c:Dde:tvw")) > 0) { switch (ch) { case 'c': if (setenv(CONF_ENV_PATH, optarg, 1) < 0) @@ -332,6 +344,9 @@ int main(int argc, char **argv) case 'v': msg_verbose++; break; + case 'w': + wait_flag = 1; + break; default: usage(argv[0]); /* NOTREACHED */ @@ -344,6 +359,17 @@ int main(int argc, char **argv) if (argc > optind) usage(argv[0]); + /* + * Run a foreground monitor process that returns an exit status of 0 when + * the child background process reports successful initialization as a + * daemon process. We use a generous limit in case main/master.cf specify + * symbolic hosts/ports and the naming service is slow. + */ +#define MASTER_INIT_TIMEOUT 100 /* keep this limit generous */ + + if (wait_flag) + monitor_fd = master_monitor(MASTER_INIT_TIMEOUT); + /* * If started from a terminal, get rid of any tty association. This also * means that all errors and warnings must go to the syslog daemon. @@ -470,6 +496,14 @@ int main(int argc, char **argv) msg_info("daemon started -- version %s, configuration %s", var_mail_version, var_config_dir); + /* + * Report successful initialization to the foreground monitor process. + */ + if (monitor_fd >= 0) { + write(monitor_fd, "", 1); + (void) close(monitor_fd); + } + /* * Process events. The event handler will execute the read/write/timer * action routines. Whenever something has happened, see if we received diff --git a/postfix/src/master/master.h b/postfix/src/master/master.h index 954dac4f7..baf5b143a 100644 --- a/postfix/src/master/master.h +++ b/postfix/src/master/master.h @@ -219,6 +219,11 @@ typedef struct { extern void master_str_watch(const MASTER_STR_WATCH *); extern void master_int_watch(MASTER_INT_WATCH *); + /* + * master_monitor.c + */ +extern int master_monitor(int); + /* DIAGNOSTICS /* BUGS /* SEE ALSO diff --git a/postfix/src/master/master_monitor.c b/postfix/src/master/master_monitor.c new file mode 100644 index 000000000..4119ea996 --- /dev/null +++ b/postfix/src/master/master_monitor.c @@ -0,0 +1,100 @@ +/*++ +/* NAME +/* master_monitor 3 +/* SUMMARY +/* Postfix master - start-up monitoring +/* SYNOPSIS +/* #include "master.h" +/* +/* int master_monitor(time_limit) +/* int time_limit; +/* DESCRIPTION +/* master_monitor() forks off a background child process, and +/* returns in the child. The result value is the file descriptor +/* on which the child process must write one byte after it +/* completes successful initialization as a daemon process. +/* +/* The foreground process waits for the child's completion for +/* a limited amount of time. It terminates with exit status 0 +/* in case of success, non-zero otherwise. +/* DIAGNOSTICS +/* Fatal errors: system call failure. +/* BUGS +/* SEE ALSO +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* IBM T.J. Watson Research +/* P.O. Box 704 +/* Yorktown Heights, NY 10598, USA +/*--*/ + +/* System library. */ + +#include +#include +#include +#include + +/* Utility library. */ + +#include +#include + +/* Application-specific. */ + +#include + +/* master_monitor - fork off a foreground monitor process */ + +int master_monitor(int time_limit) +{ + pid_t pid; + int pipes[2]; + char buf[1]; + + /* + * Sanity check. + */ + if (time_limit <= 0) + msg_panic("master_monitor: bad time limit: %d", time_limit); + + /* + * Set up the plumbing for child-to-parent communication. + */ + if (pipe(pipes) < 0) + msg_fatal("pipe: %m"); + close_on_exec(pipes[0], CLOSE_ON_EXEC); + close_on_exec(pipes[1], CLOSE_ON_EXEC); + + /* + * Fork the child, and wait for it to report successful initialization. + */ + switch (pid = fork()) { + case -1: + /* Error. */ + msg_fatal("fork: %m"); + case 0: + /* Child. Initialize as daemon in the background. */ + close(pipes[0]); + return (pipes[1]); + default: + /* Parent. Monitor the child in the foreground. */ + close(pipes[1]); + switch (timed_read(pipes[0], buf, 1, time_limit, (char *) 0)) { + default: + /* The child process still runs, but something is wrong. */ + (void) kill(pid, SIGKILL); + /* FALLTHROUGH */ + case 0: + /* The child process exited prematurely. */ + msg_fatal("daemon initialization failure"); + case 1: + /* The child process initialized successfully. */ + exit(0); + } + } +} diff --git a/postfix/src/postconf/postconf.c b/postfix/src/postconf/postconf.c index becede834..e9f0b3401 100644 --- a/postfix/src/postconf/postconf.c +++ b/postfix/src/postconf/postconf.c @@ -13,7 +13,7 @@ /* \fBpostconf\fR [\fB-ev\fR] [\fB-c \fIconfig_dir\fR] /* [\fIparameter=value ...\fR] /* -/* \fBpostconf\fR [\fB-#v\fR] [\fB-c \fIconfig_dir\fR] +/* \fBpostconf\fR [\fB-#vX\fR] [\fB-c \fIconfig_dir\fR] /* [\fIparameter ...\fR] /* /* \fBManaging master.cf:\fR @@ -267,6 +267,16 @@ /* .IP \fB-v\fR /* Enable verbose logging for debugging purposes. Multiple \fB-v\fR /* options make the software increasingly verbose. +/* .IP \fB-X\fR +/* Edit the \fBmain.cf\fR configuration file, and remove +/* the parameters given 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 +/* pairs. There is no \fBpostconf\fR(1) command to perform +/* the reverse operation. +/* +/* This feature is available with Postfix 2.10 and later. /* .IP \fB-#\fR /* Edit the \fBmain.cf\fR configuration file, and comment out /* the parameters given on the \fBpostconf\fR(1) command line, @@ -412,7 +422,7 @@ int main(int argc, char **argv) /* * Parse JCL. */ - while ((ch = GETOPT(argc, argv, "aAbc:C:deEf#hlmMntv")) > 0) { + while ((ch = GETOPT(argc, argv, "aAbc:C:deEf#hlmMntvX")) > 0) { switch (ch) { case 'a': cmd_mode |= SHOW_SASL_SERV; @@ -432,7 +442,7 @@ int main(int argc, char **argv) break; case 'C': param_class = name_mask_opt("-C option", param_class_table, - optarg, NAME_MASK_ANY_CASE | NAME_MASK_FATAL); + optarg, NAME_MASK_ANY_CASE | NAME_MASK_FATAL); break; case 'd': cmd_mode |= SHOW_DEFS; @@ -480,24 +490,29 @@ int main(int argc, char **argv) ext_argv = argv_alloc(2); argv_add(ext_argv, "bounce", "-SVndump_templates", (char *) 0); break; + case 'X': + /* This is irreversible, therefore require two-finger action. */ + cmd_mode = EDIT_EXCL; + break; case 'v': msg_verbose++; break; default: - msg_fatal("usage: %s [-a (server SASL types)] [-A (client SASL types)] [-b (bounce templates)] [-c config_dir] [-C param_class] [-d (defaults)] [-e (edit)] [-f (fold lines)] [-# (comment-out)] [-h (no names)] [-l (lock types)] [-m (map types)] [-M (master.cf)] [-n (non-defaults)] [-v] [name...]", argv[0]); + msg_fatal("usage: %s [-a (server SASL types)] [-A (client SASL types)] [-b (bounce templates)] [-c config_dir] [-C param_class] [-d (defaults)] [-e (edit)] [-f (fold lines)] [-# (comment-out)] [-h (no names)] [-l (lock types)] [-m (map types)] [-M (master.cf)] [-n (non-defaults)] [-v] [-X (exclude)] [name...]", argv[0]); } } /* * Sanity check. */ - junk = (cmd_mode & (SHOW_DEFS | SHOW_NONDEF | SHOW_MAPS | SHOW_LOCKS | EDIT_MAIN | SHOW_SASL_SERV | SHOW_SASL_CLNT | COMMENT_OUT | SHOW_MASTER)); + junk = (cmd_mode & (SHOW_DEFS | SHOW_NONDEF | SHOW_MAPS | SHOW_LOCKS | EDIT_MAIN | SHOW_SASL_SERV | SHOW_SASL_CLNT | COMMENT_OUT | SHOW_MASTER | EDIT_EXCL)); if (junk != 0 && ((junk != SHOW_DEFS && junk != SHOW_NONDEF && junk != SHOW_MAPS && junk != SHOW_LOCKS && junk != EDIT_MAIN && junk != SHOW_SASL_SERV && junk != SHOW_SASL_CLNT - && junk != COMMENT_OUT && junk != SHOW_MASTER) + && junk != COMMENT_OUT && junk != SHOW_MASTER + && junk != EDIT_EXCL) || ext_argv != 0)) - msg_fatal("specify one of -a, -A, -b, -d, -e, -#, -l, -m, -M and -n"); + msg_fatal("specify one of -a, -A, -b, -d, -e, -#, -l, -m, -M, -n, and -X"); /* * Display bounce template information and exit. @@ -555,7 +570,7 @@ int main(int argc, char **argv) /* * Edit main.cf. */ - else if (cmd_mode & (EDIT_MAIN | COMMENT_OUT)) { + else if (cmd_mode & (EDIT_MAIN | COMMENT_OUT | EDIT_EXCL)) { edit_parameters(cmd_mode, argc - optind, argv + optind); } else if (cmd_mode == DEF_MODE && argv[optind] && strchr(argv[optind], '=')) { diff --git a/postfix/src/postconf/postconf.h b/postfix/src/postconf/postconf.h index 8a3bb8ad9..f197d1223 100644 --- a/postfix/src/postconf/postconf.h +++ b/postfix/src/postconf/postconf.h @@ -30,6 +30,7 @@ #define COMMENT_OUT (1<<9) /* #-out selected main.cf entries */ #define SHOW_MASTER (1<<10) /* show master.cf entries */ #define FOLD_LINE (1<<11) /* fold long *.cf entries */ +#define EDIT_EXCL (1<<12) /* exclude main.cf entries */ #define DEF_MODE SHOW_NAME /* default mode */ @@ -165,7 +166,7 @@ extern void register_user_parameters(void); * postconf_dbms.c */ extern void register_dbms_parameters(const char *, - const char *(*) (const char *, int, char *), + const char *(*) (const char *, int, char *), PC_MASTER_ENT *); /* diff --git a/postfix/src/postconf/postconf_edit.c b/postfix/src/postconf/postconf_edit.c index 660e7e9c3..fcfe76338 100644 --- a/postfix/src/postconf/postconf_edit.c +++ b/postfix/src/postconf/postconf_edit.c @@ -88,19 +88,19 @@ void edit_parameters(int mode, int argc, char **argv) table = htable_create(argc); while ((cp = *argv++) != 0) { if (strchr(cp, '\n') != 0) - msg_fatal("-e or -# accepts no multi-line input"); + msg_fatal("-e, -X, or -# accepts no multi-line input"); while (ISSPACE(*cp)) cp++; if (*cp == '#') - msg_fatal("-e or -# accepts no comment input"); + msg_fatal("-e, -X, or -# accepts no comment input"); if (mode & EDIT_MAIN) { if ((err = split_nameval(cp, &edit_key, &edit_val)) != 0) msg_fatal("%s: \"%s\"", err, cp); - } else if (mode & COMMENT_OUT) { + } else if (mode & (COMMENT_OUT | EDIT_EXCL)) { if (*cp == 0) - msg_fatal("-# requires non-blank parameter names"); + msg_fatal("-X or -# requires non-blank parameter names"); if (strchr(cp, '=') != 0) - msg_fatal("-# requires parameter names only"); + msg_fatal("-X or -# requires parameter names only"); edit_key = mystrdup(cp); trimblanks(edit_key, 0); edit_val = 0; @@ -164,8 +164,6 @@ void edit_parameters(int mode, int argc, char **argv) vstream_fprintf(dst, "%s = %s\n", STR(key), cvalue->value); else if (mode & COMMENT_OUT) vstream_fprintf(dst, "#%s", cp); - else - msg_panic("edit_parameters: unknown mode %d", mode); } else { vstream_fputs(STR(buf), dst); } -- 2.47.3