From: Wietse Venema Date: Tue, 4 May 1999 05:00:00 +0000 (-0500) Subject: snapshot-19990504 X-Git-Tag: v20010228~111 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e84667267b317050ddcf12196bb4ef68b8bec90;p=thirdparty%2Fpostfix.git snapshot-19990504 --- diff --git a/postfix/.indent.pro b/postfix/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/.indent.pro +++ b/postfix/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/HISTORY b/postfix/HISTORY index 8dba72fc5..ad9726814 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -2687,3 +2687,26 @@ Apologies for any names omitted. Cleanup: "disable_dns_lookups = yes" now should disable all DNS lookups by the SMTP client. +19990428 + + Bugfix: with DBM files, Postfix was watching the "dir" file + modification time for changes. It should be watching the + "pag" file instead. + +19990429 + + Cleanup: all callbacks in the master to server API now pass + on the service name and the application-specific argument + vector. Files: master/*server.c. + +19990504 + + Feature: conditional macro expansion. ${name?text} expands + to text when name is defined, otherwise the result is empty. + ${name:text} expands to text when name is undefined, + otherwise the result is empty. File: util/mac_expand.c. + + Feature: conditional macro expansion in forward_path and + mailbox_command of $user, $home, $shell, $recipient, + $extension, $domain, and $recipient_delimiter. Files: + local/command.c, local/dotforward.c, local/local_expand.c. diff --git a/postfix/INSTALL b/postfix/INSTALL index 9ea47b9c6..b133cf5a9 100644 --- a/postfix/INSTALL +++ b/postfix/INSTALL @@ -1,5 +1,5 @@ -Purpose of this document -======================== +1 - Purpose of this document +============================ This document describes how to build, install and configure a Postfix system so that it can do one of the following: @@ -12,8 +12,8 @@ Postfix system so that it can do one of the following: - Replace sendmail altogether. -Typographical conventions -========================= +2 - Typographical conventions +============================= In the instructions below, a command written as @@ -27,8 +27,8 @@ A command written as should be executed as an unprivileged user. -Documentation -============= +3 - Documentation +================= Documentation is available as HTML web pages (point your browser to html/index.html) and as UNIX-style manpages (point your MANPATH @@ -39,11 +39,10 @@ The sample configuration files in the `conf' directory have extensive comments, but they may not describe every nuance of every feature. Many files have their own built-in manual page. Tools to extract -those embedded manual pages are available in the contributed software -from http://www.postfix.org/ +those embedded manual pages are available in the mantools directory. -Building on a supported system -============================== +4 - Building on a supported system +================================== If your system is supported, it is one of @@ -75,12 +74,7 @@ If your system is supported, it is one of SunOS 5.4..5.7 (Solaris 2.4..7) or something closely resemblant. Some platforms such as Ultrix 4 -might work, but that has not been verified. It is sufficiently -similar to SunOS 4 that my guesses should be mostly right. - -Download the contributed software from http://www.postfix.org/ if -you wish to include support for LDAP (light-weight directory access -protocol) lookups, for NEXTSTEP version 3 or for OPENSTEP version 4. +need a bit of work because their shell is a bit brain damaged. If at any time in the build process you get messages like: "make: don't know how to ..." you should be able to recover by running @@ -128,8 +122,8 @@ In any case, if the command produces compiler error messages, it may be time to examine the FAQ document. -Porting to on an unsupported system -=================================== +5 - Porting to on an unsupported system +======================================= - Choose a SYSTEMTYPE name for the new system. Please use a name that includes the major version of the operating system (such as @@ -153,8 +147,8 @@ increasingly difficult to maintain over time. Moreover, with the next port you'd have to place #ifdefs all over the source code again. -Installing the software after successful compilation -==================================================== +6 - Installing the software after successful compilation +======================================================== There is no automated installation procedure. The Postfix system is sufficiently complex, and UNIX systems are sufficiently different, @@ -167,11 +161,11 @@ Installing Postfix by hand takes only a few steps. variable. This text assumes that you have chosen the default location. - As superuser, execute the commands: + As superuser, execute the commands from the Postfix source directory: # mkdir /etc/postfix # chmod 755 /etc/postfix - # cp /some/where/postfix/conf/* /etc/postfix + # cp conf/* /etc/postfix # chmod 644 /etc/postfix/* # chmod 755 /etc/postfix/postfix-script* @@ -185,23 +179,33 @@ Installing Postfix by hand takes only a few steps. # mkdir /var/spool/postfix # chmod 755 /var/spool/postfix -- Program directory. The pathname is configurable in /etc/postfix/main.cf. - I recommend that you install the programs in a separate directory, - not in a place that contains other software. +- Command directory. The pathname is configurable in /etc/postfix/main.cf. + Usually I install in /usr/sbin or in /usr/etc, depending on the system. - As superuser, execute the commands: + If you are replacing an existing sendmail installation with + Postfix, you need to keep the old sendmail program running for + some time in order to flush the mail queue. As superuser, execute + the following commands (your sendmail may be in a different place): + + # mv /usr/sbin/sendmail /usr/sbin/sendmail.OFF + # chmod 755 /usr/sbin/sendmail.OFF + + As superuser, execute the commands from the Postfix source directory: + + # mkdir $command_directory + # cp bin/* $command_directory + + Alternative: leave the command executables in the Postfix source tree. - # mkdir /some/where/bin - # cp bin/* /some/where/bin +- Daemon directory. The pathname is configurable in /etc/postfix/main.cf. + Usually I install in /usr/libexec/postfix or in /usr/lib/postfix. - Alternative 1: leave the programs in the Postfix source tree. + As superuser, execute the commands from the Postfix source directory: - Alternative 2: use separate program and daemon directories (again, - configurable in /etc/postfix/main.cf): + # mkdir $daemon_directory + # cp libexec/* $daemon_directory - # mkdir /some/where/sbin /some/where/libexec - # cp bin/sendmail bin/post* /some/where/sbin - # cp `ls bin/*|egrep -v 'post|fsstone|smtp-|sendmail'` /some/where/libexec + Alternative: leave the daemon executables in the Postfix source tree. - On-line manual pages: @@ -216,53 +220,39 @@ Installing Postfix by hand takes only a few steps. # export MANPATH # MANPATH=/some/where/man:/usr/share/man:/usr/local/man -- Next, review the "To chroot or not to chroot" section, and proceed - to the section on how you wish to run Postfix on your particular - machine: +- Proceed to the section on how you wish to run Postfix on your + particular machine: - Send mail only, without changing an existing sendmail - installation. + installation (section 7). - Send and receive mail via a virtual host interface, still - without any change to an existing sendmail installation. + without any change to an existing sendmail installation + (section 8). - - Replace sendmail altogether. + - Replace sendmail altogether (section 9). -To chroot or not to chroot -========================== - -Most Postfix daemons can run in a chroot jail, that is, in a chroot -environment at fixed low privilege. This provides a significant -barrier against intrusion. The barrier is not impenetrable, but -every little bit helps. - -The file /etc/postfix/master.cf by default runs no Postfix daemons -in a chroot jail. However, with the exception of the `local' and -`pipe' daemons, every Postfix daemon can run chrooted. - -- The contributed source code from http://www.postfix.org/ has - scripts for setting up chroot environments for Postfix systems. - -Configuring Postfix to send mail only -===================================== +7 - Configuring Postfix to send mail only +========================================= If you are going to use Postfix to send mail only, there is no need -to change your sendmail setup. Instead, set up your mail user agent -so that it calls the Postfix sendmail program directly. +to change your existing sendmail setup. Instead, set up your mail +user agent so that it calls the Postfix sendmail program directly. Follow the instructions in the "Mandatory configuration file edits" -section below. +in section 10, review the "To chroot or not to chroot" text in +section 11, and choose a security model according to section 12. -You must comment out the smtp inet service in /etc/postfix/master.cf, -in order to avoid conflicts with the sendmail daemon. +You MUST comment out the `smtp inet' entry in /etc/postfix/master.cf, +in order to avoid conflicts with the real sendmail. Start the Postfix system: # postfix start -or, if you feel nostalgic, +or, if you feel nostalgic, use the Postfix sendmail command: - # /some/where/bin/sendmail -bd -qwhatever + # sendmail -bd -qwhatever and watch your syslog file for any error messages. @@ -272,21 +262,20 @@ directory. In order to inspect the mail queue, use - % /some/where/bin/sendmail -bp + % sendmail -bp -See also the "Care and feeding" section below. +See also the "Care and feeding" section 13 below. -Configuring Postfix to send and receive mail (virtual interface) -================================================================ +8 - Configuring Postfix to send and receive mail (virtual interface) +==================================================================== Alternatively, you can use the Postfix system to send AND receive mail while leaving your sendmail setup intact, by running Postfix on a virtual interface address. Simply configure your mail user agent to directly invoke the Postfix sendmail program. -The contributed source code from http://www.postfix.org/ gives -examples for setting up virtual interfaces for a variety of UNIX -versions. +The examples/virtual-setup directory gives instructions for setting +up virtual interfaces for a variety of UNIX versions. In the /etc/postfix/main.cf file, I would specify @@ -294,14 +283,17 @@ In the /etc/postfix/main.cf file, I would specify inet_interfaces = $myhostname mydestination = $myhostname -You still have to do the "Mandatory configuration file edits" -described below. After those edits, start the mail system: +Follow the instructions in the "Mandatory configuration file edits" +in section 10, review the "To chroot or not to chroot" text in +section 11, and choose a security model according to section 12. + +Start the mail system: - # /some/where/bin/postfix start + # postfix start -or, if you feel nostalgic, +or, if you feel nostalgic, use the Postfix sendmail program: - # /some/where/bin/sendmail -bd -qwhatever + # sendmail -bd -qwhatever and watch your syslog file for any error messages. @@ -311,36 +303,29 @@ directory. In order to inspect the mail queue, use - % /some/where/bin/sendmail -bp + % sendmail -bp -See also the "Care and feeding" section below. +See also the "Care and feeding" section 13 below. -Turning off sendmail forever -============================ +9 - Turning off sendmail forever +================================ If you are going to REPLACE sendmail by Postfix, execute the -following commands. The text assumes that your sendmail is in -/usr/sbin, and that mailq and newaliases are in /usr/bin. +following commands. The text assumes that on your system, sendmail +is in /usr/sbin, and that mailq and newaliases are in /usr/bin. -First, move the existing sendmail, mailq and newaliases commands -out of the way: - - # mv /usr/sbin/sendmail /usr/sbin/sendmail.OFF # mv /usr/bin/mailq /usr/bin/mailq.OFF # mv /usr/bin/newaliases /usr/bin/newaliases.OFF - # chmod 555 /usr/sbin/sendmail.OFF /usr/bin/mailq.OFF \ - /usr/bin/newaliases.OFF - -Then, drop in the new Postfix sendmail and support programs, and -set up links for the mailq and newaliases commands: + # chmod 755 /usr/bin/newaliases.OFF /usr/bin/mailq.OFF - # ln -s /some/where/bin/sendmail /some/where/bin/post* /usr/sbin - # chmod 755 /usr/sbin/sendmail /usr/sbin/post* # ln -s /usr/sbin/sendmail /usr/bin/mailq # ln -s /usr/sbin/sendmail /usr/bin/newaliases Be sure to keep the old sendmail running for at least a couple -days to flush any unsent mail. +days to flush any unsent mail. To do so, stop the sendmail daemon +and restart it as: + + # /usr/sbin/sendmail.OFF -q After you have visited the "Mandatory configuration file edits" section below, you can start the Postfix system with @@ -357,13 +342,14 @@ When it is run for the first time, the Postfix startup shell script will create a bunch of subdirectories below the Postfix spool directory. -See also the "Care and feeding" section below. +See also the "Care and feeding" section 13 below. -Mandatory configuration file edits -================================== +10 - Mandatory configuration file edits +======================================= -By default, all Postfix configuration files are in /etc/postfix, and -must be owned by root. +By default, Postfix configuration files are in /etc/postfix, and +must be owned by root. Giving someone else write permission to +main.cf or master.cf means giving root privileges to that person. Whenever you make a change to a config file, execute the following command in order to refresh a running mail system: @@ -376,7 +362,7 @@ resemble shell variables. You specify a variable as parameter = value -and you use it by putting a $ in front of it: +and you use it by putting a $ in front of its name: other_parameter = $parameter @@ -385,18 +371,21 @@ configuration language uses lazy evaluation, and does not look at a parameter value until it is needed at runtime. First of all you have to specify the userid that owns the Postfix -queue and processes. The default setting, +queue and most Postfix processes. The default setting, mail_owner = postfix should be appropriate for your system. I would recommend that you create a dedicated user account "postfix", that is not in the same -group as other accounts. Make sure it is a locked account that -no-one can log into. It does not need an executable login shell, -nor does it need an existing home directory. +group as other accounts. Preferably, this is an account that no-one +can log into. The account does not need an executable login shell, +and needs no existing home directory. My password file entry looks +like this: -Secondly, you should specify what domain name will be appended to -a local address. The "myorigin" parameter defaults to the local + postfix:*:12345:12345:postfix:/no/where:/no/shell + +Secondly, you must specify what domain will be appended to a +local address. The "myorigin" parameter defaults to the local hostname, but that is probably OK only for very small sites. Some examples: @@ -407,8 +396,8 @@ Some examples: In the first case, local mail goes out as user@$myhostname, in the second case the sender address is user@$mydomain. -Next you nee to specify what mail addresses are local to the Postfix -system. +Next you need to specify what mail addresses are local to the +Postfix system. Some examples: @@ -430,20 +419,47 @@ Some examples: relayhost = $mydomain relayhost = mail.$mydomain + relayhost = [mail.$mydomain] + +The form enclosed with [] eliminates DNS MX lookups. + +By default, the SMTP client will do DNS lookups for sender and +recipient addresses even when you specify a relay host. If your +machine has no access to a DNS server, turn off SMTP client DNS +lookups like this: + + disable_dns_lookups = yes If you haven't used sendmail prior to using Postfix, you will have to build the alias database (with: sendmail -bi, or: newaliases). -Finally, specify the program and queue directories. +Finally, specify the program, daemon and queue directories. For +example, - program_directory = /some/where/bin + command_directory = /usr/sbin + daemon_directory = /usr/libexec/postfix queue_directory = /var/spool/postfix For further configuration information I suggest that you browse the configuration documentation in the html subdirectory. -Security: writable versus protected maildrop directory -====================================================== +11 - To chroot or not to chroot +============================== + +Most Postfix daemons can run in a chroot jail, that is, in a chroot +environment at fixed low privilege. This provides a significant +barrier against intrusion. The barrier is not impenetrable, but +every little bit helps. + +The file /etc/postfix/master.cf by default runs no Postfix daemons +in a chroot jail. However, with the exception of the `local' and +`pipe' daemons, every Postfix daemon can run chrooted. + +The examples/chroot-setup directory has a collection of scripts +for setting up chroot environments for Postfix systems. + +12 - Security: writable versus protected maildrop directory +=========================================================== Postfix offers a choice of submission mechanims. @@ -491,10 +507,18 @@ Postfix offers a choice of submission mechanims. # cp postfix-script-sgid postfix-script -Care and feeding of the Postfix system -====================================== +13 - Care and feeding of the Postfix system +=========================================== + +The Postfix programs log all problems to the syslog daemon. The +names of logfiles are specified in /etc/syslog.conf. Note: the +syslogd will not create files. You must create them ahead of time +before (re)starting syslogd. At the very least you need something +like: + + mail.err /dev/console + mail.debug /var/log/maillog -The Postfix programs log all problems to the syslog daemon. Hopefully, the number of problems will be small, but it is a good idea to run every night before the syslog files are rotated: diff --git a/postfix/Makefile.in b/postfix/Makefile.in index f4a8a419e..af7264a69 100644 --- a/postfix/Makefile.in +++ b/postfix/Makefile.in @@ -34,9 +34,9 @@ depend_update: tidy: clean rm -f Makefile */Makefile cp Makefile.init Makefile - -rm -f *core */*core .nfs* .pure bin/* lib/* include/* */.nfs* */.pure \ - *.out */*.out */*.db */*.a *~ */*~ *- */*- *.orig */*.orig *.bak \ - */*.bak make.err + -rm -f *core */*core .nfs* .pure bin/* lib/* include/* libexec/* \ + */.nfs* */.pure *.out */*.out */*.db */*.a *~ */*~ *- */*- *.orig \ + */*.orig *.bak */*.bak make.err find . -type s -print | xargs rm -f find . -type d -print | xargs chmod 755 find . -type f -print | xargs chmod a+r diff --git a/postfix/RELEASE_NOTES b/postfix/RELEASE_NOTES index 642ebf1de..451172248 100644 --- a/postfix/RELEASE_NOTES +++ b/postfix/RELEASE_NOTES @@ -1,22 +1,38 @@ -Incompatible changes with snapshot-19990427: +Incompatible changes with snapshot-19990504: =========================================== -- If an address extension (+foo) matches a user's .forward+foo file -name, the +foo extension is no longer appended to recipient addresses -listed in the .forward+foo file. This is more consistent with the -way Postfix expands aliases. +- File system reorganization: daemon executables are in the libexec +subdirectory, command executables in the bin subdirectory. The +INSTALL instructions now install daemons and commands into separate +directories. -Major changes with snapshot-19990427: +- The local delivery agent no longer appends address extensions to +addresses found in aliases, :include: files or .forward files. + +Major changes with snapshot-19990504: ===================================== In addition to several little bugfixes, none related to security, lots of internal code cleanup, lots of new functionality, and lots of Solaris workarounds. +- Specify "forward_path = /var/forward/$user" to avoid looking up +.forward files in user home directories. The default value is +$home/.forward$recipient_delimiter$extension,$home/.forward. Initial +forward_path code by Philip A. Prindeville, Mirapoint, Inc., USA. + +- Conditional macro expansion in forward_path and mailbox_command. +$name expands to itself. ${name?value} expands to value when $name +is defined. ${name:value} expands to value when $name is not +defined. With ${name?value} and ${name:value}, the value is subject +to $name expansion. Available macros are: $user, $shell, $home, +$recipient, $extension, $domain, and $recipient_delimiter. + - POSIX regular expression support, enabled by default on 4.4BSD, -LINUX, and HP-UX. See conf/sample-regexp.cf. Initial code by Lamont -Jones, Hewlett-Packard, borrowing heavily from the PCRE implementation -by Andrew McNamara, connect.com.au Pty. Ltd., Australia. +LINUX, HP-UX, and Solaris 2.5 and later. See conf/sample-regexp.cf. +Initial code by Lamont Jones, Hewlett-Packard, borrowing heavily +from the PCRE implementation by Andrew McNamara, connect.com.au +Pty. Ltd., Australia. - Regular expression checks for message headers. This requires support for POSIX or for PCRE regular expressions. Specify @@ -36,11 +52,8 @@ eliminates the need to run "postfix reload" after each change to the SMTP access table, or to the canonical, virtual, transport or aliases tables. -- forward_path configuration parameter for .forward files (default: -$home/.forward$recipient_delimiter$extension,$home/.forward). -Macros: $user (login name), $home (home directory), $recipient_delimiter, -$domain (recipient domain), and $extension (address extension). -Initial code by Philip A. Prindeville, Mirapoint, Inc., USA. +- New error mailer. Specify ".domain.name error:domain is undeliverable" +in the transport table to bounce entire domains. - No more Postfix lockups on Solaris (knock on wood). The code no longer uses Solaris UNIX-domain sockets, because they are still @@ -60,8 +73,9 @@ default 450). - MIME-encapsulated bounce messages, making it easier to recover bounced mail. Initial implementation by Philip A. Prindeville, -Mirapoint, Inc., USA. Support for RFC 1894 (DSN) will have to wait -until Postfix internals have been revised to support RFC 1893. +Mirapoint, Inc., USA. Support for RFC 1892 (multipart/report) and +RFC 1894 (DSN) will have to wait until Postfix internals have been +revised to support RFC 1893. - Separately configurable "postmaster" addresses for single bounces (bounce_notice_recipient), double bounces (2bounce_notice_recipient), diff --git a/postfix/bounce/.indent.pro b/postfix/bounce/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/bounce/.indent.pro +++ b/postfix/bounce/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/bounce/Makefile.in b/postfix/bounce/Makefile.in index cb252a20f..f8e313286 100644 --- a/postfix/bounce/Makefile.in +++ b/postfix/bounce/Makefile.in @@ -25,10 +25,10 @@ Makefile: Makefile.in test: $(TESTPROG) -update: ../bin/$(PROG) +update: ../libexec/$(PROG) -../bin/$(PROG): $(PROG) - cp $(PROG) ../bin +../libexec/$(PROG): $(PROG) + cp $(PROG) ../libexec printfck: $(OBJS) $(PROG) rm -rf printfck diff --git a/postfix/bounce/bounce.c b/postfix/bounce/bounce.c index 1faca975b..63a46e3fc 100644 --- a/postfix/bounce/bounce.c +++ b/postfix/bounce/bounce.c @@ -259,7 +259,7 @@ static void bounce_service(VSTREAM *client, char *service_name, char **argv) /* post_jail_init - initialize after entering chroot jail */ -static void post_jail_init(void) +static void post_jail_init(char *unused_name, char **unused_argv) { /* diff --git a/postfix/cleanup/.indent.pro b/postfix/cleanup/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/cleanup/.indent.pro +++ b/postfix/cleanup/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/cleanup/Makefile.in b/postfix/cleanup/Makefile.in index d7b7baff7..63cc3edc6 100644 --- a/postfix/cleanup/Makefile.in +++ b/postfix/cleanup/Makefile.in @@ -29,10 +29,10 @@ Makefile: Makefile.in test: $(TESTPROG) -update: ../bin/$(PROG) +update: ../libexec/$(PROG) -../bin/$(PROG): $(PROG) - cp $(PROG) ../bin +../libexec/$(PROG): $(PROG) + cp $(PROG) ../libexec printfck: $(OBJS) $(PROG) rm -rf printfck diff --git a/postfix/cleanup/cleanup.c b/postfix/cleanup/cleanup.c index 6123cfcb3..2127a96d9 100644 --- a/postfix/cleanup/cleanup.c +++ b/postfix/cleanup/cleanup.c @@ -374,7 +374,7 @@ static void cleanup_sig(int sig) /* pre_jail_init - initialize before entering the chroot jail */ -static void pre_jail_init(void) +static void pre_jail_init(char *unused_name, char **unused_argv) { if (*var_canonical_maps) cleanup_comm_canon_maps = @@ -399,7 +399,7 @@ static void pre_jail_init(void) /* pre_accept - see if tables have changed */ -static void pre_accept(void) +static void pre_accept(char *unused_name, char **unused_argv) { if (dict_changed()) { msg_info("table has changed -- exiting"); @@ -409,7 +409,7 @@ static void pre_accept(void) /* post_jail_init - initialize after entering the chroot jail */ -static void post_jail_init(void) +static void post_jail_init(char *unused_name, char **unused_argv) { /* diff --git a/postfix/conf/aliases b/postfix/conf/aliases index e51097246..fc0471f2a 100644 --- a/postfix/conf/aliases +++ b/postfix/conf/aliases @@ -1,3 +1,31 @@ +# +# >>>>>>>>>> The program "newaliases" must be run after +# >> NOTE >> this file is updated for any changes to +# >>>>>>>>>> show through to sendmail. +# + +# Basic system aliases -- these MUST be present +MAILER-DAEMON: postmaster +postmaster: root + +# General redirections for pseudo accounts +bin: root +daemon: root +named: root +nobody: root +operator: root +uucp: root +www: root +ftp-bugs: root + +# Put your local aliases here. + +# Well-known aliases -- these should be filled in! +# root: +# manager: +# dumper: +# operator: + #++ # NAME # aliases 5 diff --git a/postfix/conf/main.cf b/postfix/conf/main.cf index 992cc849f..35e3aedf7 100644 --- a/postfix/conf/main.cf +++ b/postfix/conf/main.cf @@ -224,6 +224,13 @@ program_directory = /some/where/postfix/bin # command to use instead of mailbox delivery. The command is run as # the recipient with proper HOME, SHELL and LOGNAME settings. # Exception: delivery for root is done as $default_user. +# +# The following expansions are done on mailbox_command: $user (recipient +# username), $shell (recipient shell), $home (recipient home directory), +# $recipient (full recipient address), $extension (recipient address +# extension), $domain (recipient domain), $recipient_delimiter. Specify +# ${name?value} or ${name:value} to expand value only when $name does +# (does not) exist. # # Avoid shell meta characters because they will force Postfix to run # an expensive shell process. Procmail alone is expensive enough. @@ -291,12 +298,13 @@ program_directory = /some/where/postfix/bin # to distinguish local clients from strangers. See permit_mynetworks # and smtpd_recipient_restrictions in the file sample-smtpd.cf file. # -# The default is all networks attached to the machine: a complete -# class A network, a complete class B network, and so on. If you want -# stricter control, specify a list of network/mask patterns, where -# the mask specifies the number of bits in the network part of a host -# address. You can also specify the absolute pathname of a pattern -# file instead of listing the patterns here. +# The default is a list of all networks attached to the machine: a +# complete class A network (X.0.0.0/8), a complete class B network +# (X.X.0.0/16), and so on. If you want stricter control, specify a +# list of network/mask patterns, where the mask specifies the number +# of bits in the network part of a host address. You can also specify +# the absolute pathname of a pattern file instead of listing the +# patterns here. # #mynetworks = 168.100.189.0/28, 127.0.0.0/8 #mynetworks = $config_directory/mynetworks diff --git a/postfix/conf/main.cf.default b/postfix/conf/main.cf.default index 0483d9882..5aa96596b 100644 --- a/postfix/conf/main.cf.default +++ b/postfix/conf/main.cf.default @@ -61,7 +61,7 @@ luser_relay = mail_name = Postfix mail_owner = postfix mail_spool_directory = /var/mail -mail_version = Snapshot-19990427 +mail_version = Snapshot-19990504 mailbox_command = mailbox_transport = maps_rbl_domains = rbl.maps.vix.com diff --git a/postfix/conf/postfix-script b/postfix/conf/postfix-script new file mode 100755 index 000000000..3cc2ef9ff --- /dev/null +++ b/postfix/conf/postfix-script @@ -0,0 +1,3 @@ +#!/bin/sh + +echo Please read the SECURITY notes at the end of the INSTALL document 1>&2 diff --git a/postfix/conf/sample-local.cf b/postfix/conf/sample-local.cf index 889a102d9..379db6436 100644 --- a/postfix/conf/sample-local.cf +++ b/postfix/conf/sample-local.cf @@ -25,9 +25,14 @@ #local_command_shell = /some/where/smrsh -c # The forward_path parameter specifies a search list. The first file -# that is found is used. In the path you can specify $user (login -# name), $home (home directory), $recipient_delimiter, $domain -# (recipient domain), and $extension (address extension). +# that is found is used. +# +# The following expansions are done on forward_path: $user (recipient +# username), $shell (recipient shell), $home (recipient home directory), +# $recipient (full recipient address), $extension (recipient address +# extension), $domain (recipient domain), $recipient_delimiter. Specify +# ${name?value} or ${name:value} to expand value only when $name does +# (does not) exist. # #forward_path = /var/forward/$user forward_path = $home/.forward$recipient_delimiter$extension,$home/.forward @@ -89,6 +94,13 @@ home_mailbox = # as the recipient with proper HOME, SHELL and LOGNAME settings. # Exception: delivery for root is done as $default_user. # +# The following expansions are done on mailbox_command: $user (recipient +# username), $shell (recipient shell), $home (recipient home directory), +# $recipient (full recipient address), $extension (recipient address +# extension), $domain (recipient domain), $recipient_delimiter. Specify +# ${name?value} or ${name:value} to expand value only when $name does +# (does not) exist. +# # Avoid shell meta characters because they will force Postfix to run # an expensive shell process. Procmail alone is expensive enough. # diff --git a/postfix/conf/sample-misc.cf b/postfix/conf/sample-misc.cf index ca9df2166..a0f63f203 100644 --- a/postfix/conf/sample-misc.cf +++ b/postfix/conf/sample-misc.cf @@ -172,12 +172,18 @@ myorigin = $myhostname # to distinguish local clients from strangers. See permit_mynetworks # in the sample-smtpd.cf file. # -# The default is all networks attached to the machine: a complete -# class A network, a complete class B network, and so on. If you want -# stricter control, specify a list of network/mask patterns, where -# the mask specifies the number of bits in the network part of a host -# address. You can also specify the absolute pathname of a pattern -# file instead of listing the patterns here. +# The mynetworks parameter specifies the list of networks that are +# local to this machine. The list is used by the anti-UCE software +# to distinguish local clients from strangers. See permit_mynetworks +# and smtpd_recipient_restrictions in the file sample-smtpd.cf file. +# +# The default is a list of all networks attached to the machine: a +# complete class A network (X.0.0.0/8), a complete class B network +# (X.X.0.0/16), and so on. If you want stricter control, specify a +# list of network/mask patterns, where the mask specifies the number +# of bits in the network part of a host address. You can also specify +# the absolute pathname of a pattern file instead of listing the +# patterns here. # #mynetworks = 168.100.189.0/28, 127.0.0.0/8 diff --git a/postfix/conf/sample-smtpd.cf b/postfix/conf/sample-smtpd.cf index 23707f3b4..cc8c214bb 100644 --- a/postfix/conf/sample-smtpd.cf +++ b/postfix/conf/sample-smtpd.cf @@ -17,6 +17,26 @@ # smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) smtpd_banner = $myhostname ESMTP $mail_name +# The smtpd_etrn_restrictions parameter restricts what clients are +# allowed to issue the ETRN command. The present Postfix ETRN differs +# from other ETRN implementations in that it flushes mail for all +# destinations. This will change in the future. +# +# The default is to allow ETRN from any host. The following restrictions +# are available: +# +# reject_unknown_client: reject the request if the client hostname is unknown. +# permit_mynetworks: permit if the client address matches $mynetworks. +# check_client_access maptype:mapname +# maptype:mapname: look up client name, parent domains, client address, +# or networks obtained by stripping octets. +# Reject if result is REJECT or "[45]xx text" +# Permit otherwise. +# reject_maps_rbl: reject if the client is listed under $maps_rbl_domains. +# reject: reject the request. Place this at the end of a restriction. +# permit: permit the request. Place this at the end of a restriction. +smtpd_etrn_restrictions = + # The smtpd_recipient_limit parameter restricts the number of recipients # that the SMTP server accepts per message delivery. # diff --git a/postfix/dns/.indent.pro b/postfix/dns/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/dns/.indent.pro +++ b/postfix/dns/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/error/.indent.pro b/postfix/error/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/error/.indent.pro +++ b/postfix/error/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/error/.printfck b/postfix/error/.printfck new file mode 100644 index 000000000..65eb6bfa6 --- /dev/null +++ b/postfix/error/.printfck @@ -0,0 +1,25 @@ +been_here_xt 2 0 +bounce_append 5 0 +cleanup_out_format 1 0 +defer_append 5 0 +mail_command 1 0 +mail_print 1 0 +msg_error 0 0 +msg_fatal 0 0 +msg_info 0 0 +msg_panic 0 0 +msg_warn 0 0 +opened 3 0 +post_mail_fprintf 1 0 +qmgr_message_bounce 2 0 +rec_fprintf 2 0 +sent 4 0 +smtp_cmd 1 0 +smtp_mesg_fail 2 0 +smtp_printf 1 0 +smtp_rcpt_fail 3 0 +smtp_site_fail 2 0 +udp_syslog 1 0 +vstream_fprintf 1 0 +vstream_printf 0 0 +vstring_sprintf 1 0 diff --git a/postfix/error/Makefile.in b/postfix/error/Makefile.in index 75477d720..96f90c0fa 100644 --- a/postfix/error/Makefile.in +++ b/postfix/error/Makefile.in @@ -23,10 +23,10 @@ Makefile: Makefile.in test: $(TESTPROG) -update: ../bin/$(PROG) +update: ../libexec/$(PROG) -../bin/$(PROG): $(PROG) - cp $(PROG) ../bin +../libexec/$(PROG): $(PROG) + cp $(PROG) ../libexec printfck: $(OBJS) $(PROG) rm -rf printfck diff --git a/postfix/chroot-setup/AIX42 b/postfix/examples/chroot-setup/AIX42 similarity index 100% rename from postfix/chroot-setup/AIX42 rename to postfix/examples/chroot-setup/AIX42 diff --git a/postfix/chroot-setup/BSDI2 b/postfix/examples/chroot-setup/BSDI2 similarity index 100% rename from postfix/chroot-setup/BSDI2 rename to postfix/examples/chroot-setup/BSDI2 diff --git a/postfix/chroot-setup/BSDI3 b/postfix/examples/chroot-setup/BSDI3 similarity index 100% rename from postfix/chroot-setup/BSDI3 rename to postfix/examples/chroot-setup/BSDI3 diff --git a/postfix/chroot-setup/FREEBSD3 b/postfix/examples/chroot-setup/FREEBSD3 similarity index 100% rename from postfix/chroot-setup/FREEBSD3 rename to postfix/examples/chroot-setup/FREEBSD3 diff --git a/postfix/chroot-setup/FreeBSD2 b/postfix/examples/chroot-setup/FreeBSD2 similarity index 100% rename from postfix/chroot-setup/FreeBSD2 rename to postfix/examples/chroot-setup/FreeBSD2 diff --git a/postfix/chroot-setup/HPUX10 b/postfix/examples/chroot-setup/HPUX10 similarity index 100% rename from postfix/chroot-setup/HPUX10 rename to postfix/examples/chroot-setup/HPUX10 diff --git a/postfix/chroot-setup/HPUX9 b/postfix/examples/chroot-setup/HPUX9 similarity index 100% rename from postfix/chroot-setup/HPUX9 rename to postfix/examples/chroot-setup/HPUX9 diff --git a/postfix/chroot-setup/IRIX5 b/postfix/examples/chroot-setup/IRIX5 similarity index 100% rename from postfix/chroot-setup/IRIX5 rename to postfix/examples/chroot-setup/IRIX5 diff --git a/postfix/chroot-setup/IRIX6 b/postfix/examples/chroot-setup/IRIX6 similarity index 100% rename from postfix/chroot-setup/IRIX6 rename to postfix/examples/chroot-setup/IRIX6 diff --git a/postfix/chroot-setup/LINUX2 b/postfix/examples/chroot-setup/LINUX2 similarity index 100% rename from postfix/chroot-setup/LINUX2 rename to postfix/examples/chroot-setup/LINUX2 diff --git a/postfix/chroot-setup/NETBSD1 b/postfix/examples/chroot-setup/NETBSD1 similarity index 100% rename from postfix/chroot-setup/NETBSD1 rename to postfix/examples/chroot-setup/NETBSD1 diff --git a/postfix/chroot-setup/NEXTSTEP3 b/postfix/examples/chroot-setup/NEXTSTEP3 similarity index 100% rename from postfix/chroot-setup/NEXTSTEP3 rename to postfix/examples/chroot-setup/NEXTSTEP3 diff --git a/postfix/chroot-setup/OPENSTEP4 b/postfix/examples/chroot-setup/OPENSTEP4 similarity index 100% rename from postfix/chroot-setup/OPENSTEP4 rename to postfix/examples/chroot-setup/OPENSTEP4 diff --git a/postfix/chroot-setup/OSF1 b/postfix/examples/chroot-setup/OSF1 similarity index 100% rename from postfix/chroot-setup/OSF1 rename to postfix/examples/chroot-setup/OSF1 diff --git a/postfix/chroot-setup/Solaris2 b/postfix/examples/chroot-setup/Solaris2 similarity index 100% rename from postfix/chroot-setup/Solaris2 rename to postfix/examples/chroot-setup/Solaris2 diff --git a/postfix/examples/virtual-setup/BSDI2 b/postfix/examples/virtual-setup/BSDI2 new file mode 100644 index 000000000..f89efd1b2 --- /dev/null +++ b/postfix/examples/virtual-setup/BSDI2 @@ -0,0 +1,5 @@ +In order to set up Postfix on a virtual interface address on my own +BSD/OS or FreeBSD systems I would use: + + # ifconfig interface-name alias virtual.host.addr netmask some.net.mask + # route add virtual.host.addr localhost diff --git a/postfix/examples/virtual-setup/FREEBSD2 b/postfix/examples/virtual-setup/FREEBSD2 new file mode 100644 index 000000000..f89efd1b2 --- /dev/null +++ b/postfix/examples/virtual-setup/FREEBSD2 @@ -0,0 +1,5 @@ +In order to set up Postfix on a virtual interface address on my own +BSD/OS or FreeBSD systems I would use: + + # ifconfig interface-name alias virtual.host.addr netmask some.net.mask + # route add virtual.host.addr localhost diff --git a/postfix/examples/virtual-setup/LINUX2 b/postfix/examples/virtual-setup/LINUX2 new file mode 100644 index 000000000..faeac06cf --- /dev/null +++ b/postfix/examples/virtual-setup/LINUX2 @@ -0,0 +1,3 @@ +On linux virtual interfaces can be set up with: +ifconfig interface-name:alias-num virtual.host.addr +route add virtual.host.addr dev interface-name:alias-num diff --git a/postfix/fsstone/.indent.pro b/postfix/fsstone/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/fsstone/.indent.pro +++ b/postfix/fsstone/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/fsstone/Makefile.in b/postfix/fsstone/Makefile.in index cba53254e..21d5d58de 100644 --- a/postfix/fsstone/Makefile.in +++ b/postfix/fsstone/Makefile.in @@ -25,9 +25,9 @@ fsstone: fsstone.o $(LIBS) test: $(TESTPROG) -update: ../bin/fsstone +update: ../libexec/fsstone -../bin/fsstone: fsstone +../libexec/fsstone: fsstone cp $? $@ printfck: $(OBJS) $(PROG) diff --git a/postfix/global/.indent.pro b/postfix/global/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/global/.indent.pro +++ b/postfix/global/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/global/mail_version.h b/postfix/global/mail_version.h index ac5e4d83b..d11555493 100644 --- a/postfix/global/mail_version.h +++ b/postfix/global/mail_version.h @@ -15,7 +15,7 @@ * Version of this program. */ #define VAR_MAIL_VERSION "mail_version" -#define DEF_MAIL_VERSION "Snapshot-19990427" +#define DEF_MAIL_VERSION "Snapshot-19990504" extern char *var_mail_version; /* LICENSE diff --git a/postfix/html/Makefile.in b/postfix/html/Makefile.in index f60655d26..7180aced6 100644 --- a/postfix/html/Makefile.in +++ b/postfix/html/Makefile.in @@ -1,6 +1,6 @@ # For now, just hard-coded rules for daemons, commands, config files. -DAEMONS = bounce.8.html cleanup.8.html defer.8.html local.8.html \ +DAEMONS = bounce.8.html cleanup.8.html defer.8.html error.8.html local.8.html \ master.8.html pickup.8.html pipe.8.html qmgr.8.html showq.8.html \ smtp.8.html smtpd.8.html trivial-rewrite.8.html COMMANDS= mailq.1.html newaliases.1.html postalias.1.html postcat.1.html \ @@ -30,6 +30,9 @@ defer.8.html: bounce.8.html rm -f $@ ln -s $? $@ +error.8.html: ../error/error.c + srctoman $? | nroff -man | man2html | postlink >$@ + cleanup.8.html: ../cleanup/cleanup.c srctoman $? | nroff -man | man2html | postlink >$@ diff --git a/postfix/html/error.8.html b/postfix/html/error.8.html new file mode 100644 index 000000000..2a3d401f8 --- /dev/null +++ b/postfix/html/error.8.html @@ -0,0 +1,134 @@ +
+
+
+
+ERROR(8)                                                 ERROR(8)
+
+
+NAME
+       error - Postfix error mailer
+
+SYNOPSIS
+       error [generic Postfix daemon options]
+
+DESCRIPTION
+       The   Postfix  error  mailer  processes  message  delivery
+       requests from the queue manager. Each request specifies  a
+       queue  file,  a sender address, a domain or host name that
+       is treated as the reason for non-delivery,  and  recipient
+       information.  This program expects to be run from the mas-
+       ter(8) process manager.
+
+       The error mailer client forces all recipients  to  bounce,
+       using  the  domain  or  host information as the reason for
+       non-delivery, updates the queue file and marks  recipients
+       as finished, or it informs the queue manager that delivery
+       should be tried again at a later time.
+
+       Delivery problem reports are  sent  to  the  bounce(8)  or
+       defer(8) daemon as appropriate.
+
+SECURITY
+       The  error  mailer  is not security-sensitive. It does not
+       talk to the network, and can be run chrooted at fixed  low
+       privilege.
+
+STANDARDS
+       None.
+
+DIAGNOSTICS
+       Problems and transactions are logged to syslogd(8).
+
+       Depending  on the setting of the notify_classes parameter,
+       the postmaster is notified of bounces and of  other  trou-
+       ble.
+
+BUGS
+CONFIGURATION PARAMETERS
+       The  following  main.cf parameters are especially relevant
+       to this program. See the Postfix main.cf file  for  syntax
+       details  and  for  default  values. Use the postfix reload
+       command after a configuration change.
+
+Miscellaneous
+       bounce_notice_recipient
+              Postmaster for bounce error notices.
+
+       notify_classes
+              When this parameter includes the bounce class, send
+              mail to the postmaster with with the headers of the
+              bounced mail.
+
+
+
+
+                                                                1
+
+
+
+
+
+ERROR(8)                                                 ERROR(8)
+
+
+SEE ALSO
+       bounce(8) non-delivery status reports
+       master(8) process manager
+       qmgr(8) queue manager
+       syslogd(8) system logging
+
+LICENSE
+       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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+                                                                2
+
+
+
diff --git a/postfix/html/local.8.html b/postfix/html/local.8.html index 3b06a2cec..336b5359e 100644 --- a/postfix/html/local.8.html +++ b/postfix/html/local.8.html @@ -33,32 +33,32 @@ LOCAL(8) LOCAL(8) mailbox owned by the user name, or it is sent back as undeliverable. - An alias or ~/.forward file may list any combination of - external commands, destination file names, :include: - directives, or mail addresses. See aliases(5) for a pre- - cise description. Each line in a user's .forward file has + The system administrator can specify a comma/space sepa- + rated list of ~/.forward like files through the for- + ward_path configuration parameter. Upon delivery, the + local delivery agent tries each pathname in the list until + a file is found. The forward_path parameter is subject to + interpolation of $user (recipient username), $home (recip- + ient home directory), $shell (recipient shell), $recipient + (complete recipient address), $extension (recipient + address extension), $domain (recipient domain) and $recip- + ient_delimiter. The forms ${name?value} and ${name:value} + expand conditionally to value when $name is (is not) + defined. + + An alias or ~/.forward file may list any combination of + external commands, destination file names, :include: + directives, or mail addresses. See aliases(5) for a pre- + cise description. Each line in a user's .forward file has the same syntax as the right-hand part of an alias. - When an address is found in its own alias expansion, - delivery is made to the user instead. When a user is + When an address is found in its own alias expansion, + delivery is made to the user instead. When a user is listed in the user's own ~/.forward file, delivery is made - to the user's mailbox instead. An empty ~/.forward file + to the user's mailbox instead. An empty ~/.forward file means do not forward mail. - In order to prevent the mail system from using up unrea- - sonable amounts of memory, input records read from - :include: or from ~/.forward files are broken up into - chunks of length line_length_limit. - - While expanding aliases, ~/.forward files, and so on, the - program attempts to avoid duplicate deliveries. The dupli- - cate_filter_limit configuration parameter limits the num- - ber of remembered recipients. - -MAIL FORWARDING - For the sake of reliability, forwarded mail is re-submit- - ted as a new message, so that each recipient has a sepa- - rate on-file delivery status record. + In order to prevent the mail system from using up @@ -71,81 +71,103 @@ LOCAL(8) LOCAL(8) LOCAL(8) LOCAL(8) + unreasonable amounts of memory, input records read from + :include: or from ~/.forward files are broken up into + chunks of length line_length_limit. + + While expanding aliases, ~/.forward files, and so on, the + program attempts to avoid duplicate deliveries. The dupli- + cate_filter_limit configuration parameter limits the num- + ber of remembered recipients. + +MAIL FORWARDING + For the sake of reliability, forwarded mail is re-submit- + ted as a new message, so that each recipient has a sepa- + rate on-file delivery status record. + In order to stop mail forwarding loops early, the software - adds a Delivered-To: header with the envelope recipient - address. If mail arrives for a recipient that is already - listed in a Delivered-To: header, the message is bounced. + adds a Delivered-To: header with the envelope recipient + address. If mail arrives for a recipient that is already + listed in a Delivered-To: header, the message is bounced. MAILBOX DELIVERY - The default per-user mailbox is a file in the UNIX mail - spool directory (/var/mail/user or /var/spool/mail/user); - the location can be specified with the mail_spool_direc- + The default per-user mailbox is a file in the UNIX mail + spool directory (/var/mail/user or /var/spool/mail/user); + the location can be specified with the mail_spool_direc- tory configuration parameter. - Alternatively, the per-user mailbox can be a file in the - user's home directory with a name specified via the - home_mailbox configuration parameter. Specify a relative + Alternatively, the per-user mailbox can be a file in the + user's home directory with a name specified via the + home_mailbox configuration parameter. Specify a relative path name. Specify a name ending in / for qmail-compatible maildir delivery. - Mailbox delivery can be delegated to an external command - specified with the mailbox_command configuration parame- - ter. The command executes with the privileges of the - recipient user (exception: in case of delivery as root, + Mailbox delivery can be delegated to an external command + specified with the mailbox_command configuration parame- + ter. The command executes with the privileges of the + recipient user (exception: in case of delivery as root, the command executes with the privileges of default_user). - - Mailbox delivery can be delegated to alternative message - transports specified in the master.cf file. The mail- - box_transport configuration parameter specifies a message - transport that is to be used for all local recipients, - regardless of whether they are found in the UNIX passwd - database. The fallback_transport parameter specifies a + The command is subject to interpolation of $user (recipi- + ent username), $home (recipient home directory), $shell + (recipient shell), $recipient (complete recipient + address), $extension (recipient address extension), + $domain (recipient domain) and $recipient_delimiter. The + forms ${name?value} and ${name:value} expand conditionally + to value when $name is (is not) defined. In the result of + name expansion, characters that have special meaning to + the shell are censored and replaced by underscores. + + Mailbox delivery can be delegated to alternative message + transports specified in the master.cf file. The mail- + box_transport configuration parameter specifies a message + transport that is to be used for all local recipients, + regardless of whether they are found in the UNIX passwd + database. The fallback_transport parameter specifies a message transport for recipients that are not found in the UNIX passwd database. - In the case of UNIX-style mailbox delivery, the local dae- - mon prepends a "From sender time_stamp" envelope header to - each message, prepends a Delivered-To: header with the - envelope recipient address, prepends a Return-Path: header - with the envelope sender address, prepends a > character - to lines beginning with "From ", and appends an empty - line. The mailbox is locked for exclusive access while - delivery is in progress. In case of problems, an attempt - is made to truncate the mailbox to its original length. - - In the case of maildir delivery, the local daemon prepends - a Delivered-To: header with the envelope recipient address - and prepends a Return-Path: header with the envelope - sender address. -EXTERNAL COMMAND DELIVERY - The allow_mail_to_commands configuration parameter - restricts delivery to external commands. The default set- - ting (alias, forward) forbids command destinations in - :include: files. - The command is executed directly where possible. + 2 - 2 +LOCAL(8) LOCAL(8) + In the case of UNIX-style mailbox delivery, the local dae- + mon prepends a "From sender time_stamp" envelope header to + each message, prepends a Delivered-To: header with the + envelope recipient address, prepends a Return-Path: header + with the envelope sender address, prepends a > character + to lines beginning with "From ", and appends an empty + line. The mailbox is locked for exclusive access while + delivery is in progress. In case of problems, an attempt + is made to truncate the mailbox to its original length. -LOCAL(8) LOCAL(8) + In the case of maildir delivery, the local daemon prepends + a Delivered-To: header with the envelope recipient address + and prepends a Return-Path: header with the envelope + sender address. +EXTERNAL COMMAND DELIVERY + The allow_mail_to_commands configuration parameter + restricts delivery to external commands. The default set- + ting (alias, forward) forbids command destinations in + :include: files. - Assistance by the shell (/bin/sh on UNIX systems) is used - only when the command contains shell magic characters, or - when the command invokes a shell built-in command. + The command is executed directly where possible. Assis- + tance by the shell (/bin/sh on UNIX systems) is used only + when the command contains shell magic characters, or when + the command invokes a shell built-in command. - A limited amount of command output (standard output and - standard error) is captured for inclusion with non-deliv- - ery status reports. A command is forcibly terminated if - it does not complete within command_time_limit seconds. - Command exit status codes are expected to follow the con- + A limited amount of command output (standard output and + standard error) is captured for inclusion with non-deliv- + ery status reports. A command is forcibly terminated if + it does not complete within command_time_limit seconds. + Command exit status codes are expected to follow the con- ventions defined in <sysexits.h>. When mail is delivered on behalf of a user, the HOME, LOG- @@ -157,64 +179,64 @@ LOCAL(8) LOCAL(8) The current working directory is the mail queue directory. The local daemon prepends a "From sender time_stamp" enve- - lope header to each message, prepends a Delivered-To: - header with the recipient envelope address, prepends a - Return-Path: header with the sender envelope address, and + lope header to each message, prepends a Delivered-To: + header with the recipient envelope address, prepends a + Return-Path: header with the sender envelope address, and appends an empty line. EXTERNAL FILE DELIVERY - The allow_mail_to_files configuration parameter restricts - delivery to external files. The default setting (alias, - forward) forbids file destinations in :include: files. + The allow_mail_to_files configuration parameter restricts + delivery to external files. The default setting (alias, + forward) forbids file destinations in :include: files. Specify a pathname ending in / for qmail-compatible maildir delivery. - The local daemon prepends a "From sender time_stamp" enve- - lope header to each message, prepends a Delivered-To: - header with the recipient envelope address, prepends a > - character to lines beginning with "From ", and appends an - empty line. The envelope sender address is available in - the Return-Path: header. When the destination is a regu- - lar file, it is locked for exclusive access while delivery - is in progress. In case of problems, an attempt is made to - truncate a regular file to its original length. - In the case of maildir delivery, the local daemon prepends - a Delivered-To: header with the envelope recipient - address. The envelope sender address is available in the - Return-Path: header. -ADDRESS EXTENSION - The optional recipient_delimiter configuration parameter - specifies how to separate address extensions from local - recipient names. - For example, with "recipient_delimiter = +", mail for - name+foo is delivered to the alias name+foo or to the + 3 - 3 +LOCAL(8) LOCAL(8) + The local daemon prepends a "From sender time_stamp" enve- + lope header to each message, prepends a Delivered-To: + header with the recipient envelope address, prepends a > + character to lines beginning with "From ", and appends an + empty line. The envelope sender address is available in + the Return-Path: header. When the destination is a regu- + lar file, it is locked for exclusive access while delivery + is in progress. In case of problems, an attempt is made to + truncate a regular file to its original length. -LOCAL(8) LOCAL(8) + In the case of maildir delivery, the local daemon prepends + a Delivered-To: header with the envelope recipient + address. The envelope sender address is available in the + Return-Path: header. +ADDRESS EXTENSION + The optional recipient_delimiter configuration parameter + specifies how to separate address extensions from local + recipient names. - alias name, to the destinations listed in ~name/.for- + For example, with "recipient_delimiter = +", mail for + name+foo is delivered to the alias name+foo or to the + alias name, to the destinations listed in ~name/.for- ward+foo or in ~name/.forward, to the mailbox owned by the user name, or it is sent back as undeliverable. - In all cases the local daemon prepends a `Delivered-To: + In all cases the local daemon prepends a `Delivered-To: name+foo' header line. DELIVERY RIGHTS - Deliveries to external files and external commands are + Deliveries to external files and external commands are made with the rights of the receiving user on whose behalf - the delivery is made. In the absence of a user context, - the local daemon uses the owner rights of the :include: + the delivery is made. In the absence of a user context, + the local daemon uses the owner rights of the :include: file or alias database. When those files are owned by the superuser, delivery is made with the rights specified with the default_privs configuration parameter. @@ -223,29 +245,41 @@ LOCAL(8) LOCAL(8) RFC 822 (ARPA Internet Text Messages) DIAGNOSTICS - Problems and transactions are logged to syslogd(8). Cor- - rupted message files are marked so that the queue manager + Problems and transactions are logged to syslogd(8). Cor- + rupted message files are marked so that the queue manager can move them to the corrupt queue afterwards. - Depending on the setting of the notify_classes parameter, - the postmaster is notified of bounces and of other trou- + Depending on the setting of the notify_classes parameter, + the postmaster is notified of bounces and of other trou- ble. BUGS - For security reasons, the message delivery status of - external commands or of external files is never check- + For security reasons, the message delivery status of + external commands or of external files is never check- pointed to file. As a result, the program may occasionally + + + + 4 + + + + + +LOCAL(8) LOCAL(8) + + deliver more than once to a command or external file. Bet- ter safe than sorry. - Mutually-recursive aliases or ~/.forward files are not - detected early. The resulting mail forwarding loop is + Mutually-recursive aliases or ~/.forward files are not + detected early. The resulting mail forwarding loop is broken by the use of the Delivered-To: message header. CONFIGURATION PARAMETERS - The following main.cf parameters are especially relevant - to this program. See the Postfix main.cf file for syntax - details and for default values. Use the postfix reload + The following main.cf parameters are especially relevant + to this program. See the Postfix main.cf file for syntax + details and for default values. Use the postfix reload command after a configuration change. Miscellaneous @@ -253,27 +287,16 @@ LOCAL(8) LOCAL(8) List of alias databases. forward_path - Search list for .forward files. The following + Search list for .forward files. The following macros are recognized: $home (home directory), $user (login name), $extension (address extension), $recipient_delimiter (address extension delimiter). - - - 4 - - - - - -LOCAL(8) LOCAL(8) - - local_command_shell - Shell to use for external command execution (for - example, /some/where/smrsh -c). When a shell is + Shell to use for external command execution (for + example, /some/where/smrsh -c). When a shell is specified, it is invoked even when the command con- - tains no shell built-in commands or meta charac- + tains no shell built-in commands or meta charac- ters. owner_request_special @@ -286,99 +309,113 @@ LOCAL(8) LOCAL(8) Mailbox delivery fallback_transport Message transport for recipients that are not found - in the UNIX passwd database. This parameter over- + in the UNIX passwd database. This parameter over- rides luser_relay. home_mailbox - Pathname of a mailbox relative to a user's home + Pathname of a mailbox relative to a user's home directory. Specify a path ending in / for maildir- style delivery. luser_relay - Destination (@domain or address) for non-existent - users. The address can be any destination that is + Destination (@domain or address) for non-existent + users. The address can be any destination that is valid in an alias file. + + + + + 5 + + + + + +LOCAL(8) LOCAL(8) + + mail_spool_directory - Directory with UNIX-style mailboxes. The default + Directory with UNIX-style mailboxes. The default pathname is system dependent. mailbox_command - External command to use for mailbox delivery. The + External command to use for mailbox delivery. The command executes with the recipient privileges (exception: root). mailbox_transport - Message transport to use for mailbox delivery to + Message transport to use for mailbox delivery to all local recipients, whether or not they are found - in the UNIX passwd database. This parameter over- - rides all other configuration parameters that con- + in the UNIX passwd database. This parameter over- + rides all other configuration parameters that con- trol mailbox delivery, including luser_relay. Locking controls deliver_lock_attempts - Limit the number of attempts to acquire an exclu- + Limit the number of attempts to acquire an exclu- sive lock on a mailbox or external file. deliver_lock_delay - Time in seconds between successive attempts to + Time in seconds between successive attempts to acquire an exclusive lock. - - - 5 - - - - - -LOCAL(8) LOCAL(8) - - stale_lock_time Limit the time after which a stale lock is removed. Resource controls command_time_limit - Limit the amount of time for delivery to external + Limit the amount of time for delivery to external command. duplicate_filter_limit - Limit the size of the duplicate filter for results + Limit the size of the duplicate filter for results from alias etc. expansion. line_length_limit - Limit the amount of memory used for processing a + Limit the amount of memory used for processing a partial input line. local_destination_concurrency_limit Limit the number of parallel deliveries to the same - user. The default limit is taken from the + user. The default limit is taken from the default_destination_concurrency_limit parameter. local_destination_recipient_limit - Limit the number of recipients per message deliv- - ery. The default limit is taken from the + Limit the number of recipients per message deliv- + ery. The default limit is taken from the default_destination_recipient_limit parameter. Security controls allow_mail_to_commands - Restrict the usage of mail delivery to external + Restrict the usage of mail delivery to external + + + + 6 + + + + + +LOCAL(8) LOCAL(8) + + command. allow_mail_to_files - Restrict the usage of mail delivery to external + Restrict the usage of mail delivery to external file. default_privs - Default rights for delivery to external file or + Default rights for delivery to external file or command. HISTORY - The Delivered-To: header appears in the qmail system by + The Delivered-To: header appears in the qmail system by Daniel Bernstein. - The maildir structure appears in the qmail system by + The maildir structure appears in the qmail system by Daniel Bernstein. SEE ALSO @@ -388,21 +425,8 @@ LOCAL(8) LOCAL(8) syslogd(8) system logging qmgr(8) queue manager - - - - - 6 - - - - - -LOCAL(8) LOCAL(8) - - LICENSE - The Secure Mailer license must be distributed with this + The Secure Mailer license must be distributed with this software. AUTHOR(S) @@ -430,30 +454,6 @@ LOCAL(8) LOCAL(8) - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/postfix/html/smtp.8.html b/postfix/html/smtp.8.html index 2988053e3..4dfcdfd0e 100644 --- a/postfix/html/smtp.8.html +++ b/postfix/html/smtp.8.html @@ -90,12 +90,16 @@ SMTP(8) SMTP(8) ging level by the amount specified in the debug_peer_level parameter. + disable_dns_lookups + Disable DNS lookups. This means that mail must be + forwarded via a smart relay host. + error_notice_recipient - Recipient of protocol/policy/resource/software + Recipient of protocol/policy/resource/software error notices. fallback_relay - Hosts to hand off mail to if a message destination + Hosts to hand off mail to if a message destination is not found or if a destination is unreachable. ignore_mx_lookup_error @@ -105,27 +109,23 @@ SMTP(8) SMTP(8) inet_interfaces The network interface addresses that this mail sys- - tem receives mail on. When any of those addresses + tem receives mail on. When any of those addresses appears in the list of mail exchangers for a remote - destination, the list is truncated to avoid mail + destination, the list is truncated to avoid mail delivery loops. notify_classes - When this parameter includes the protocol class, - send mail to the postmaster with transcripts of + When this parameter includes the protocol class, + send mail to the postmaster with transcripts of SMTP sessions with protocol errors. smtp_skip_4xx_greeting - Skip servers that greet us with a 4xx status code. + Skip servers that greet us with a 4xx status code. smtp_skip_quit_response - Do not wait for the server response after sending + Do not wait for the server response after sending QUIT. -Resource controls - smtp_destination_concurrency_limit - Limit the number of parallel deliveries to the same - 2 @@ -137,35 +137,38 @@ SMTP(8) SMTP(8) SMTP(8) SMTP(8) - destination. The default limit is taken from the +Resource controls + smtp_destination_concurrency_limit + Limit the number of parallel deliveries to the same + destination. The default limit is taken from the default_destination_concurrency_limit parameter. smtp_destination_recipient_limit - Limit the number of recipients per message deliv- - ery. The default limit is taken from the + Limit the number of recipients per message deliv- + ery. The default limit is taken from the default_destination_recipient_limit parameter. Timeout controls smtp_connect_timeout Timeout in seconds for completing a TCP connection. When no connection can be made within the deadline, - the SMTP client tries the next address on the mail + the SMTP client tries the next address on the mail exchanger list. smtp_helo_timeout - Timeout in seconds for receiving the SMTP greeting + Timeout in seconds for receiving the SMTP greeting banner. When the server drops the connection with- - out sending a greeting banner, or when it sends no + out sending a greeting banner, or when it sends no greeting banner within the deadline, the SMTP client tries the next address on the mail exchanger list. smtp_helo_timeout - Timeout in seconds for sending the HELO command, + Timeout in seconds for sending the HELO command, and for receiving the server response. smtp_mail_timeout - Timeout in seconds for sending the MAIL FROM com- + Timeout in seconds for sending the MAIL FROM com- mand, and for receiving the server response. smtp_rcpt_timeout @@ -173,7 +176,7 @@ SMTP(8) SMTP(8) and for receiving the server response. smtp_data_init_timeout - Timeout in seconds for sending the DATA command, + Timeout in seconds for sending the DATA command, and for receiving the server response. smtp_data_xfer_timeout @@ -182,16 +185,13 @@ SMTP(8) SMTP(8) smtp_data_done_timeout Timeout in seconds for sending the "." command, and for receiving the server response. When no response - is received, a warning is logged that the mail may + is received, a warning is logged that the mail may be delivered multiple times. smtp_quit_timeout - Timeout in seconds for sending the QUIT command, + Timeout in seconds for sending the QUIT command, and for receiving the server response. -SEE ALSO - bounce(8) non-delivery status reports - 3 @@ -203,12 +203,14 @@ SMTP(8) SMTP(8) SMTP(8) SMTP(8) +SEE ALSO + bounce(8) non-delivery status reports master(8) process manager qmgr(8) queue manager 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) @@ -255,8 +257,6 @@ SMTP(8) SMTP(8) - - diff --git a/postfix/local/.indent.pro b/postfix/local/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/local/.indent.pro +++ b/postfix/local/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/local/Makefile.in b/postfix/local/Makefile.in index 7f4a5f6ae..0eb8d6d3e 100644 --- a/postfix/local/Makefile.in +++ b/postfix/local/Makefile.in @@ -1,10 +1,12 @@ SHELL = /bin/sh SRCS = alias.c command.c delivered.c dotforward.c file.c forward.c \ include.c indirect.c local.c mailbox.c recipient.c resolve.c token.c \ - deliver_attr.c feature.c maildir.c biff_notify.c unknown.c + deliver_attr.c feature.c maildir.c biff_notify.c unknown.c \ + local_expand.c OBJS = alias.o command.o delivered.o dotforward.o file.o forward.o \ include.o indirect.o local.o mailbox.o recipient.o resolve.o token.o \ - deliver_attr.o feature.o maildir.o biff_notify.o unknown.o + deliver_attr.o feature.o maildir.o biff_notify.o unknown.o \ + local_expand.o HDRS = local.h TESTSRC = WARN = -W -Wformat -Wimplicit -Wmissing-prototypes \ @@ -27,10 +29,10 @@ Makefile: Makefile.in test: $(TESTPROG) -update: ../bin/$(PROG) +update: ../libexec/$(PROG) -../bin/$(PROG): $(PROG) - cp $(PROG) ../bin +../libexec/$(PROG): $(PROG) + cp $(PROG) ../libexec printfck: $(OBJS) $(PROG) rm -rf printfck @@ -287,6 +289,20 @@ local.o: ../include/mail_server.h local.o: local.h local.o: ../include/tok822.h local.o: ../include/resolve_clnt.h +local_expand.o: local_expand.c +local_expand.o: ../include/sys_defs.h +local_expand.o: ../include/vstring.h +local_expand.o: ../include/vbuf.h +local_expand.o: ../include/mac_expand.h +local_expand.o: ../include/mail_params.h +local_expand.o: local.h +local_expand.o: ../include/htable.h +local_expand.o: ../include/vstream.h +local_expand.o: ../include/been_here.h +local_expand.o: ../include/tok822.h +local_expand.o: ../include/resolve_clnt.h +local_expand.o: ../include/deliver_request.h +local_expand.o: ../include/recipient_list.h mailbox.o: mailbox.c mailbox.o: ../include/sys_defs.h mailbox.o: ../include/msg.h diff --git a/postfix/local/command.c b/postfix/local/command.c index 1502a46d2..c6a4b2425 100644 --- a/postfix/local/command.c +++ b/postfix/local/command.c @@ -24,8 +24,9 @@ /* .IP usr_attr /* Attributes describing user rights and environment. /* .IP command -/* The shell command to be executed. If possible, the command -/* is executed without actually invoking a shell. +/* The shell command to be executed, after $name expansion of recipient +/* attributes. If possible, the command is executed without actually +/* invoking a shell. /* DIAGNOSTICS /* deliver_command() returns non-zero when delivery should be /* tried again, @@ -81,6 +82,10 @@ int deliver_command(LOCAL_STATE state, USER_ATTR usr_attr, char *command) int deliver_status; ARGV *env; int copy_flags; + static char *ok_chars = "1234567890!@%-_=+:,./\ +abcdefghijklmnopqrstuvwxyz\ +ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + VSTRING *expanded_cmd; /* * Make verbose logging easier to understand. @@ -145,10 +150,16 @@ int deliver_command(LOCAL_STATE state, USER_ATTR usr_attr, char *command) argv_add(env, "SHELL", usr_attr.shell, ARGV_END); argv_terminate(env); + expanded_cmd = vstring_alloc(10); + if (command == var_mailbox_command) + local_expand(expanded_cmd, command, state, usr_attr, ok_chars); + else + vstring_strcpy(expanded_cmd, command); + cmd_status = pipe_command(state.msg_attr.fp, why, PIPE_CMD_UID, usr_attr.uid, PIPE_CMD_GID, usr_attr.gid, - PIPE_CMD_COMMAND, command, + PIPE_CMD_COMMAND, vstring_str(expanded_cmd), PIPE_CMD_COPY_FLAGS, copy_flags, PIPE_CMD_SENDER, state.msg_attr.sender, PIPE_CMD_DELIVERED, state.msg_attr.delivered, @@ -158,6 +169,7 @@ int deliver_command(LOCAL_STATE state, USER_ATTR usr_attr, char *command) PIPE_CMD_END); argv_free(env); + vstring_free(expanded_cmd); /* * Depending on the result, bounce or defer the message. diff --git a/postfix/local/dotforward.c b/postfix/local/dotforward.c index 6c18f5647..0c73a981a 100644 --- a/postfix/local/dotforward.c +++ b/postfix/local/dotforward.c @@ -84,83 +84,6 @@ #define NO 0 #define YES 1 - /* - * A little helper structure for message-specific context. - */ -typedef struct { - int flags; /* see below */ - struct mypasswd *pwd; /* recipient */ - char *extension; /* address extension */ - char *domain; /* recipient's domain */ - char *recipient; /* recipient */ - VSTRING *path; /* result */ -} FW_CONTEXT; - -#define FW_FLAG_FAILURE (1<<0) /* $name not available */ -#define FW_FLAG_HOME (1<<1) /* expanded $home */ -#define FW_FLAG_USER (1<<2) /* expanded $user */ -#define FW_FLAG_EXTENSION (1<<3) /* expanded $extension */ -#define FW_FLAG_DELIMITER (1<<4) /* expanded $recipient_delimiter */ -#define FW_FLAG_DOMAIN (1<<5) /* expanded $domain */ -#define FW_FLAG_RECIPIENT (1<<6) /* expanded $recipient */ -#define FW_FLAG_OTHER (1<<7) /* expanded text */ - -/* dotforward_parse_callback - callback for mac_parse */ - -static void dotforward_parse_callback(int type, VSTRING *buf, char *context) -{ - char *myname = "dotforward_parse_callback"; - FW_CONTEXT *fw_context = (FW_CONTEXT *) context; - char *ptr; - int flg; - - if (fw_context->flags & FW_FLAG_FAILURE) - return; - - /* - * Find out what data to substitute. - */ - if (type == MAC_PARSE_VARNAME) { - if (strcmp(vstring_str(buf), "home") == 0) { - flg = FW_FLAG_HOME; - ptr = fw_context->pwd->pw_dir; - } else if (strcmp(vstring_str(buf), "user") == 0) { - flg = FW_FLAG_USER; - ptr = fw_context->pwd->pw_name; - } else if (strcmp(vstring_str(buf), "extension") == 0) { - flg = FW_FLAG_EXTENSION; - ptr = fw_context->extension; - } else if (strcmp(vstring_str(buf), "recipient_delimiter") == 0) { - flg = FW_FLAG_DELIMITER; - ptr = var_rcpt_delim; - } else if (strcmp(vstring_str(buf), "domain") == 0) { - flg = FW_FLAG_DOMAIN; - ptr = fw_context->domain; - } else if (strcmp(vstring_str(buf), "recipient") == 0) { - flg = FW_FLAG_RECIPIENT; - ptr = fw_context->recipient; - } else - msg_fatal("unknown macro $%s in %s", vstring_str(buf), - VAR_FORWARD_PATH); - } else { - flg = FW_FLAG_OTHER; - ptr = vstring_str(buf); - } - - /* - * Append the data, or record that the data was not available. - */ - if (msg_verbose) - msg_info("%s: %s = %s", myname, vstring_str(buf), - ptr ? ptr : "(unavailable)"); - if (ptr == 0) { - fw_context->flags |= FW_FLAG_FAILURE; - } else { - fw_context->flags |= flg; - vstring_strcat(fw_context->path, ptr); - } -} - /* deliver_dotforward - expand contents of .forward file */ int deliver_dotforward(LOCAL_STATE state, USER_ATTR usr_attr, int *statusp) @@ -178,9 +101,7 @@ int deliver_dotforward(LOCAL_STATE state, USER_ATTR usr_attr, int *statusp) char *saved_forward_path; char *lhs; char *next; - char *domain; const char *forward_path; - FW_CONTEXT fw_context; /* * Make verbose logging easier to understand. @@ -274,33 +195,18 @@ int deliver_dotforward(LOCAL_STATE state, USER_ATTR usr_attr, int *statusp) path = vstring_alloc(100); saved_forward_path = mystrdup(forward_path); next = saved_forward_path; - - if ((domain = strrchr(state.msg_attr.recipient, '@')) != 0) - domain++; - - fw_context.pwd = mypwd; - fw_context.extension = state.msg_attr.extension; - fw_context.path = path; - fw_context.domain = domain; - fw_context.recipient = state.msg_attr.recipient; - lookup_status = -1; while ((lhs = mystrtok(&next, ", \t\r\n")) != 0) { - fw_context.flags = 0; VSTRING_RESET(path); - mac_parse(lhs, dotforward_parse_callback, (char *) &fw_context); - if ((fw_context.flags & FW_FLAG_FAILURE) == 0) { + if (local_expand(path, lhs, state, usr_attr, (char *) 0) == 0) { lookup_status = lstat_as(STR(path), &st, usr_attr.uid, usr_attr.gid); if (msg_verbose) msg_info("%s: path %s status %d", myname, STR(path), lookup_status); - if (lookup_status >= 0) { - if (fw_context.flags & FW_FLAG_EXTENSION) - state.msg_attr.extension = 0; + if (lookup_status >= 0) break; - } } } diff --git a/postfix/local/local.c b/postfix/local/local.c index e865bb267..3147a3928 100644 --- a/postfix/local/local.c +++ b/postfix/local/local.c @@ -27,6 +27,19 @@ /* destinations in ~\fIname\fR/.\fBforward\fR, to the mailbox owned /* by the user \fIname\fR, or it is sent back as undeliverable. /* +/* The system administrator can specify a comma/space separated list +/* of ~\fR/.\fBforward\fR like files through the \fBforward_path\fR +/* configuration parameter. Upon delivery, the local delivery agent +/* tries each pathname in the list until a file is found. +/* The \fBforward_path\fR parameter is subject to interpolation of +/* \fB$user\fR (recipient username), \fB$home\fR (recipient home +/* directory), \fB$shell\fR (recipient shell), \fB$recipient\fR +/* (complete recipient address), \fB$extension\fR (recipient address +/* extension), \fB$domain\fR (recipient domain) and +/* \fB$recipient_delimiter.\fR The forms \fI${name?value}\fR and +/* \fI${name:value}\fR expand conditionally to \fIvalue\fR when +/* \fI$name\fR is (is not) defined. +/* /* An alias or ~/.\fBforward\fR file may list any combination of external /* commands, destination file names, \fB:include:\fR directives, or /* mail addresses. @@ -77,6 +90,15 @@ /* executes with the privileges of the recipient user (exception: in /* case of delivery as root, the command executes with the privileges /* of \fBdefault_user\fR). +/* The command is subject to interpolation of \fB$user\fR (recipient +/* username), \fB$home\fR (recipient home directory), \fB$shell\fR +/* (recipient shell), \fB$recipient\fR (complete recipient address), +/* \fB$extension\fR (recipient address extension), \fB$domain\fR +/* (recipient domain) and \fB$recipient_delimiter.\fR The forms +/* \fI${name?value}\fR and \fI${name:value}\fR expand conditionally to +/* \fIvalue\fR when \fI$name\fR is (is not) defined. In the result +/* of \fIname\fR expansion, characters that have special meaning to +/* the shell are censored and replaced by underscores. /* /* Mailbox delivery can be delegated to alternative message transports /* specified in the \fBmaster.cf\fR file. @@ -504,7 +526,7 @@ static void local_mask_init(void) /* pre_accept - see if tables have changed */ -static void pre_accept(void) +static void pre_accept(char *unused_name, char **unused_argv) { if (dict_changed()) { msg_info("table has changed -- exiting"); @@ -514,7 +536,7 @@ static void pre_accept(void) /* post_init - post-jail initialization */ -static void post_init(void) +static void post_init(char *unused_name, char **unused_argv) { /* @@ -536,7 +558,6 @@ int main(int argc, char **argv) static CONFIG_STR_TABLE str_table[] = { VAR_ALIAS_MAPS, DEF_ALIAS_MAPS, &var_alias_maps, 0, 0, VAR_HOME_MAILBOX, DEF_HOME_MAILBOX, &var_home_mailbox, 0, 0, - VAR_MAILBOX_COMMAND, DEF_MAILBOX_COMMAND, &var_mailbox_command, 0, 0, VAR_ALLOW_COMMANDS, DEF_ALLOW_COMMANDS, &var_allow_commands, 0, 0, VAR_ALLOW_FILES, DEF_ALLOW_FILES, &var_allow_files, 0, 0, VAR_RCPT_FDELIM, DEF_RCPT_FDELIM, &var_rcpt_fdelim, 0, 0, @@ -555,6 +576,7 @@ int main(int argc, char **argv) /* Suppress $name expansion upon loading. */ static CONFIG_STR_TABLE raw_table[] = { VAR_FORWARD_PATH, DEF_FORWARD_PATH, &var_forward_path, 0, 0, + VAR_MAILBOX_COMMAND, DEF_MAILBOX_COMMAND, &var_mailbox_command, 0, 0, 0, }; diff --git a/postfix/local/local.h b/postfix/local/local.h index 16a72df9a..2f72de13c 100644 --- a/postfix/local/local.h +++ b/postfix/local/local.h @@ -181,6 +181,11 @@ extern int forward_finish(DELIVER_ATTR, int); */ extern int feature_control(const char *); + /* + * local_expand.c + */ +int local_expand(VSTRING *, const char *, LOCAL_STATE, USER_ATTR, const char *); + /* LICENSE /* .ad /* .fi diff --git a/postfix/local/local_expand.c b/postfix/local/local_expand.c new file mode 100644 index 000000000..e8563e45a --- /dev/null +++ b/postfix/local/local_expand.c @@ -0,0 +1,109 @@ +/*++ +/* NAME +/* local_expand 3 +/* SUMMARY +/* expand $name based on delivery attributes +/* SYNOPSIS +/* #include "local.h" +/* +/* int local_expand(result, pattern, state, usr_attr, filter) +/* VSTRING *result; +/* const char *pattern; +/* LOCAL_STATE state; +/* USER_ATTR usr_attr; +/* const char *filter; +/* DESCRIPTION +/* local_expand() expands $name instances on the basis of message +/* delivery attributes. +/* +/* Macros: +/* .IP $domain +/* The recipient address domain. +/* .IP $extension +/* The recipient address extension. +/* .IP $home +/* The recipient home directory. +/* .IP $recipient +/* The full recipient address. +/* .IP $recipient_delimiter +/* The recipient delimiter. +/* .IP $shell +/* The recipient shell program. +/* .IP $user +/* The recipient user name. +/* .PP +/* Arguments: +/* .IP result +/* Storage for the result. The result is truncated upon entry. +/* .IP pattern +/* The input with zero or more $name references. +/* .IP state +/* Message delivery attributes (sender, recipient etc.). +/* Attributes describing alias, include or forward expansion. +/* A table with the results from expanding aliases or lists. +/* A table with delivered-to: addresses taken from the message. +/* .IP usr_attr +/* Attributes describing user rights and environment. +/* .IP filter +/* A null pointer, or a null-terminated list of characters that +/* are allowed to appear in the result if a $name expansion. +/* DIAGNOSTICS +/* Fatal errors: out of memory. +/* SEE ALSO +/* mac_expand(3) macro expansion +/* 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 + +/* Utility library. */ + +#include +#include + +/* Global library. */ + +#include + +/* Application-specific. */ + +#include "local.h" + +/* local_expand - expand contents of .forward file */ + +int local_expand(VSTRING *result, const char *pattern, + LOCAL_STATE state, USER_ATTR usr_attr, const char *filter) +{ + char *domain; + + /* + * Impedance matching between the local delivery agent data structures + * and the mac_expand() interface. The CPU cycles wasted will be + * negligible. + */ + if ((domain = strrchr(state.msg_attr.recipient, '@')) != 0) + domain++; + + return (mac_expand(result, pattern, MAC_EXP_FLAG_NONE, + MAC_EXP_ARG_FILTER, filter, + MAC_EXP_ARG_ATTR, "user", usr_attr.logname, + MAC_EXP_ARG_ATTR, "home", usr_attr.home, + MAC_EXP_ARG_ATTR, "shell", usr_attr.shell, + MAC_EXP_ARG_ATTR, "domain", domain, + MAC_EXP_ARG_ATTR, "recipient", state.msg_attr.recipient, + MAC_EXP_ARG_ATTR, "extension", state.msg_attr.extension, + MAC_EXP_ARG_ATTR, "recipient_delimiter", + *var_rcpt_delim ? var_rcpt_delim : 0, + 0)); +} diff --git a/postfix/local/resolve.c b/postfix/local/resolve.c index 2e0f339da..04ce7405d 100644 --- a/postfix/local/resolve.c +++ b/postfix/local/resolve.c @@ -114,6 +114,7 @@ int deliver_resolve_tree(LOCAL_STATE state, USER_ATTR usr_attr, TOK822 *addr tok822_resolve(addr, &reply); state.msg_attr.recipient = STR(reply.recipient); +#if 0 /* * Splice in the optional unmatched address extension. */ @@ -130,6 +131,7 @@ int deliver_resolve_tree(LOCAL_STATE state, USER_ATTR usr_attr, TOK822 *addr VSTRING_SKIP(reply.recipient); } } +#endif /* * Delivery to a local or non-local address. For a while there was some diff --git a/postfix/man/Makefile.in b/postfix/man/Makefile.in index 01f1e374d..df598450a 100644 --- a/postfix/man/Makefile.in +++ b/postfix/man/Makefile.in @@ -1,6 +1,6 @@ # For now, just hard-coded rules for daemons, commands, config files. -DAEMONS = man8/bounce.8 man8/defer.8 man8/cleanup.8 man8/local.8 \ +DAEMONS = man8/bounce.8 man8/defer.8 man8/cleanup.8 man8/error.8 man8/local.8 \ man8/master.8 man8/pickup.8 man8/pipe.8 man8/qmgr.8 man8/showq.8 \ man8/smtp.8 man8/smtpd.8 man8/trivial-rewrite.8 COMMANDS= man1/postalias.1 man1/postcat.1 man1/postconf.1 man1/postfix.1 \ @@ -32,6 +32,9 @@ man8/defer.8: man8/cleanup.8: ../cleanup/cleanup.c srctoman $? >$@ +man8/error.8: ../error/error.c + srctoman $? >$@ + man8/local.8: ../local/local.c srctoman $? >$@ diff --git a/postfix/man/man8/error.8 b/postfix/man/man8/error.8 new file mode 100644 index 000000000..b33b45325 --- /dev/null +++ b/postfix/man/man8/error.8 @@ -0,0 +1,86 @@ +.TH ERROR 8 +.ad +.fi +.SH NAME +error +\- +Postfix error mailer +.SH SYNOPSIS +.na +.nf +\fBerror\fR [generic Postfix daemon options] +.SH DESCRIPTION +.ad +.fi +The Postfix error mailer processes message delivery requests from +the queue manager. Each request specifies a queue file, a sender +address, a domain or host name that is treated as the reason for +non-delivery, and recipient information. +This program expects to be run from the \fBmaster\fR(8) process +manager. + +The error mailer client forces all recipients to bounce, using the +domain or host information as the reason for non-delivery, updates +the queue file and marks recipients as finished, or it informs the +queue manager that delivery should be tried again at a later time. + +Delivery problem reports are sent to the \fBbounce\fR(8) or +\fBdefer\fR(8) daemon as appropriate. +.SH SECURITY +.na +.nf +.ad +.fi +The error mailer is not security-sensitive. It does not talk +to the network, and can be run chrooted at fixed low privilege. +.SH STANDARDS +.na +.nf +None. +.SH DIAGNOSTICS +.ad +.fi +Problems and transactions are logged to \fBsyslogd\fR(8). + +Depending on the setting of the \fBnotify_classes\fR parameter, +the postmaster is notified of bounces and of other trouble. +.SH BUGS +.ad +.fi +.SH CONFIGURATION PARAMETERS +.na +.nf +.ad +.fi +The following \fBmain.cf\fR parameters are especially relevant to +this program. See the Postfix \fBmain.cf\fR file for syntax details +and for default values. Use the \fBpostfix reload\fR command after +a configuration change. +.SH Miscellaneous +.ad +.fi +.IP \fBbounce_notice_recipient\fR +Postmaster for bounce error notices. +.IP \fBnotify_classes\fR +When this parameter includes the \fBbounce\fR class, send mail to the +postmaster with with the headers of the bounced mail. +.SH SEE ALSO +.na +.nf +bounce(8) non-delivery status reports +master(8) process manager +qmgr(8) queue manager +syslogd(8) system logging +.SH LICENSE +.na +.nf +.ad +.fi +The Secure Mailer license must be distributed with this software. +.SH AUTHOR(S) +.na +.nf +Wietse Venema +IBM T.J. Watson Research +P.O. Box 704 +Yorktown Heights, NY 10598, USA diff --git a/postfix/man/man8/local.8 b/postfix/man/man8/local.8 index 1f5215778..dca195cb8 100644 --- a/postfix/man/man8/local.8 +++ b/postfix/man/man8/local.8 @@ -35,6 +35,19 @@ Mail for \fIname\fR is delivered to the alias \fIname\fR, to destinations in ~\fIname\fR/.\fBforward\fR, to the mailbox owned by the user \fIname\fR, or it is sent back as undeliverable. +The system administrator can specify a comma/space separated list +of ~\fR/.\fBforward\fR like files through the \fBforward_path\fR +configuration parameter. Upon delivery, the local delivery agent +tries each pathname in the list until a file is found. +The \fBforward_path\fR parameter is subject to interpolation of +\fB$user\fR (recipient username), \fB$home\fR (recipient home +directory), \fB$shell\fR (recipient shell), \fB$recipient\fR +(complete recipient address), \fB$extension\fR (recipient address +extension), \fB$domain\fR (recipient domain) and +\fB$recipient_delimiter.\fR The forms \fI${name?value}\fR and +\fI${name:value}\fR expand conditionally to \fIvalue\fR when +\fI$name\fR is (is not) defined. + An alias or ~/.\fBforward\fR file may list any combination of external commands, destination file names, \fB:include:\fR directives, or mail addresses. @@ -89,6 +102,15 @@ with the \fBmailbox_command\fR configuration parameter. The command executes with the privileges of the recipient user (exception: in case of delivery as root, the command executes with the privileges of \fBdefault_user\fR). +The command is subject to interpolation of \fB$user\fR (recipient +username), \fB$home\fR (recipient home directory), \fB$shell\fR +(recipient shell), \fB$recipient\fR (complete recipient address), +\fB$extension\fR (recipient address extension), \fB$domain\fR +(recipient domain) and \fB$recipient_delimiter.\fR The forms +\fI${name?value}\fR and \fI${name:value}\fR expand conditionally to +\fIvalue\fR when \fI$name\fR is (is not) defined. In the result +of \fIname\fR expansion, characters that have special meaning to +the shell are censored and replaced by underscores. Mailbox delivery can be delegated to alternative message transports specified in the \fBmaster.cf\fR file. diff --git a/postfix/man/man8/smtp.8 b/postfix/man/man8/smtp.8 index 6dbd17a8b..18db2df16 100644 --- a/postfix/man/man8/smtp.8 +++ b/postfix/man/man8/smtp.8 @@ -82,6 +82,9 @@ pattern in the \fBdebug_peer_list\fR parameter. List of domain or network patterns. When a remote host matches a pattern, increase the verbose logging level by the amount specified in the \fBdebug_peer_level\fR parameter. +.IP \fBdisable_dns_lookups\fR +Disable DNS lookups. This means that mail must be forwarded +via a smart relay host. .IP \fBerror_notice_recipient\fR Recipient of protocol/policy/resource/software error notices. .IP \fBfallback_relay\fR diff --git a/postfix/master/.indent.pro b/postfix/master/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/master/.indent.pro +++ b/postfix/master/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/master/Makefile.in b/postfix/master/Makefile.in index c0840d633..fe194f86e 100644 --- a/postfix/master/Makefile.in +++ b/postfix/master/Makefile.in @@ -20,7 +20,7 @@ TESTPROG= LIBS = ../lib/libglobal.a ../lib/libutil.a LIB_DIR = ../lib INC_DIR = ../include -BIN_DIR = ../bin +BIN_DIR = ../libexec .c.o:; $(CC) $(CFLAGS) -c $*.c diff --git a/postfix/master/mail_server.h b/postfix/master/mail_server.h index 303f9ca7f..4e3c9b74e 100644 --- a/postfix/master/mail_server.h +++ b/postfix/master/mail_server.h @@ -27,10 +27,10 @@ #define MAIL_SERVER_EXIT 13 #define MAIL_SERVER_PRE_ACCEPT 14 -typedef void (*MAIL_SERVER_INIT_FN) (void); -typedef int (*MAIL_SERVER_LOOP_FN) (void); -typedef void (*MAIL_SERVER_EXIT_FN) (void); -typedef void (*MAIL_SERVER_ACCEPT_FN) (void); +typedef void (*MAIL_SERVER_INIT_FN) (char *, char **); +typedef int (*MAIL_SERVER_LOOP_FN) (char *, char **); +typedef void (*MAIL_SERVER_EXIT_FN) (char *, char **); +typedef void (*MAIL_SERVER_ACCEPT_FN) (char *, char **); /* * single_server.c diff --git a/postfix/master/multi_server.c b/postfix/master/multi_server.c index 1163f89c2..68a6fcda9 100644 --- a/postfix/master/multi_server.c +++ b/postfix/master/multi_server.c @@ -62,25 +62,25 @@ /* order as specified, and multiple instances of the same type /* are allowed. Raw parameters are not subjected to $name /* evaluation. -/* .IP "MAIL_SERVER_PRE_INIT (void *(void))" +/* .IP "MAIL_SERVER_PRE_INIT (void *(char *service_name char **argv))" /* A pointer to a function that is called once /* by the skeleton after it has read the global configuration file /* and after it has processed command-line arguments, but before /* the skeleton has optionally relinquished the process privileges. -/* .IP "MAIL_SERVER_POST_INIT (void *(void))" +/* .IP "MAIL_SERVER_POST_INIT (void *(char *service_name char **argv))" /* A pointer to a function that is called once /* by the skeleton after it has optionally relinquished the process /* privileges, but before servicing client connection requests. -/* .IP "MAIL_SERVER_LOOP (int *(void))" +/* .IP "MAIL_SERVER_LOOP (int *(char *service_name char **argv))" /* A pointer to function that is executed from /* within the event loop, whenever an I/O or timer event has happened, /* or whenever nothing has happened for a specified amount of time. /* The result value of the function specifies how long to wait until /* the next event. Specify -1 to wait for "as long as it takes". -/* .IP "MAIL_SERVER_EXIT (void *(void))" +/* .IP "MAIL_SERVER_EXIT (void *(char *service_name char **argv))" /* A pointer to function that is executed immediately before normal /* process termination. -/* .IP "MAIL_SERVER_PRE_ACCEPT (void *(void))" +/* .IP "MAIL_SERVER_PRE_ACCEPT (void *(char *service_name char **argv))" /* Function to be executed prior to accepting a new connection. /* .PP /* multi_server_disconnect() should be called by the application @@ -172,8 +172,8 @@ static void (*multi_server_service) (VSTREAM *, char *, char **); static char *multi_server_name; static char **multi_server_argv; static void (*multi_server_accept) (int, char *); -static void (*multi_server_onexit) (void); -static void (*multi_server_pre_accept) (void); +static void (*multi_server_onexit) (char *, char **); +static void (*multi_server_pre_accept) (char *, char **); static VSTREAM *multi_server_lock; /* multi_server_exit - normal termination */ @@ -181,7 +181,7 @@ static VSTREAM *multi_server_lock; static NORETURN multi_server_exit(void) { if (multi_server_onexit) - multi_server_onexit(); + multi_server_onexit(multi_server_name, multi_server_argv); exit(0); } @@ -291,7 +291,7 @@ static void multi_server_accept_local(int unused_event, char *context) time_left = event_cancel_timer(multi_server_timeout, (char *) 0); if (multi_server_pre_accept) - multi_server_pre_accept(); + multi_server_pre_accept(multi_server_name, multi_server_argv); fd = LOCAL_ACCEPT(listen_fd); if (multi_server_lock != 0 && myflock(vstream_fileno(multi_server_lock), MYFLOCK_NONE) < 0) @@ -331,7 +331,7 @@ static void multi_server_accept_inet(int unused_event, char *context) time_left = event_cancel_timer(multi_server_timeout, (char *) 0); if (multi_server_pre_accept) - multi_server_pre_accept(); + multi_server_pre_accept(multi_server_name, multi_server_argv); fd = inet_accept(listen_fd); if (multi_server_lock != 0 && myflock(vstream_fileno(multi_server_lock), MYFLOCK_NONE) < 0) @@ -537,7 +537,7 @@ NORETURN multi_server_main(int argc, char **argv, MULTI_SERVER_FN service,...) * Run pre-jail initialization. */ if (pre_init) - pre_init(); + pre_init(multi_server_name, multi_server_argv); /* * Optionally, restrict the damage that this process can do. @@ -551,7 +551,7 @@ NORETURN multi_server_main(int argc, char **argv, MULTI_SERVER_FN service,...) * Run post-jail initialization. */ if (post_init) - post_init(); + post_init(multi_server_name, multi_server_argv); /* * Are we running as a one-shot server with the client connection on @@ -586,7 +586,7 @@ NORETURN multi_server_main(int argc, char **argv, MULTI_SERVER_FN service,...) event_enable_read(MASTER_STATUS_FD, multi_server_abort, (char *) 0); close_on_exec(MASTER_STATUS_FD, CLOSE_ON_EXEC); while (var_use_limit == 0 || use_count < var_use_limit || client_count > 0) { - delay = loop ? loop() : -1; + delay = loop ? loop(multi_server_name, multi_server_argv) : -1; if (multi_server_lock != 0 && myflock(vstream_fileno(multi_server_lock), MYFLOCK_EXCLUSIVE) < 0) msg_fatal("select lock: %m"); diff --git a/postfix/master/single_server.c b/postfix/master/single_server.c index 708b04142..744afc420 100644 --- a/postfix/master/single_server.c +++ b/postfix/master/single_server.c @@ -57,16 +57,16 @@ /* order as specified, and multiple instances of the same type /* are allowed. Raw parameters are not subjected to $name /* evaluation. -/* .IP "MAIL_SERVER_PRE_INIT (void *(void))" +/* .IP "MAIL_SERVER_PRE_INIT (void *(char *service_name char **argv))" /* A pointer to a function that is called once /* by the skeleton after it has read the global configuration file /* and after it has processed command-line arguments, but before /* the skeleton has optionally relinquished the process privileges. -/* .IP "MAIL_SERVER_POST_INIT (void *(void))" +/* .IP "MAIL_SERVER_POST_INIT (void *(char *service_name char **argv))" /* A pointer to a function that is called once /* by the skeleton after it has optionally relinquished the process /* privileges, but before servicing client connection requests. -/* .IP "MAIL_SERVER_LOOP (int *(void))" +/* .IP "MAIL_SERVER_LOOP (int *(char *service_name char **argv))" /* A pointer to function that is executed from /* within the event loop, whenever an I/O or timer event has happened, /* or whenever nothing has happened for a specified amount of time. @@ -75,7 +75,7 @@ /* .IP "MAIL_SERVER_EXIT (void *(void))" /* A pointer to function that is executed immediately before normal /* process termination. -/* .IP "MAIL_SERVER_PRE_ACCEPT (void *(void))" +/* .IP "MAIL_SERVER_PRE_ACCEPT (void *(char *service_name char **argv))" /* Function to be executed prior to accepting a new connection. /* .PP /* The var_use_limit variable limits the number of clients that @@ -162,8 +162,8 @@ static void (*single_server_service) (VSTREAM *, char *, char **); static char *single_server_name; static char **single_server_argv; static void (*single_server_accept) (int, char *); -static void (*single_server_onexit) (void); -static void (*single_server_pre_accept) (void); +static void (*single_server_onexit) (char *, char **); +static void (*single_server_pre_accept) (char *, char **); static VSTREAM *single_server_lock; /* single_server_exit - normal termination */ @@ -171,7 +171,7 @@ static VSTREAM *single_server_lock; static NORETURN single_server_exit(void) { if (single_server_onexit) - single_server_onexit(); + single_server_onexit(single_server_name, single_server_argv); exit(0); } @@ -261,7 +261,7 @@ static void single_server_accept_local(int unused_event, char *context) time_left = event_cancel_timer(single_server_timeout, (char *) 0); if (single_server_pre_accept) - single_server_pre_accept(); + single_server_pre_accept(single_server_name, single_server_argv); fd = LOCAL_ACCEPT(listen_fd); if (single_server_lock != 0 && myflock(vstream_fileno(single_server_lock), MYFLOCK_NONE) < 0) @@ -300,7 +300,7 @@ static void single_server_accept_inet(int unused_event, char *context) time_left = event_cancel_timer(single_server_timeout, (char *) 0); if (single_server_pre_accept) - single_server_pre_accept(); + single_server_pre_accept(single_server_name, single_server_argv); fd = inet_accept(listen_fd); if (single_server_lock != 0 && myflock(vstream_fileno(single_server_lock), MYFLOCK_NONE) < 0) @@ -506,7 +506,7 @@ NORETURN single_server_main(int argc, char **argv, SINGLE_SERVER_FN service,...) * Run pre-jail initialization. */ if (pre_init) - pre_init(); + pre_init(single_server_name, single_server_argv); /* * Optionally, restrict the damage that this process can do. @@ -520,7 +520,7 @@ NORETURN single_server_main(int argc, char **argv, SINGLE_SERVER_FN service,...) * Run post-jail initialization. */ if (post_init) - post_init(); + post_init(single_server_name, single_server_argv); /* * Are we running as a one-shot server with the client connection on @@ -555,7 +555,7 @@ NORETURN single_server_main(int argc, char **argv, SINGLE_SERVER_FN service,...) event_enable_read(MASTER_STATUS_FD, single_server_abort, (char *) 0); close_on_exec(MASTER_STATUS_FD, CLOSE_ON_EXEC); while (var_use_limit == 0 || use_count < var_use_limit) { - delay = loop ? loop() : -1; + delay = loop ? loop(single_server_name, single_server_argv) : -1; if (single_server_lock != 0 && myflock(vstream_fileno(single_server_lock), MYFLOCK_EXCLUSIVE) < 0) msg_fatal("select lock: %m"); diff --git a/postfix/master/trigger_server.c b/postfix/master/trigger_server.c index d145682a3..791c101ea 100644 --- a/postfix/master/trigger_server.c +++ b/postfix/master/trigger_server.c @@ -64,25 +64,25 @@ /* order as specified, and multiple instances of the same type /* are allowed. Raw parameters are not subjected to $name /* evaluation. -/* .IP "MAIL_SERVER_PRE_INIT (void *(void))" +/* .IP "MAIL_SERVER_PRE_INIT (void *(char *service_name, char **argv))" /* A pointer to a function that is called once /* by the skeleton after it has read the global configuration file /* and after it has processed command-line arguments, but before /* the skeleton has optionally relinquished the process privileges. -/* .IP "MAIL_SERVER_POST_INIT (void *(void))" +/* .IP "MAIL_SERVER_POST_INIT (void *(char *service_name, char **argv))" /* A pointer to a function that is called once /* by the skeleton after it has optionally relinquished the process /* privileges, but before servicing client connection requests. -/* .IP "MAIL_SERVER_LOOP (int *(void))" +/* .IP "MAIL_SERVER_LOOP (int *(char *service_name, char **argv))" /* A pointer to function that is executed from /* within the event loop, whenever an I/O or timer event has happened, /* or whenever nothing has happened for a specified amount of time. /* The result value of the function specifies how long to wait until /* the next event. Specify -1 to wait for "as long as it takes". -/* .IP "MAIL_SERVER_EXIT (void *(void))" +/* .IP "MAIL_SERVER_EXIT (void *(char *service_name, char **argv))" /* A pointer to function that is executed immediately before normal /* process termination. -/* .IP "MAIL_SERVER_PRE_ACCEPT (void *(void))" +/* .IP "MAIL_SERVER_PRE_ACCEPT (void *(char *service_name, char **argv))" /* Function to be executed prior to accepting a new request. /* .PP /* The var_use_limit variable limits the number of clients that @@ -169,8 +169,8 @@ static TRIGGER_SERVER_FN trigger_server_service; static char *trigger_server_name; static char **trigger_server_argv; static void (*trigger_server_accept) (int, char *); -static void (*trigger_server_onexit) (void); -static void (*trigger_server_pre_accept) (void); +static void (*trigger_server_onexit) (char *, char **); +static void (*trigger_server_pre_accept) (char *, char **); static VSTREAM *trigger_server_lock; /* trigger_server_exit - normal termination */ @@ -178,7 +178,7 @@ static VSTREAM *trigger_server_lock; static NORETURN trigger_server_exit(void) { if (trigger_server_onexit) - trigger_server_onexit(); + trigger_server_onexit(trigger_server_name, trigger_server_argv); exit(0); } @@ -260,7 +260,7 @@ static void trigger_server_accept_fifo(int unused_event, char *context) * non-blocking so we won't get stuck when multiple processes wake up. */ if (trigger_server_pre_accept) - trigger_server_pre_accept(); + trigger_server_pre_accept(trigger_server_name, trigger_server_argv); trigger_server_wakeup(listen_fd); } @@ -294,7 +294,7 @@ static void trigger_server_accept_local(int unused_event, char *context) time_left = event_cancel_timer(trigger_server_timeout, (char *) 0); if (trigger_server_pre_accept) - trigger_server_pre_accept(); + trigger_server_pre_accept(trigger_server_name, trigger_server_argv); fd = LOCAL_ACCEPT(listen_fd); if (trigger_server_lock != 0 && myflock(vstream_fileno(trigger_server_lock), MYFLOCK_NONE) < 0) @@ -521,7 +521,7 @@ NORETURN trigger_server_main(int argc, char **argv, TRIGGER_SERVER_FN service,.. * Run pre-jail initialization. */ if (pre_init) - pre_init(); + pre_init(trigger_server_name, trigger_server_argv); /* * Optionally, restrict the damage that this process can do. @@ -535,7 +535,7 @@ NORETURN trigger_server_main(int argc, char **argv, TRIGGER_SERVER_FN service,.. * Run post-jail initialization. */ if (post_init) - post_init(); + post_init(trigger_server_name, trigger_server_argv); /* * Are we running as a one-shot server with the client connection on @@ -567,7 +567,7 @@ NORETURN trigger_server_main(int argc, char **argv, TRIGGER_SERVER_FN service,.. event_enable_read(MASTER_STATUS_FD, trigger_server_abort, (char *) 0); close_on_exec(MASTER_STATUS_FD, CLOSE_ON_EXEC); while (var_use_limit == 0 || use_count < var_use_limit) { - delay = loop ? loop() : -1; + delay = loop ? loop(trigger_server_name, trigger_server_argv) : -1; if (trigger_server_lock != 0 && myflock(vstream_fileno(trigger_server_lock), MYFLOCK_EXCLUSIVE) < 0) msg_fatal("select lock: %m"); diff --git a/postfix/pickup/.indent.pro b/postfix/pickup/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/pickup/.indent.pro +++ b/postfix/pickup/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/pickup/Makefile.in b/postfix/pickup/Makefile.in index 119491852..1701c087b 100644 --- a/postfix/pickup/Makefile.in +++ b/postfix/pickup/Makefile.in @@ -23,10 +23,10 @@ Makefile: Makefile.in test: $(TESTPROG) -update: ../bin/$(PROG) +update: ../libexec/$(PROG) -../bin/$(PROG): $(PROG) - cp $(PROG) ../bin +../libexec/$(PROG): $(PROG) + cp $(PROG) ../libexec printfck: $(OBJS) $(PROG) rm -rf printfck diff --git a/postfix/pickup/pickup.c b/postfix/pickup/pickup.c index 5eeb9a10b..7359d4ce8 100644 --- a/postfix/pickup/pickup.c +++ b/postfix/pickup/pickup.c @@ -400,7 +400,7 @@ static void pickup_service(char *unused_buf, int unused_len, /* drop_privileges - drop privileges most of the time */ -static void drop_privileges(void) +static void drop_privileges(char *unused_name, char **unused_argv) { set_eugid(var_owner_uid, var_owner_gid); } diff --git a/postfix/pipe/.indent.pro b/postfix/pipe/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/pipe/.indent.pro +++ b/postfix/pipe/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/pipe/Makefile.in b/postfix/pipe/Makefile.in index 7693befbf..0a24077ea 100644 --- a/postfix/pipe/Makefile.in +++ b/postfix/pipe/Makefile.in @@ -23,10 +23,10 @@ Makefile: Makefile.in test: $(TESTPROG) -update: ../bin/$(PROG) +update: ../libexec/$(PROG) -../bin/$(PROG): $(PROG) - cp $(PROG) ../bin +../libexec/$(PROG): $(PROG) + cp $(PROG) ../libexec printfck: $(OBJS) $(PROG) rm -rf printfck diff --git a/postfix/pipe/pipe.c b/postfix/pipe/pipe.c index 35b765c0e..c61005f39 100644 --- a/postfix/pipe/pipe.c +++ b/postfix/pipe/pipe.c @@ -677,7 +677,7 @@ static void pipe_service(VSTREAM *client_stream, char *service, char **argv) /* pre_accept - see if tables have changed */ -static void pre_accept(void) +static void pre_accept(char *unused_name, char **unused_argv) { if (dict_changed()) { msg_info("table has changed -- exiting"); @@ -687,7 +687,7 @@ static void pre_accept(void) /* drop_privileges - drop privileges most of the time */ -static void drop_privileges(void) +static void drop_privileges(char *unused_name, char **unused_argv) { set_eugid(var_owner_uid, var_owner_gid); } diff --git a/postfix/postalias/.indent.pro b/postfix/postalias/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/postalias/.indent.pro +++ b/postfix/postalias/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/postcat/.indent.pro b/postfix/postcat/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/postcat/.indent.pro +++ b/postfix/postcat/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/postconf/.indent.pro b/postfix/postconf/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/postconf/.indent.pro +++ b/postfix/postconf/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/postdrop/.indent.pro b/postfix/postdrop/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/postdrop/.indent.pro +++ b/postfix/postdrop/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/postfix/.indent.pro b/postfix/postfix/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/postfix/.indent.pro +++ b/postfix/postfix/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/postkick/.indent.pro b/postfix/postkick/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/postkick/.indent.pro +++ b/postfix/postkick/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/postlock/.indent.pro b/postfix/postlock/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/postlock/.indent.pro +++ b/postfix/postlock/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/postlog/.indent.pro b/postfix/postlog/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/postlog/.indent.pro +++ b/postfix/postlog/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/postmap/.indent.pro b/postfix/postmap/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/postmap/.indent.pro +++ b/postfix/postmap/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/postsuper/.indent.pro b/postfix/postsuper/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/postsuper/.indent.pro +++ b/postfix/postsuper/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/qmgr/.indent.pro b/postfix/qmgr/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/qmgr/.indent.pro +++ b/postfix/qmgr/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/qmgr/Makefile.in b/postfix/qmgr/Makefile.in index e6e138c52..1b9d18192 100644 --- a/postfix/qmgr/Makefile.in +++ b/postfix/qmgr/Makefile.in @@ -27,10 +27,10 @@ Makefile: Makefile.in test: $(TESTPROG) -update: ../bin/$(PROG) +update: ../libexec/$(PROG) -../bin/$(PROG): $(PROG) - cp $(PROG) ../bin +../libexec/$(PROG): $(PROG) + cp $(PROG) ../libexec printfck: $(OBJS) $(PROG) rm -rf printfck diff --git a/postfix/qmgr/qmgr.c b/postfix/qmgr/qmgr.c index 7ed726e43..7bfd25ff5 100644 --- a/postfix/qmgr/qmgr.c +++ b/postfix/qmgr/qmgr.c @@ -347,7 +347,7 @@ static void qmgr_trigger_event(char *buf, int len, /* qmgr_loop - queue manager main loop */ -static int qmgr_loop(void) +static int qmgr_loop(char *unused_name, char **unused_argv) { char *in_path = 0; char *df_path = 0; @@ -390,7 +390,7 @@ static int qmgr_loop(void) /* pre_accept - see if tables have changed */ -static void pre_accept(void) +static void pre_accept(char *unused_name, char **unused_argv) { if (dict_changed()) { msg_info("table has changed -- exiting"); @@ -400,7 +400,7 @@ static void pre_accept(void) /* qmgr_pre_init - pre-jail initialization */ -static void qmgr_pre_init(void) +static void qmgr_pre_init(char *unused_name, char **unused_argv) { if (*var_relocated_maps) qmgr_relocated = maps_create("relocated", var_relocated_maps, @@ -412,7 +412,7 @@ static void qmgr_pre_init(void) /* qmgr_post_init - post-jail initialization */ -static void qmgr_post_init(void) +static void qmgr_post_init(char *unused_name, char **unused_argv) { /* diff --git a/postfix/sendmail/.indent.pro b/postfix/sendmail/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/sendmail/.indent.pro +++ b/postfix/sendmail/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/showq/.indent.pro b/postfix/showq/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/showq/.indent.pro +++ b/postfix/showq/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/showq/Makefile.in b/postfix/showq/Makefile.in index 1d5bf10c3..da83116c4 100644 --- a/postfix/showq/Makefile.in +++ b/postfix/showq/Makefile.in @@ -23,10 +23,10 @@ Makefile: Makefile.in test: $(TESTPROG) -update: ../bin/$(PROG) +update: ../libexec/$(PROG) -../bin/$(PROG): $(PROG) - cp $(PROG) ../bin +../libexec/$(PROG): $(PROG) + cp $(PROG) ../libexec printfck: $(OBJS) $(PROG) rm -rf printfck diff --git a/postfix/smtp/.indent.pro b/postfix/smtp/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/smtp/.indent.pro +++ b/postfix/smtp/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/smtp/Makefile.in b/postfix/smtp/Makefile.in index ae9e7f14e..edff7061b 100644 --- a/postfix/smtp/Makefile.in +++ b/postfix/smtp/Makefile.in @@ -25,10 +25,10 @@ Makefile: Makefile.in test: $(TESTPROG) -update: ../bin/$(PROG) +update: ../libexec/$(PROG) -../bin/$(PROG): $(PROG) - cp $(PROG) ../bin +../libexec/$(PROG): $(PROG) + cp $(PROG) ../libexec printfck: $(OBJS) $(PROG) rm -rf printfck diff --git a/postfix/smtp/smtp.c b/postfix/smtp/smtp.c index 81c0188d8..2881bb99b 100644 --- a/postfix/smtp/smtp.c +++ b/postfix/smtp/smtp.c @@ -324,9 +324,16 @@ static void smtp_service(VSTREAM *client_stream, char *unused_service, char **ar } } +/* pre_init - pre-jail initialization */ + +static void pre_init(char *unused_name, char **unused_argv) +{ + debug_peer_init(); +} + /* pre_accept - see if tables have changed */ -static void pre_accept(void) +static void pre_accept(char *unused_name, char **unused_argv) { if (dict_changed()) { msg_info("table has changed -- exiting"); @@ -369,7 +376,7 @@ int main(int argc, char **argv) MAIL_SERVER_INT_TABLE, int_table, MAIL_SERVER_STR_TABLE, str_table, MAIL_SERVER_BOOL_TABLE, bool_table, - MAIL_SERVER_PRE_INIT, debug_peer_init, + MAIL_SERVER_PRE_INIT, pre_init, MAIL_SERVER_PRE_ACCEPT, pre_accept, 0); } diff --git a/postfix/smtpd/.indent.pro b/postfix/smtpd/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/smtpd/.indent.pro +++ b/postfix/smtpd/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/smtpd/Makefile.in b/postfix/smtpd/Makefile.in index b9cca844d..ff849ac27 100644 --- a/postfix/smtpd/Makefile.in +++ b/postfix/smtpd/Makefile.in @@ -23,10 +23,10 @@ Makefile: Makefile.in test: $(TESTPROG) -update: ../bin/$(PROG) +update: ../libexec/$(PROG) -../bin/$(PROG): $(PROG) - cp $(PROG) ../bin +../libexec/$(PROG): $(PROG) + cp $(PROG) ../libexec SMTPD_CHECK_OBJ = smtpd_state.o diff --git a/postfix/smtpd/smtpd.c b/postfix/smtpd/smtpd.c index b7328969d..1ec0f2759 100644 --- a/postfix/smtpd/smtpd.c +++ b/postfix/smtpd/smtpd.c @@ -1096,7 +1096,7 @@ static void smtpd_sig(int sig) /* pre_accept - see if tables have changed */ -static void pre_accept(void) +static void pre_accept(char *unused_name, char **unused_argv) { if (dict_changed()) { msg_info("lookup table has changed -- exiting"); @@ -1106,7 +1106,7 @@ static void pre_accept(void) /* post_jail_init - post-jail initialization */ -static void post_jail_init(void) +static void post_jail_init(char *unused_name, char **unused_argv) { /* @@ -1120,7 +1120,7 @@ static void post_jail_init(void) /* pre_jail_init - pre-jail initialization */ -static void pre_jail_init(void) +static void pre_jail_init(char *unused_name, char **unused_argv) { /* diff --git a/postfix/smtpstone/.indent.pro b/postfix/smtpstone/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/smtpstone/.indent.pro +++ b/postfix/smtpstone/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/trivial-rewrite/.indent.pro b/postfix/trivial-rewrite/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/trivial-rewrite/.indent.pro +++ b/postfix/trivial-rewrite/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/trivial-rewrite/Makefile.in b/postfix/trivial-rewrite/Makefile.in index e4036be06..3c4a26354 100644 --- a/postfix/trivial-rewrite/Makefile.in +++ b/postfix/trivial-rewrite/Makefile.in @@ -14,7 +14,7 @@ PROG = trivial-rewrite LIBS = ../lib/libmaster.a ../lib/libglobal.a ../lib/libutil.a LIB_DIR = ../lib INC_DIR = ../include -BIN_DIR = ../bin +BIN_DIR = ../libexec .c.o:; $(CC) $(CFLAGS) -c $*.c diff --git a/postfix/trivial-rewrite/trivial-rewrite.c b/postfix/trivial-rewrite/trivial-rewrite.c index 991cde5f4..a6a870f59 100644 --- a/postfix/trivial-rewrite/trivial-rewrite.c +++ b/postfix/trivial-rewrite/trivial-rewrite.c @@ -185,7 +185,7 @@ static void rewrite_service(VSTREAM *stream, char *unused_service, char **argv) /* pre_accept - see if tables have changed */ -static void pre_accept(void) +static void pre_accept(char *unused_name, char **unused_argv) { if (dict_changed()) { msg_info("table has changed -- exiting"); @@ -195,7 +195,7 @@ static void pre_accept(void) /* pre_jail_init - initialize before entering chroot jail */ -static void pre_jail_init(void) +static void pre_jail_init(char *unused_name, char **unused_argv) { command = vstring_alloc(100); rewrite_init(); diff --git a/postfix/util/.indent.pro b/postfix/util/.indent.pro index 88212c9ce..fc9774ba8 100644 --- a/postfix/util/.indent.pro +++ b/postfix/util/.indent.pro @@ -37,13 +37,13 @@ -TEXPAND_ATTR -TFILE -TFORWARD_INFO --TFW_CONTEXT -THEADER_OPTS -THTABLE -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE -TLOCAL_STATE +-TMAC_EXP_CONTEXT -TMAC_HEAD -TMAC_PARSE -TMAIL_PRINT diff --git a/postfix/util/Makefile.in b/postfix/util/Makefile.in index 8a75f3f50..95603e95a 100644 --- a/postfix/util/Makefile.in +++ b/postfix/util/Makefile.in @@ -19,7 +19,7 @@ SRCS = argv.c argv_split.c attr.c basename.c binhash.c chroot_uid.c \ unsafe.c username.c valid_hostname.c vbuf.c vbuf_print.c \ vstream.c vstream_popen.c vstring.c vstring_vstream.c writable.c \ write_buf.c write_wait.c dict_unix.c dict_pcre.c stream_listen.c \ - stream_connect.c stream_trigger.c dict_regexp.c watch_fd.c \ + stream_connect.c stream_trigger.c dict_regexp.c mac_expand.c \ clean_env.c OBJS = argv.o argv_split.o attr.o basename.o binhash.o chroot_uid.o \ close_on_exec.o concatenate.o dict.o dict_db.o dict_dbm.o \ @@ -41,7 +41,7 @@ OBJS = argv.o argv_split.o attr.o basename.o binhash.o chroot_uid.o \ unsafe.o username.o valid_hostname.o vbuf.o vbuf_print.o \ vstream.o vstream_popen.o vstring.o vstring_vstream.o writable.o \ write_buf.o write_wait.o dict_unix.o dict_pcre.o stream_listen.o \ - stream_connect.o stream_trigger.o dict_regexp.o watch_fd.o \ + stream_connect.o stream_trigger.o dict_regexp.o mac_expand.o \ clean_env.o HDRS = argv.h attr.h binhash.h chroot_uid.h connect.h dict.h dict_db.h \ dict_dbm.h dict_env.h dict_ht.h dict_ldap.h dict_ni.h dict_nis.h \ @@ -56,7 +56,7 @@ HDRS = argv.h attr.h binhash.h chroot_uid.h connect.h dict.h dict_db.h \ sigdelay.h split_at.h stat_as.h stringops.h sys_defs.h \ timed_connect.h timed_wait.h trigger.h username.h valid_hostname.h \ vbuf.h vbuf_print.h vstream.h vstring.h vstring_vstream.h \ - dict_unix.h dict_pcre.h dict_regexp.h watch_fd.h clean_env.h + dict_unix.h dict_pcre.h dict_regexp.h mac_expand.h clean_env.h TESTSRC = fifo_open.c fifo_rdwr_bug.c fifo_rdonly_bug.c select_bug.c \ stream_test.c WARN = -W -Wformat -Wimplicit -Wmissing-prototypes \ @@ -71,7 +71,7 @@ TESTPROG= dict_open events exec_command fifo_open fifo_rdonly_bug \ fifo_rdwr_bug fifo_trigger fsspace fullname inet_addr_host \ inet_addr_local mac_parse make_dirs msg_syslog \ mystrtok peer_name sigdelay translit valid_hostname vstream_popen \ - vstring vstring_vstream doze select_bug stream_test + vstring vstring_vstream doze select_bug stream_test mac_expand LIB_DIR = ../lib INC_DIR = ../include @@ -232,6 +232,11 @@ doze: $(LIB) $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS) mv junk $@.o +mac_expand: $(LIB) + mv $@.o junk + $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS) + mv junk $@.o + depend: $(MAKES) (sed '1,/^# do not edit/!d' Makefile.in; \ set -e; for i in [a-z][a-z0-9]*.c; do \ @@ -243,13 +248,18 @@ depend: $(MAKES) stream_test: stream_test.c $(LIB) $(CC) $(CFLAGS) -o $@ $@.c $(LIB) $(SYSLIBS) -tests: valid_hostname_test +tests: valid_hostname_test mac_expand_test valid_hostname_test: valid_hostname valid_hostname.in valid_hostname.ref ./valid_hostname valid_hostname.tmp diff valid_hostname.ref valid_hostname.tmp rm -f valid_hostname.tmp +mac_expand_test: mac_expand mac_expand.in mac_expand.ref + ./mac_expand mac_expand.tmp + diff mac_expand.ref mac_expand.tmp + rm -f mac_expand.tmp + # do not edit below this line - it is generated by 'make depend' argv.o: argv.c argv.o: mymalloc.h @@ -528,6 +538,15 @@ lstat_as.o: sys_defs.h lstat_as.o: msg.h lstat_as.o: set_eugid.h lstat_as.o: lstat_as.h +mac_expand.o: mac_expand.c +mac_expand.o: sys_defs.h +mac_expand.o: msg.h +mac_expand.o: vstring.h +mac_expand.o: vbuf.h +mac_expand.o: mymalloc.h +mac_expand.o: htable.h +mac_expand.o: mac_parse.h +mac_expand.o: mac_expand.h mac_parse.o: mac_parse.c mac_parse.o: sys_defs.h mac_parse.o: msg.h @@ -828,12 +847,6 @@ vstring_vstream.o: vstring.h vstring_vstream.o: vbuf.h vstring_vstream.o: vstream.h vstring_vstream.o: vstring_vstream.h -watch_fd.o: watch_fd.c -watch_fd.o: sys_defs.h -watch_fd.o: msg.h -watch_fd.o: binhash.h -watch_fd.o: mymalloc.h -watch_fd.o: watch_fd.h writable.o: writable.c writable.o: sys_defs.h writable.o: msg.h diff --git a/postfix/util/dict_dbm.c b/postfix/util/dict_dbm.c index 78a73c0c2..eff168a8b 100644 --- a/postfix/util/dict_dbm.c +++ b/postfix/util/dict_dbm.c @@ -210,7 +210,7 @@ DICT *dict_dbm_open(const char *path, int open_flags, int dict_flags) dict_dbm->dict.lookup = dict_dbm_lookup; dict_dbm->dict.update = dict_dbm_update; dict_dbm->dict.close = dict_dbm_close; - dict_dbm->dict.fd = dbm_dirfno(dbm); + dict_dbm->dict.fd = dbm_pagfno(dbm); if (fstat(dict_dbm->dict.fd, &st) < 0) msg_fatal("dict_dbm_open: fstat: %m"); dict_dbm->dict.mtime = st.st_mtime; diff --git a/postfix/util/mac_expand.c b/postfix/util/mac_expand.c new file mode 100644 index 000000000..8c5da1b87 --- /dev/null +++ b/postfix/util/mac_expand.c @@ -0,0 +1,351 @@ +/*++ +/* NAME +/* mac_expand 3 +/* SUMMARY +/* attribute expansion +/* SYNOPSIS +/* #include +/* +/* int mac_expand(result, pattern, flags, key, ...) +/* VSTRING *result; +/* const char *pattern; +/* int flags; +/* int key; +/* DESCRIPTION +/* mac_expand() expands $name instances in \fBpattern\fR +/* and stores the result into \fBresult\fR. +/* +/* The following expansions are done: +/* .IP "$name, ${name}, $(name)" +/* The result is the value of the named parameter. Optionally, the +/* result is subjected to further expansions. +/* .IP "${name?text}, $(name?text)" +/* If the named parameter is defined, the result is the given text, +/* after another iteration of $name expansion. Otherwise, the result is +/* empty. +/* .IP "${name:text}, $(name:text)" +/* If the named parameter is undefined, the result is the given text, +/* after another iteration of $name expansion. Otherwise, the result is +/* empty. +/* .PP +/* Arguments: +/* .IP result +/* Storage for the result of expansion. The result is not truncated +/* upon entry. +/* .IP pattern +/* The string to be expanded. +/* .IP flags +/* Bit-wise OR of zero or more of the following: +/* .RS +/* .IP MAC_EXP_FLAG_RECURSE +/* Expand $name recursively. +/* .RE +/* The constant MAC_EXP_FLAG_NONE specifies a manifest null value. +/* .IP key +/* The attribute information is specified as a null-terminated list. +/* Attributes are defined left to right; only the last definition +/* of an attribute is remembered. +/* The following keys are understood (types of arguments indicated +/* in parentheses): +/* .RS +/* .IP "MAC_EXP_ARG_ATTR (char *, char *)" +/* The next two arguments specify an attribute name and its attribute +/* string value. Specify a null string value for an attribute that is +/* known but unset. +/* .IP "MAC_EXP_ARG_TABLE (HTABLE *)" +/* The next argument is a hash table with attribute names and values. +/* Specify a null string value for an attribute that is known but unset. +/* .IP "MAC_EXP_ARG_FILTER (char *)" +/* The next argument specifies a null-terminated list of characters +/* that are allowed to appear in $name expansions. By default, illegal +/* characters are replaced by underscore. Only the last specified +/* filter takes effect. +/* .IP "MAC_EXP_ARG_CLOBBER (int)" +/* Character value to be used when the result of expansion is not +/* allowed according to the MAC_EXP_ARG_FILTER argument. Only the +/* last specified replacement value takes effect. +/* .RE +/* .IP MAC_EXP_ARG_END +/* A manifest constant that indicates the end of the argument list. +/* DIAGNOSTICS +/* Fatal errors: out of memory. Warnings: syntax errors, unreasonable +/* macro nesting. +/* +/* The result value is the binary OR of zero or more of the following: +/* .IP MAC_EXP_FLAG_UNDEF +/* The pattern contains a reference to an unknown parameter or to +/* a parameter whose value is not defined. +/* A zero-length string was used as replacement. +/* SEE ALSO +/* mac_parse(3) locate macro references in string. +/* 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 +#include +#include +#include +#include + + /* + * Little helper structure. + */ +typedef struct { + HTABLE *table; /* private symbol table */ + VSTRING *result; /* result buffer */ + const char *filter; /* safe character list */ + int clobber; /* safe replacement */ + int flags; /* findings, features */ + int level; /* nesting level */ + jmp_buf jbuf; /* escape */ +} MAC_EXP_CONTEXT; + +/* mac_expand_callback - callback for mac_parse */ + +static void mac_expand_callback(int type, VSTRING *buf, char *ptr) +{ + char *myname = "mac_expand_callback"; + MAC_EXP_CONTEXT *context = (MAC_EXP_CONTEXT *) ptr; + HTABLE_INFO *ht; + char *text; + char *cp; + int ch; + + if (context->level++ > 100) { + msg_warn("unreasonable macro call nesting: \"%s\"", vstring_str(buf)); + longjmp(context->jbuf, 1); + } + + /* + * $Name reference. + */ + if (type == MAC_PARSE_VARNAME) { + + /* + * Look for the ? or : delimiter. In case of a syntax error, return + * without doing damage. We do not have enough context to produce an + * understandable error message, so don't try. + */ + for (cp = vstring_str(buf); (ch = *cp) != 0; cp++) { + if (ch == '?' || ch == ':') { + *cp++ = 0; + break; + } + if (!ISALNUM(ch) && ch != '_') { + msg_warn("macro name syntax error: \"%s\"", vstring_str(buf)); + longjmp(context->jbuf, 1); + } + } + + /* + * Look up the named parameter. + */ + text = (ht = htable_locate(context->table, vstring_str(buf))) == 0 ? + 0 : ht->value; + + /* + * Perform the requested substitution. + */ + switch (ch) { + case '?': + if (text != 0) + mac_parse(cp, mac_expand_callback, (char *) context); + break; + case ':': + if (text == 0) + mac_parse(cp, mac_expand_callback, (char *) context); + break; + default: + if (text == 0) { + context->flags |= MAC_EXP_FLAG_UNDEF; + break; + } + if (context->filter) { + vstring_strcpy(buf, text); + text = vstring_str(buf); + for (cp = text; (cp += strspn(cp, context->filter))[0];) + *cp++ = context->clobber; + } + if (context->flags & MAC_EXP_FLAG_RECURSE) + mac_parse(text, mac_expand_callback, (char *) context); + else + vstring_strcat(context->result, text); + break; + } + } + + /* + * Literal text. + */ + else { + text = vstring_str(buf); + vstring_strcat(context->result, text); + } + + /* + * Give the poor tester a clue of what is going on. + */ + if (msg_verbose) + msg_info("%s: %s = %s", myname, vstring_str(buf), + text ? text : "(undef)"); + + context->level--; +} + +/* mac_expand - expand $name instances */ + +int mac_expand(VSTRING *result, const char *pattern, int flags, int key,...) +{ + MAC_EXP_CONTEXT context; + va_list ap; + HTABLE_INFO **ht_info; + HTABLE_INFO **ht; + HTABLE *table; + char *name; + char *value; + +#define HTABLE_CLOBBER(t, n, v) do { \ + HTABLE_INFO *_ht; \ + if ((_ht = htable_locate(t, n)) != 0) \ + _ht->value = v; \ + else \ + htable_enter(t, n, v); \ + } while(0); + + /* + * Inititalize. + */ + context.table = htable_create(0); + context.result = result; + context.flags = flags; + context.filter = 0; + context.clobber = '_'; + context.level = 0; + + /* + * Stash away the attributes. + */ + for (va_start(ap, key); key != 0; key = va_arg(ap, int)) { + switch (key) { + case MAC_EXP_ARG_ATTR: + name = va_arg(ap, char *); + value = va_arg(ap, char *); + HTABLE_CLOBBER(context.table, name, value); + break; + case MAC_EXP_ARG_TABLE: + table = va_arg(ap, HTABLE *); + ht_info = htable_list(table); + for (ht = ht_info; *ht; ht++) + HTABLE_CLOBBER(context.table, ht[0]->key, ht[0]->value); + myfree((char *) ht_info); + break; + case MAC_EXP_ARG_FILTER: + context.filter = va_arg(ap, char *); + break; + case MAC_EXP_ARG_CLOBBER: + context.clobber = va_arg(ap, int); + break; + } + } + va_end(ap); + + /* + * Do the substitutions. + */ + if (setjmp(context.jbuf) == 0) + mac_parse(pattern, mac_expand_callback, (char *) &context); + VSTRING_TERMINATE(result); + + /* + * Clean up. + */ + htable_free(context.table, (void (*) (char *)) 0); + return (context.flags & MAC_EXP_FLAG_UNDEF); +} + +#ifdef TEST + + /* + * This code certainly deserves a stand-alone test program. + */ +#include +#include +#include + +static void nfree(char *ptr) +{ + if (ptr) + myfree(ptr); +} + +int main(int unused_argc, char **unused_argv) +{ + VSTRING *buf = vstring_alloc(100); + VSTRING *result = vstring_alloc(100); + char *cp; + char *name; + char *value; + HTABLE *table; + int stat; + + while (!vstream_feof(VSTREAM_IN)) { + + table = htable_create(0); + + /* + * Read a block of definitions, terminated with an empty line. + */ + while (vstring_get_nonl(buf, VSTREAM_IN) != VSTREAM_EOF) { + if (VSTRING_LEN(buf) == 0) + break; + cp = vstring_str(buf); + name = mystrtok(&cp, " \t\r\n="); + value = mystrtok(&cp, " \t\r\n="); + htable_enter(table, name, value ? mystrdup(value) : 0); + } + + /* + * Read a block of patterns, terminated with an empty line or EOF. + */ + while (vstring_get_nonl(buf, VSTREAM_IN) != VSTREAM_EOF) { + if (VSTRING_LEN(buf) == 0) + break; + cp = vstring_str(buf); + VSTRING_RESET(result); + stat = mac_expand(result, vstring_str(buf), MAC_EXP_FLAG_NONE, + MAC_EXP_ARG_TABLE, table, + MAC_EXP_ARG_END); + vstream_printf("stat=%d result=%s\n", stat, vstring_str(result)); + vstream_fflush(VSTREAM_OUT); + } + htable_free(table, nfree); + vstream_printf("\n"); + } + + /* + * Clean up. + */ + vstring_free(buf); + vstring_free(result); + exit(0); +} + +#endif diff --git a/postfix/util/mac_expand.h b/postfix/util/mac_expand.h new file mode 100644 index 000000000..e6a47a1cd --- /dev/null +++ b/postfix/util/mac_expand.h @@ -0,0 +1,45 @@ +#ifndef _MAC_EXPAND_H_INCLUDED_ +#define _MAC_EXPAND_H_INCLUDED_ + +/*++ +/* NAME +/* mac_expand 3h +/* SUMMARY +/* expand macro references in string +/* SYNOPSIS +/* #include + DESCRIPTION + .nf + + /* + * Utility library. + */ +#include + + /* + * External interface. + */ +#define MAC_EXP_FLAG_NONE (0) +#define MAC_EXP_FLAG_UNDEF (1<<0) +#define MAC_EXP_FLAG_RECURSE (1<<1) + +#define MAC_EXP_ARG_END 0 +#define MAC_EXP_ARG_ATTR 1 +#define MAC_EXP_ARG_TABLE 2 +#define MAC_EXP_ARG_FILTER 3 +#define MAC_EXP_ARG_CLOBBER 4 + +extern int mac_expand(VSTRING *, const char *, int, int,...); + +/* 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 +/*--*/ + +#endif diff --git a/postfix/util/mac_expand.in b/postfix/util/mac_expand.in new file mode 100644 index 000000000..f92ad2c89 --- /dev/null +++ b/postfix/util/mac_expand.in @@ -0,0 +1,18 @@ +name1 = name1-value +name2 = + +${name1?name 1 defined, |$name1|$name2|} +${name1:name 1 undefined, |$name1|$name2|} +${name2?name 2 defined, |$name1|$name2|} +${name2:name 2 undefined, |$name1|$name2|} +|$name1|$name2| +$(name1 +$(name ) + +name2 = name2-value + +${name1?name 1 defined, |$name1|$name2|} +${name1:name 1 undefined, |$name1|$name2|} +${name2?name 2 defined, |$name1|$name2|} +${name2:name 2 undefined, |$name1|$name2|} +|$name1|$name2| diff --git a/postfix/util/mac_expand.ref b/postfix/util/mac_expand.ref new file mode 100644 index 000000000..7fb290928 --- /dev/null +++ b/postfix/util/mac_expand.ref @@ -0,0 +1,13 @@ +stat=1 result=name 1 defined, |name1-value|| +stat=0 result= +stat=0 result= +stat=1 result=name 2 undefined, |name1-value|| +stat=1 result=|name1-value|| +stat=0 result=name1-value +stat=0 result= + +stat=0 result= +stat=1 result=name 1 undefined, ||name2-value| +stat=1 result=name 2 defined, ||name2-value| +stat=0 result= +stat=1 result=||name2-value| diff --git a/postfix/util/mac_parse.c b/postfix/util/mac_parse.c index e863a2328..30bee99cb 100644 --- a/postfix/util/mac_parse.c +++ b/postfix/util/mac_parse.c @@ -28,7 +28,7 @@ /* SEE ALSO /* dict(3) dictionary interface. /* DIAGNOSTICS -/* Fatal errors: out of memory, malformed macro name. +/* Fatal errors: out of memory. malformed macro name. /* LICENSE /* .ad /* .fi @@ -96,14 +96,16 @@ void mac_parse(const char *value, MAC_PARSE_FN action, char *context) level = 1; vp += 1; for (ep = vp; level > 0; ep++) { - if (*ep == 0) - msg_fatal("incomplete macro: %s", value); + if (*ep == 0) { + msg_warn("truncated macro reference: \"%s\"", value); + break; + } if (*ep == *pp) level++; if (*ep == close_paren[pp - open_paren]) level--; } - vstring_strncat(buf, vp, ep - vp - 1); + vstring_strncat(buf, vp, level > 0 ? ep - vp : ep - vp - 1); vp = ep; } else { /* plain $x */ SKIP(vp, ep, ISALNUM(*ep) || *ep == '_'); @@ -111,7 +113,7 @@ void mac_parse(const char *value, MAC_PARSE_FN action, char *context) vp = ep; } if (VSTRING_LEN(buf) == 0) - msg_fatal("empty macro name: %s", value); + msg_warn("empty macro name: \"%s\"", value); MAC_PARSE_ACTION(MAC_PARSE_VARNAME, buf, context); } } diff --git a/postfix/util/watch_fd.c b/postfix/util/watch_fd.c deleted file mode 100644 index 76dda7225..000000000 --- a/postfix/util/watch_fd.c +++ /dev/null @@ -1,114 +0,0 @@ -/*++ -/* NAME -/* watch_fd 3 -/* SUMMARY -/* monitor file descriptors for change -/* SYNOPSIS -/* #include -/* -/* void watch_fd_register(fd) -/* int fd; -/* -/* void watch_fd_remove(fd) -/* int fd; -/* -/* int watch_fd_changed() -/* DESCRIPTION -/* This module monitors file modification times of arbitrary file -/* descriptors. -/* -/* watch_fd_register() records information about the specified -/* file descriptor. -/* -/* watch_fd_remove() releases storage allocated by watch_fd_register(). -/* -/* watch_fd_changed() returns non-zero if any of the registered -/* SEE ALSO -/* msg(3) diagnostics interface -/* DIAGNOSTICS -/* Problems are reported via the msg(3) diagnostics routines: -/* the requested amount of memory is not available; improper use -/* is detected; other fatal errors. -/* 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 - -/* Utility library. */ - -#include -#include -#include -#include - -/* Application-specific. */ - -typedef struct { - int fd; /* file descriptor */ - time_t mtime; /* initial modification time */ -} WATCH_FD; - -static BINHASH *watch_fd_table; - -/* watch_fd_register - register file descriptor */ - -void watch_fd_register(int fd) -{ - char *myname = "watch_fd_enter"; - WATCH_FD *info; - struct stat st; - - if (fstat(fd, &st) < 0) - msg_fatal("%s: fstat: %m", myname); - - info = (WATCH_FD *) mymalloc(sizeof(*info)); - info->fd = fd; - info->mtime = st.st_mtime; - - if (watch_fd_table == 0) - watch_fd_table = binhash_create(0); - if (binhash_find(watch_fd_table, (char *) &fd, sizeof(fd))) - msg_panic("%s: entry %d exists", myname, fd); - binhash_enter(watch_fd_table, (char *) &fd, sizeof(fd), (char *) info); -} - -/* watch_fd_remove - remove file descriptor */ - -void watch_fd_remove(int fd) -{ - binhash_delete(watch_fd_table, (char *) &fd, sizeof(fd), myfree); -} - -/* watch_fd_changed - see if any file has changed */ - -int watch_fd_changed(void) -{ - char *myname = "watch_fd_changed"; - struct stat st; - BINHASH_INFO **ht_info_list; - BINHASH_INFO **ht; - BINHASH_INFO *h; - WATCH_FD *info; - int status; - - ht_info_list = binhash_list(watch_fd_table); - for (status = 0, ht = ht_info_list; status == 0 && (h = *ht) != 0; ht++) { - info = (WATCH_FD *) h->value; - if (fstat(info->fd, &st) < 0) - msg_fatal("%s: fstat: %m", myname); - status = (st.st_mtime != info->mtime); - } - myfree((char *) ht_info_list); - return (status); -} diff --git a/postfix/util/watch_fd.h b/postfix/util/watch_fd.h deleted file mode 100644 index ef02ccd02..000000000 --- a/postfix/util/watch_fd.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _WATCH_FD_H_INCLUDED_ -#define _WATCH_FD_H_INCLUDED_ - -/*++ -/* NAME -/* watch_fd 3h -/* SUMMARY -/* monitor file descriptors for change -/* SYNOPSIS -/* #include "watch_fd.h" - DESCRIPTION - .nf - - /* - * External interface. - */ -extern void watch_fd_register(int); -extern void watch_fd_remove(int); -extern int watch_fd_changed(void); - -/* 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 -/*--*/ - -#endif