diff --git a/postfix/HISTORY b/postfix/HISTORY index 7e0bd641d..0bbafeadb 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -5944,6 +5944,11 @@ Apologies for any names omitted. non-blocking pipe. File: master/master_flow.c. Report: Hamish Marson. +20020111 + + Feedback: feedback, bugfixes, and brain-dead shell workarounds + for the install scripts by Victor Duchovny and Simon Mudd. + Open problems: Low: don't do user@domain and @domain lookups in diff --git a/postfix/RELEASE_NOTES b/postfix/RELEASE_NOTES index a99f392cb..cdfc8924d 100644 --- a/postfix/RELEASE_NOTES +++ b/postfix/RELEASE_NOTES @@ -1,3 +1,17 @@ +Incompatible changes with snapshot-20020111 +=========================================== + +Another revision of installation procedures. The command line +interface of the post-install script has changed; see embedded +documentation. The postfix-files file with information about +Postfix files and directories now contains $name variables rather +than directory names, user names and group names. You can now change +parameters such as mail_owner and setgid_group after installing +Postfix, and apply the correct file/directory ownerships and +permissions by executing the post-install script as: + + post-install set-permissions config_directory=/etc/postfix + Incompatible changes with snapshot-20020110 =========================================== @@ -5,10 +19,10 @@ The INSTALL.sh installation procedure is replaced by a postfix-install script that either installs Postfix on the local system (as root) or that builds a package (as non-root) for distribution to other systems. This script creates a file $config_directory/postfix-files -with ownership and permissions of Postfix files/directories. The -$config_directory/post-install script applies the finishing touch: -it sets file/directory ownership and permissions, edits existing -configuration files, and creates missing queue directories. +with ownership and permissions of Postfix files/directories. A +new $config_directory/post-install script applies the finishing +touch: it sets file/directory ownership and permissions, edits +existing configuration files, and creates missing queue directories. Incompatible changes with snapshot-20020106 =========================================== diff --git a/postfix/conf/post-install b/postfix/conf/post-install index e639dcede..72cf1b953 100644 --- a/postfix/conf/post-install +++ b/postfix/conf/post-install @@ -9,7 +9,7 @@ # SUMMARY # Postfix post-installation script # SYNOPSIS -# post-install [options] config_directory +# post-install [name=value] command ... # DESCRIPTION # The post-install script performs the finishing touch of a Postfix # installation, after the executable programs and configuration @@ -27,47 +27,51 @@ # create missing queue directories. # .PP # Arguments -# .IP -create +# .IP create-missing # Create missing queue directories with ownerships and permissions # according to the contents of $config_directory/postfix-files. # # This is required at Postfix start-up time. -# .IP -set-permissions +# .IP set-permissions # Set all file/directory ownerships and permissions according to the -# contents of $config_directory/postfix-files. Implies -create. +# contents of $config_directory/postfix-files. Implies create-missing. # # This is required when installing Postfix from a pre-built package. -# .IP -upgrade-permissions +# .IP upgrade-permissions # Update ownership and permission of selected files/directories as -# specified in $config_directory/postfix-files. Implies -create. +# specified in $config_directory/postfix-files. Implies create-missing. # # This is required when installing Postfix from source code, while # Postfix was already installed on the machine. -# .IP -upgrade-configuration +# .IP upgrade-configuration # Edit the installed main.cf and master.cf files, in order to account # for missing services and to fix deprecated parameter settings. # # This is required when Postfix was already installed on the machine. -# .IP -upgrade-source -# Short-hand for -upgrade-permissions -upgrade-configuration. +# .IP upgrade-source +# Short-hand for upgrade-permissions upgrade-configuration. # # This is recommended when upgrading Postfix from source code. -# .IP -upgrade-package -# Short-hand for -set-permissions -upgrade-configuration. +# .IP upgrade-package +# Short-hand for set-permissions upgrade-configuration. # # This is recommended when upgrading Postfix from a pre-built package. -# .IP -first-install-reminder +# .IP first-install-reminder # Remind the user that they still need to configure main.cf and the # aliases file, and that newaliases needs to be run. # # This is recommended when Postfix is installed for the first time. -# .IP config_directory -# Directory with Postfix configuration files. This must be an absolute -# pathname. +# .IP config_directory=pathname +# Absolute pathname of the directory with Postfix configuration files. +# This information must be specified if it is not given via the +# process environment. +# .IP command_directory=pathname +# Absolute pathname of the directory with the postconf command. +# This information must be specified if it is not given via the +# process environment, and if the directory is not a standard +# system directory. # SEE ALSO -# postfix-install(1) Postfix primary installation script for installation -# from source code, or for building a package for distribution to other -# systems. +# postfix-install(1) Postfix primary installation script. # FILES # $config_directory/main.cf, Postfix installation configuration. # $config_directory/postfix-files, permissions and ownerships. @@ -87,32 +91,36 @@ umask 022 PATH=/bin:/usr/bin:/usr/sbin:/usr/etc:/sbin:/etc:/usr/contrib/bin:/usr/gnu/bin:/usr/ucb:/usr/bsd SHELL=/bin/sh +IFS=" +" -USAGE="usage: $0 [options] config_directory +USAGE="Usage: $0 [name=value] command + create-missing Create missing queue directories. + upgrade-source Use when upgrading from source. + upgrade-package Use when upgrading from pre-built package. + first-install-reminder Remind of mandatory configuration steps. + config_directory=path Specify an absolute path name. + command_directory=path Specify an absolute path name." - -upgrade-source Use when upgrading from source. +# Process command-line options and parameter settings. Work around +# brain damaged shells. "name=value command" should not make the +# name=value setting permanent. - -upgrade-package Use when upgrading from pre-built package. - - -first-install-reminder Remind of mandatory configuration steps. - - config_directory Must be an absolute path name." - -# Process command-line settings +create=; set_perms=; upgrade_perms=; upgrade_conf=; first_install_reminder= for arg do case $arg in - -create) create=1;; - -set-perm*) create=1; set_perms=1;; - -upgrade-perm*) create=1; upgrade_perms=1;; - -upgrade-conf*) upgrade_conf=1;; - -upgrade-source) create=1; upgrade_conf=1; upgrade_perms=1;; - -upgrade-package) create=1; upgrade_conf=1; set_perms=1;; - -first-install*) first_install_reminder=1;; - /*) config_dir=$1;; - "") break;; - *) echo "Error: $USAGE" 1>&2; exit 1;; + *=*) SAVED_IFS="$IFS"; IFS= eval $arg; IFS="$SAVED_IFS";; + create-missing) create=1;; + set-perm*) create=1; set_perms=1;; + upgrade-perm*) create=1; upgrade_perms=1;; + upgrade-conf*) upgrade_conf=1;; + upgrade-source) create=1; upgrade_conf=1; upgrade_perms=1;; + upgrade-package) create=1; upgrade_conf=1; set_perms=1;; + first-install*) first_install_reminder=1;; + "") break;; + *) echo "Error: $USAGE" 1>&2; exit 1;; esac shift done @@ -124,18 +132,19 @@ test -n "$create$upgrade_conf$first_install_reminder" || { exit 1 } -test -n "$config_dir" || { - echo "Error: $USAGE" 1>&2 +test -n "$config_directory" || { + echo "Error: no config_directory parameter setting." 1>&2 + echo "$USAGE" 1>&2 exit 1 } -test -d "$config_dir" || { - echo Error: $config_dir is not a directory. 1>&2 +test -d "$config_directory" || { + echo Error: $config_directory is not a directory. 1>&2 exit 1 } -test -f $config_dir/postfix-files || { - Error: $config_dir/postfix-files is not a file. 1>&2 +test -f $config_directory/postfix-files || { + Error: $config_directory/postfix-files is not a file. 1>&2 exit 1 } @@ -150,37 +159,63 @@ else CHATTR=echo fi -# Use file/directory status information in $config_dir/postfix-files. +# Bootstrapping problem. + +if [ -n "$command_directory" ] +then + POSTCONF="$command_directory/postconf" +else + POSTCONF="postconf" +fi + +# Settings from main.cf must override command line or environment settings. + +for name in daemon_directory command_directory queue_directory mail_owner \ + setgid_group sendmail_path newaliases_path mailq_path manpage_path +do + eval $name=\`$POSTCONF -c $config_directory -h $name\` || kill $$ +done + +POSTCONF="$command_directory/postconf" + +# Use file/directory status information in $config_directory/postfix-files. test -n "$create" && { - IFS=: - while read path type owner group mode upgrade_flag create_flag junk + while IFS=: read path type owner group mode upgrade_flag create_flag junk do set_permission= case $path in - /*) # Create missing directories with proper owner/group/mode settings. - if [ -n "$create" -a "$type" = "d" -a -n "$create_flag" -a ! -d "$path" ] - then - mkdir $path || exit 1 - $CHATTR $path >/dev/null 2>/dev/null - set_permission=1 - # Update all owner/group/mode settings. - elif [ -n "$set_perms" ] - then - set_permission=1 - # Update obsolete owner/group/mode settings. - elif [ -n "$upgrade_perms" -a -n "$upgrade_flag" ] - then - set_permission=1 - fi - test -n "$set_permission" && { - chown $owner $path || exit 1 - test -z "$group" || chgrp $group $path || exit 1 - chmod $mode $path || exit 1 - } - ;; + [$]*) eval path=$path;; + /*) ;; + *) continue;; esac - done <$config_dir/postfix-files + case $owner in + [$]*) eval owner=$owner;; + esac + case $group in + [$]*) eval group=$group;; + esac + # Create missing directories with proper owner/group/mode settings. + if [ -n "$create" -a "$type" = "d" -a -n "$create_flag" -a ! -d "$path" ] + then + mkdir $path || exit 1 + $CHATTR $path >/dev/null 2>/dev/null + set_permission=1 + # Update all owner/group/mode settings. + elif [ -n "$set_perms" ] + then + set_permission=1 + # Update obsolete owner/group/mode settings. + elif [ -n "$upgrade_perms" -a -n "$upgrade_flag" ] + then + set_permission=1 + fi + test -n "$set_permission" && { + chown $owner $path || exit 1 + test -z "$group" || chgrp $group $path || exit 1 + chmod $mode $path || exit 1 + } + done <$config_directory/postfix-files } # Upgrade existing Postfix configuration files if necessary. @@ -189,9 +224,9 @@ test -n "$upgrade_conf" && { # Add missing flush service to master.cf. - grep 'flush.*flush' $config_dir/master.cf >/dev/null || { - echo Editing $config_dir/master.cf, adding missing entry for flush service - cat >>$config_dir/master.cf </dev/null || { + echo Editing $config_directory/master.cf, adding missing entry for flush service + cat >>$config_directory/master.cf </dev/null && { - echo Editing $config_dir/master.cf, making the pickup service unprivileged - ed $config_dir/master.cf </dev/null && { + echo Editing $config_directory/master.cf, making the pickup service unprivileged + ed $config_directory/master.cf </dev/null && { - echo Editing $config_dir/master.cf, making the $name service public - ed $config_dir/master.cf </dev/null && { + echo Editing $config_directory/master.cf, making the $name service public + ed $config_directory/master.cf </dev/null) || missing="$missing active" (echo "$found" | grep bounce >/dev/null) || missing="$missing bounce" @@ -246,7 +281,7 @@ EOF (echo "$found" | grep deferred>/dev/null)|| missing="$missing deferred" test -n "$missing" && { echo fixing main.cf hash_queue_names for missing $missing - bin/postconf -c $config_dir -e hash_queue_names="$found$missing" + $POSTCONF -c $config_directory -e hash_queue_names="$found$missing" } } @@ -255,12 +290,12 @@ EOF test -n "$first_install_reminder" && { - ALIASES=`postconf -h alias_database | sed 's/^[^:]*://'` - NEWALIASES_PATH=`postconf -h newaliases_path` + ALIASES=`$POSTCONF -h alias_database | sed 's/^[^:]*://'` + NEWALIASES_PATH=`$POSTCONF -h newaliases_path` cat <&2 Warning: you still need to edit myorigin/mydestination/mynetworks - parameter settings in $config_dir/main.cf. + parameter settings in $config_directory/main.cf. See also http://www.postfix.org/faq.html for information about dialup sites or about sites inside a firewalled network. diff --git a/postfix/conf/postfix-script b/postfix/conf/postfix-script index fe669cf03..9b53a4d62 100644 --- a/postfix/conf/postfix-script +++ b/postfix/conf/postfix-script @@ -164,7 +164,7 @@ check) \( -perm -020 -o -perm -002 \) -type f \ -exec $WARN group or other writable: {} \; - $SHELL $config_directory/post-install -create $config_directory || { + $SHELL $config_directory/post-install create-missing || { $WARN unable to create missing queue directories exit 1 } diff --git a/postfix/postfix-install b/postfix/postfix-install index acb1d38b0..a1663237b 100644 --- a/postfix/postfix-install +++ b/postfix/postfix-install @@ -142,13 +142,17 @@ umask 022 PATH=/bin:/usr/bin:/usr/sbin:/usr/etc:/sbin:/etc:/usr/contrib/bin:/usr/gnu/bin:/usr/ucb:/usr/bsd SHELL=/bin/sh +IFS=" +" -# Process command-line options and parameter settings. +# Process command-line options and parameter settings. Work around +# brain damaged shells. "name=value command" should not make the +# name=value setting permanent. for arg do case $arg in - *=*) IFS= eval $arg;; + *=*) SAVED_IFS="$IFS"; IFS= eval $arg; IFS="$SAVED_IFS";; -non-interactive) non_interactive=1;; *) echo Error: usage: $0 [-non-interactive] name=value ... 1>&2 exit 1;; @@ -509,26 +513,26 @@ cat <$CONFIG_DIRECTORY/postfix-files || exit 1 # update=update owner/group/mode (upgrade mode). # create=create missing directory. # -$config_directory:d:root::755:u -$daemon_directory:d:root::755:u -$queue_directory:d:root::755:u +\$config_directory:d:root::755:u +\$daemon_directory:d:root::755:u +\$queue_directory:d:root::755:u:c EOF # Generate instructions only for queue subdirectories. for dir in active bounce corrupt defer deferred flush incoming private saved do - echo $queue_directory/$dir:d:$mail_owner::700:u:c \ + echo \$queue_directory/$dir:d:\$mail_owner::700:u:c \ >>$CONFIG_DIRECTORY/postfix-files || exit 1 done -echo $queue_directory/maildrop:d:$mail_owner:$setgid_group:730:u:c \ +echo \$queue_directory/maildrop:d:\$mail_owner:\$setgid_group:730:u:c \ >>$CONFIG_DIRECTORY/postfix-files || exit 1 -echo $queue_directory/public:d:$mail_owner:$setgid_group:710:u:c \ +echo \$queue_directory/public:d:\$mail_owner:\$setgid_group:710:u:c \ >>$CONFIG_DIRECTORY/postfix-files || exit 1 -echo $queue_directory/pid:d:root::755:u:c \ +echo \$queue_directory/pid:d:root::755:u:c \ >>$CONFIG_DIRECTORY/postfix-files || exit 1 # Install daemon programs. @@ -536,7 +540,7 @@ echo $queue_directory/pid:d:root::755:u:c \ for file in `censored_ls libexec` do compare_or_replace $EXE libexec/$file $DAEMON_DIRECTORY/$file || exit 1 - echo $daemon_directory/$file:f:root::755 \ + echo \$daemon_directory/$file:f:root::755 \ >>$CONFIG_DIRECTORY/postfix-files || exit 1 done @@ -545,7 +549,7 @@ done for file in `censored_ls bin | grep '^post' | egrep -v '^post(drop|queue)$'` do compare_or_replace $EXE bin/$file $COMMAND_DIRECTORY/$file || exit 1 - echo $command_directory/$file:f:root::755 \ + echo \$command_directory/$file:f:root::755 \ >>$CONFIG_DIRECTORY/postfix-files || exit 1 done @@ -557,7 +561,7 @@ then for file in postdrop postqueue do compare_or_replace $EXE bin/$file $COMMAND_DIRECTORY/$file || exit 1 - echo $command_directory/$file:f:root:postdrop:1755 \ + echo \$command_directory/$file:f:root:\$setgid_group:1755 \ >>$CONFIG_DIRECTORY/postfix-files || exit 1 done else @@ -565,7 +569,7 @@ else do compare_or_replace 2$EXE bin/$file $COMMAND_DIRECTORY/$file postdrop \ || exit 1 - echo $command_directory/$file:f:root:postdrop:1755 \ + echo \$command_directory/$file:f:root:\$setgid_group:1755 \ >>$CONFIG_DIRECTORY/postfix-files || exit 1 done fi @@ -577,9 +581,9 @@ test -f bin/sendmail && { compare_or_symlink $SENDMAIL_PATH $NEWALIASES_PATH compare_or_symlink $SENDMAIL_PATH $MAILQ_PATH cat <>$CONFIG_DIRECTORY/postfix-files || exit 1 -$sendmail_path:f:root::755 -$newaliases_path:f:root::755 -$mailq_path:f:root::755 +\$sendmail_path:f:root::755 +\$newaliases_path:f:root::755 +\$mailq_path:f:root::755 EOF } @@ -596,19 +600,19 @@ else do compare_or_replace 644 conf/$file $CONFIG_DIRECTORY/$file || exit 1 done - test -z "$install_root" && need_config="-create -first-install" + test -z "$install_root" && need_config="create-missing first-install" fi for file in `censored_ls conf | egrep -v 'postfix-script|post-install'` do - echo $config_directory/$file:f:root::644 \ + echo \$config_directory/$file:f:root::644 \ >>$CONFIG_DIRECTORY/postfix-files || exit 1 done for file in postfix-script post-install do compare_or_replace $EXE conf/$file $CONFIG_DIRECTORY/$file || exit 1 - echo $config_directory/$file:f:root::755 \ + echo \$config_directory/$file:f:root::755 \ >>$CONFIG_DIRECTORY/postfix-files || exit 1 done @@ -635,7 +639,7 @@ bin/postconf -c $CONFIG_DIRECTORY -e \ for file in `censored_ls man?/*` do compare_or_replace 644 $file $MANPAGE_PATH/$file || exit 1 - echo "$manpage_path/$file:f:root::644" \ + echo \$manpage_path/$file:f:root::644 \ >>$CONFIG_DIRECTORY/postfix-files || exit 1 done) @@ -645,4 +649,6 @@ bin/postconf -c $CONFIG_DIRECTORY -e \ test -n "$install_root" && exit 0 -${SHELL} conf/post-install ${need_config-"-upgrade-source"} $config_directory +export command_directory config_directory + +${SHELL} conf/post-install ${need_config-"upgrade-source"} diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index 38e824787..df5fbc856 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -15,7 +15,7 @@ * Version of this program. */ #define VAR_MAIL_VERSION "mail_version" -#define DEF_MAIL_VERSION "Snapshot-20020110" +#define DEF_MAIL_VERSION "Snapshot-20020111" extern char *var_mail_version; /* LICENSE diff --git a/postfix/src/master/mail_flow.c b/postfix/src/master/mail_flow.c index 2ade8cfab..efb598854 100644 --- a/postfix/src/master/mail_flow.c +++ b/postfix/src/master/mail_flow.c @@ -44,6 +44,7 @@ /* System library. */ #include +#include #include #include @@ -68,6 +69,7 @@ int mail_flow_get(int len) { char *myname = "mail_flow_get"; char buf[BUFFER_SIZE]; + struct stat st; int count; int n = 0; @@ -78,8 +80,14 @@ int mail_flow_get(int len) msg_panic("%s: bad length %d", myname, len); /* - * Read and discard N bytes. XXX AIX read() returns 0 when the pipe is - * empty. + * Silence some wild claims. + */ + if (fstat(MASTER_FLOW_WRITE, &st) < 0) + msg_fatal("fstat flow pipe write descriptor: %m"); + + /* + * Read and discard N bytes. XXX AIX read() can return 0 when an open + * pipe is empty. */ for (count = len; count > 0; count -= n) if ((n = read(MASTER_FLOW_READ, buf, count > BUFFER_SIZE ?