diff options
author | Matthias Andree <mandree@FreeBSD.org> | 2020-10-06 23:09:39 +0000 |
---|---|---|
committer | Matthias Andree <mandree@FreeBSD.org> | 2020-10-06 23:09:39 +0000 |
commit | 69c372bb8c1e951b5579f2b47522d7d7ccbee37f (patch) | |
tree | b61dbc39d7af03c134b36b13a43a9fb1a2041747 /mail/fetchmail | |
parent | 58f7d72c101aedbc59d78786c44410c4459994e1 (diff) | |
download | freebsd-ports-69c372bb8c1e951b5579f2b47522d7d7ccbee37f.zip |
mail/fetchmail: fix rcscript regression from _1 that broke global mode
In a situation where fetchmail is to be started globally with the
configuration in $LOCALBASE/etc, the rc.d file would try to run
fetchmail for the wrong user.
Simplify script more, avoiding recursive call in single-user mode.
Submitted by: Corey Halpin (maintainer, direct mail to mandree@)
Reported by: Armin Tüting
Diffstat (limited to 'mail/fetchmail')
-rw-r--r-- | mail/fetchmail/Makefile | 2 | ||||
-rw-r--r-- | mail/fetchmail/files/fetchmail.in | 94 |
2 files changed, 41 insertions, 55 deletions
diff --git a/mail/fetchmail/Makefile b/mail/fetchmail/Makefile index 1fdafcf1c8a7..40c2e00ae532 100644 --- a/mail/fetchmail/Makefile +++ b/mail/fetchmail/Makefile @@ -3,7 +3,7 @@ PORTNAME?= fetchmail DISTVERSION= 6.4.12 -PORTREVISION?= 1 +PORTREVISION?= 2 CATEGORIES= mail # The next line is inherited by the fetchmailconf slave port, # do NOT replace fetchmail by ${PORTNAME} diff --git a/mail/fetchmail/files/fetchmail.in b/mail/fetchmail/files/fetchmail.in index 3803d6dcc56c..c18ce122d982 100644 --- a/mail/fetchmail/files/fetchmail.in +++ b/mail/fetchmail/files/fetchmail.in @@ -126,8 +126,7 @@ fetchmail_dump_config() # if this is the global or 'umbrella' run if [ -z "$2" ] ; then - uid=$(id -u) - if [ "x${fetchmail_users}" != "x" -a "x$1" != "x" -a "$uid" = "0" ]; then + if [ "x${fetchmail_users}" != "x" -a "x$1" != "x" -a "$(id -u)" = "0" ]; then # root mode: multiple user profiles are handled by recursive # calls of this script for user in ${fetchmail_users}; do @@ -138,66 +137,53 @@ if [ -z "$2" ] ; then failed="${user} (${retcode}) ${failed:-}" fi done - else - if [ "x${fetchmail_users}" = "x" ]; then - # There is only one global configuration file - globalconfig=GLOBALCONFIG - fi - $fetchmail_script "$1" "$(id -u -n)" $globalconfig - retcode="$?" - if [ "0${retcode}" -ne 0 ]; then - failed="${name} (${retcode}) ${failed:-}" - fi - fi - # if we had any failures, exit witn an error - if [ -n "${failed}" ] ; then - exit 1 - fi + # if we had any failures, exit with an error + if [ -n "${failed}" ] ; then + exit 1 + fi - # otherwise, exit success - exit 0 + # otherwise, exit success + exit 0 + fi +else + fetchmail_user="$2" fi # perform action for an instance of fetchmail daemon -fetchmail_user="$2" -if [ "x${fetchmail_users}" != "x" -o "x$3" = "xGLOBALCONFIG" ]; then - if [ "x${fetchmail_users}" != "x" ]; then - # multiuser setup: determine user specific config and pid file - fetchmail_home="$(getent passwd ${fetchmail_user} | cut -f6 -d:)" - fetchmail_home="${fetchmail_home%/}" - fetchmail_config="${fetchmail_home}/${fetchmail_config_name}" - pidfile="${fetchmail_home}/.fetchmail.pid" - # PULLVARS - pull user specific variables into scope if existing - # else use global defaults - for i in chdir chroot env env_file fib flags nice \ - limits login_class oomprotect program user group groups prepend \ - logging_facility polling_interval - do - uvarname=fetchmail_${fetchmail_user}_${i} - eval fetchmail_${i}="\${${uvarname}-\${fetchmail_${i}}}" - done - else - pidfile=/var/run/fetchmail/fetchmail.pid - fi - required_files=${fetchmail_config} +if [ "x${fetchmail_users}" != "x" ]; then + # multiuser setup: determine user specific config and pid file + fetchmail_home="$(getent passwd ${fetchmail_user} | cut -f6 -d:)" + fetchmail_home="${fetchmail_home%/}" + fetchmail_config="${fetchmail_home}/${fetchmail_config_name}" + pidfile="${fetchmail_home}/.fetchmail.pid" + # PULLVARS - pull user specific variables into scope if existing + # else use global defaults + for i in chdir chroot env env_file fib flags nice \ + limits login_class oomprotect program user group groups prepend \ + logging_facility polling_interval + do + uvarname=fetchmail_${fetchmail_user}_${i} + eval fetchmail_${i}="\${${uvarname}-\${fetchmail_${i}}}" + done +else + pidfile=/var/run/fetchmail/fetchmail.pid +fi +required_files=${fetchmail_config} - # add early command line arguments - # if logfile set in config file, do not override with rc.conf default (note logfile overrides syslog) - _logfile="$(fetchmail_dump_config logfile)" - if [ _"${_logfile}" != _"None," ] ; then - fetchmail_logging_facility="" - fi +# add early command line arguments +# if logfile set in config file, do not override with rc.conf default (note logfile overrides syslog) +_logfile="$(fetchmail_dump_config logfile)" +if [ _"${_logfile}" != _"None," ] ; then + fetchmail_logging_facility="" +fi - fetchmail_flags="${fetchmail_flags} -f ${fetchmail_config} --pidfile ${pidfile} ${fetchmail_logging_facility}" +fetchmail_flags="${fetchmail_flags} -f ${fetchmail_config} --pidfile ${pidfile} ${fetchmail_logging_facility}" - # add late command line arguments - # if no polling interval in config file, use value from rc.conf - if [ "$(fetchmail_dump_config poll_interval)" = "0," ] ; then - fetchmail_flags="${fetchmail_flags} -d ${fetchmail_polling_interval}" - fi -else - echo "$0: extra argument ignored" +# add late command line arguments +# if no polling interval in config file, use value from rc.conf +if [ "$(fetchmail_dump_config poll_interval)" = "0," ] ; then + fetchmail_flags="${fetchmail_flags} -d ${fetchmail_polling_interval}" fi # actually execute the fetchmail program |