View | Details | Raw Unified | Return to bug 249860 | Differences between
and this patch

Collapse All | Expand All

(-)UPDATING (+12 lines)
Lines 5-10 Link Here
5
You should get into the habit of checking this file for changes each time
5
You should get into the habit of checking this file for changes each time
6
you update your ports collection, before attempting any port upgrades.
6
you update your ports collection, before attempting any port upgrades.
7
7
8
20200926:
9
  AFFECTS: users of mail/fetchmail beginning with 6.4.12_1
10
  AUTHOR:  mandree@FreeBSD.org
11
12
  Note that if you are using fetchmail in a multi-user setup, i. e. with the
13
  fetchmail_users (mind the -s!) variable set, the $fetchmail_home_prefix +
14
  user second-guess work has been replaced by a real lookup of the user's home
15
  directory. In the majority of configurations, this should not make a
16
  difference, in some setups, it may open up some flexibility.
17
18
  The fetchmail_home_prefix variable is ignored from 6.4.12_1 onwards.
19
8
20200924:
20
20200924:
9
  AFFECTS: users of net/freeradius3, who need python support
21
  AFFECTS: users of net/freeradius3, who need python support
10
  AUTHOR: zi@FreeBSD.org
22
  AUTHOR: zi@FreeBSD.org
(-)mail/fetchmail/Makefile (+1 lines)
Lines 3-8 Link Here
3
3
4
PORTNAME?=	fetchmail
4
PORTNAME?=	fetchmail
5
DISTVERSION=	6.4.12
5
DISTVERSION=	6.4.12
6
PORTREVISION?=	1
6
CATEGORIES=	mail
7
CATEGORIES=	mail
7
# The next line is inherited by the fetchmailconf slave port,
8
# The next line is inherited by the fetchmailconf slave port,
8
# do NOT replace fetchmail by ${PORTNAME}
9
# do NOT replace fetchmail by ${PORTNAME}
(-)mail/fetchmail/files/fetchmail.in (-32 / +83 lines)
Lines 15-29 Link Here
15
#
15
#
16
# There are two variants:
16
# There are two variants:
17
#
17
#
18
#  Note that there are two variables with only very slightly
19
#  different names, fetchmail_user and fetchmail_users
20
#  (mind the trailing plural-'s').
21
#
18
#  * Single system-wide fetchmail daemon:
22
#  * Single system-wide fetchmail daemon:
23
#    - This mode applies if the 'fetchmail_users' variable
24
#      is unset or empty.
19
#    - It is run as user `fetchmail_user' (default: fetchmail)
25
#    - It is run as user `fetchmail_user' (default: fetchmail)
20
#      Note: The directory /var/run/fetchmail must be writable for
26
#      Note: The directory /var/run/fetchmail must be writable for
21
#            'fetchmail_user'.
27
#            'fetchmail_user'.
22
#    - All configuration is contained in one global file
28
#    - All configuration is contained in one global file
23
#      'fetchmail_config' (default: %%PREFIX%%/etc/fetchmailrc)
29
#      'fetchmail_config' (default: %%PREFIX%%/etc/fetchmailrc)
24
#      that must be owned by 'fetchmail_user' (mode 700)
30
#      that must be owned by 'fetchmail_user' and access mode
31
#      may not be more than 700.
25
#    - The fetchmail daemon awakes to fetch mail every 
32
#    - The fetchmail daemon awakes to fetch mail every 
26
#      'fetchmail_polling_interval' seconds (default: 900).
33
#      'fetchmail_polling_interval' seconds (default: 900).
34
#        Note that a "set daemon 123" in the file $fetchmail_config
35
#      takes precedence. The rc.conf value is only a fall-back.
36
#    - The fetchmail logs will go to the syslog by default, but
37
#      you can override it to a file by setting 
38
#      'fetchmail_logging_facility=--logfile=/path/to/logfile'
39
#      in the rcfile or set logfile /path/to/logfile in the $fetchmail_config
40
#      file.  The log-file must pre-exist and be writable by the
41
#      'fetchmail_user'.
27
#
42
#
28
#  * Per-user daemon
43
#  * Per-user daemon
29
#    - Users for which a fetchmail daemon is to be started must be
44
#    - Users for which a fetchmail daemon is to be started must be
Lines 30-45 Link Here
30
#      listed in 'fetchmail_users', e.g. fetchmail_users="user1 user2"
45
#      listed in 'fetchmail_users', e.g. fetchmail_users="user1 user2"
31
#      The 'fetchmail_user' (sic!) variable is ignored in this
46
#      The 'fetchmail_user' (sic!) variable is ignored in this
32
#      configuration variant.
47
#      configuration variant.
33
#    - The config files for the individual users must be located at
48
#    - The config files for the individual users must be located in
34
#      ${fetchmail_home_prefix}/${user}/${fetchmail_config_name}. The
49
#      the fetchmail_user's home directory as ${fetchmail_config_name}. The
35
#      default for 'fetchmail_home_prefix' is "/home", and that for
50
#      default for 'fetchmail_config_name' is ".fetchmailrc".
36
#      'fetchmail_config_name' is ".fetchmailrc".
51
#    - There are user-specific versions of 'fetchmail_config',
37
#    - Note that "${fetchmail_home_prefix}/${user}" must be writable
52
#      'fetchmail_logging_facility' and 'fetchmail_polling_interval' as well as
38
#      for ${user} since it is used to store the per-user PID files!
53
#      the usual rc.subr variables that can be used to override the defaults,
39
#    - There are user-specific versions of 'fetchmail_config' and
54
#      i.e. for the user 'user1' there are variables 'fetchmail_user1_config'
40
#      'fetchmail_polling_interval' that can be used to override the
55
#      and 'fetchmail_user1_polling_interval', or fetchmail_user1_env to
41
#      defaults, i.e. for the user 'user1' there are variables
56
#      set user-daemon specific environment variables.
42
#      'fetchmail_user1_config' and 'fetchmail_user1_polling_interval'
57
#        Note that a "set daemon 123" in the config file (.fetchmailrc
58
#      by default) takes precedence. The rc.conf value is only a fall-back.
43
#    - All commands (e.g. start, stop, awaken (see below)) can be either
59
#    - All commands (e.g. start, stop, awaken (see below)) can be either
44
#      passed to all instances of the daemon (if %%PREFIX%%/etc/rc.d/fetchmail)
60
#      passed to all instances of the daemon (if %%PREFIX%%/etc/rc.d/fetchmail)
45
#      is run as root), or just to the instance belonging to the respective
61
#      is run as root), or just to the instance belonging to the respective
Lines 54-64 Link Here
54
#
70
#
55
# In any case, you will need a working fetchmailrc file. Please consult
71
# In any case, you will need a working fetchmailrc file. Please consult
56
# the man page fetchmail(1), the documentation in %%PREFIX%%/share/doc/fetchmail/
72
# the man page fetchmail(1), the documentation in %%PREFIX%%/share/doc/fetchmail/
57
# and/or the material found at <http://www.fetchmail.info/>.
73
# and/or the material found at <https://www.fetchmail.info/> or
74
# <https://fetchmail.sourceforge.io/>.
58
75
59
. /etc/rc.subr
76
. /etc/rc.subr
60
77
78
# prevent reading passwords from the boot console
79
exec < /dev/null
80
61
name=fetchmail
81
name=fetchmail
82
# note we do not override name for instances, because we want to have a fallback
83
# to global defaults.  Check for PULLVARS below.
62
rcvar=fetchmail_enable
84
rcvar=fetchmail_enable
63
85
64
command=%%PREFIX%%/bin/${name}
86
command=%%PREFIX%%/bin/${name}
Lines 71-81 Link Here
71
# read settings, set default values
93
# read settings, set default values
72
load_rc_config "$name"
94
load_rc_config "$name"
73
: ${fetchmail_enable="NO"}
95
: ${fetchmail_enable="NO"}
96
: ${fetchmail_flags=""}
74
: ${fetchmail_user="fetchmail"}
97
: ${fetchmail_user="fetchmail"}
75
: ${fetchmail_config="%%PREFIX%%/etc/fetchmailrc"}
98
: ${fetchmail_config="%%PREFIX%%/etc/fetchmailrc"}
76
: ${fetchmail_polling_interval="900"}
99
: ${fetchmail_polling_interval="900"}
77
: ${fetchmail_logging_facility="--syslog"}
100
: ${fetchmail_logging_facility="--syslog"}
78
: ${fetchmail_home_prefix="/home"}
79
: ${fetchmail_config_name=".fetchmailrc"}
101
: ${fetchmail_config_name=".fetchmailrc"}
80
102
81
# send signal to fetchmail process(es) to check for new mail immediately
103
# send signal to fetchmail process(es) to check for new mail immediately
Lines 91-125 Link Here
91
	return
113
	return
92
}
114
}
93
115
116
# arguments:
117
# ACTION - perform ACTION for the one global daemon
118
# ACTION USER GLOBALCONFIG - ditto, inside the recursive call
119
#
120
# ACTION USER - perform ACTION for the USER-specific daemon, inside recursive call
121
#
122
# XXX FIXME - to easily grok this script, read the outer "else" first...
94
if [ -n "$2" ]; then
123
if [ -n "$2" ]; then
95
	# perform action for an instance of fetchmail daemon
124
	# perform action for an instance of fetchmail daemon
96
        user="$2"
125
        fetchmail_user="$2"
97
        if [ "x${fetchmail_users}" != "x" -o "x$3" = "xGLOBALCONFIG"  ]; then
126
        if [ "x${fetchmail_users}" != "x" -o "x$3" = "xGLOBALCONFIG"  ]; then
98
		if [ "x${fetchmail_users}" != "x" ]; then
127
		if [ "x${fetchmail_users}" != "x" ]; then
99
			# multiuser setup:  determine user specific config and pid file
128
			# multiuser setup:  determine user specific config and pid file
100
			eval fetchmail_config="\${fetchmail_${user}_config:-${fetchmail_home_prefix}/${user}}/${fetchmail_config_name}"
129
			fetchmail_home="$(getent passwd ${fetchmail_user} | cut -f6 -d:)"
101
			eval pidfile="${fetchmail_home_prefix}/${user}/.fetchmail.pid"
130
			fetchmail_home="${fetchmail_home%/}"
102
			eval fetchmail_user=$user
131
			fetchmail_config="${fetchmail_home}/${fetchmail_config_name}"
132
			pidfile="${fetchmail_home}/.fetchmail.pid"
133
			# PULLVARS - pull user specific variables into scope if existing
134
			# else use global defaults
135
			for i in chdir chroot env env_file fib flags nice \
136
				limits login_class oomprotect program user group groups prepend \
137
				logging_facility polling_interval
138
			do
139
				uvarname=fetchmail_${fetchmail_user}_${i}
140
		 		eval fetchmail_${i}="\${${uvarname}-\${fetchmail_${i}}}"
141
			done
103
		else
142
		else
104
			eval pidfile=/var/run/fetchmail/fetchmail.pid
143
			pidfile=/var/run/fetchmail/fetchmail.pid
105
		fi
144
		fi
106
		required_files=${fetchmail_config}
145
		required_files=${fetchmail_config}
107
		eval fetchmail_polling_interval="\${fetchmail_${user}_polling_interval:-${fetchmail_polling_interval}}"
146
108
		fetchmail_flags="-f ${fetchmail_config} \
147
		# add early command line arguments
109
				--pidfile ${pidfile} \
148
		# if logfile set in config file, do not override with rc.conf default (note logfile overrides syslog)
110
				-d ${fetchmail_polling_interval} \
149
		_logfile="$(su -m ${fetchmail_user} -c sh -c "fetchmail -f ${fetchmail_config} --configdump" | fgrep logfile | cut -d: -f2)"
111
				${fetchmail_logging_facility}"
150
		if [ _"${_logfile}" != _"None," ] ; then
112
        else
151
			fetchmail_logging_facility=""
113
                echo "$0: extra argument ignored"
152
		fi
114
        fi
153
154
		fetchmail_flags="${fetchmail_flags} -f ${fetchmail_config} --pidfile ${pidfile} ${fetchmail_logging_facility}"
155
156
		# add late command line arguments
157
		# if no polling interval in config file, use value from rc.conf
158
		if [ "$(su -m ${fetchmail_user} -c sh -c "fetchmail -f ${fetchmail_config} --configdump" | fgrep poll_interval | cut -d: -f2)" = "0," ] ; then
159
			fetchmail_flags="${fetchmail_flags} -d ${fetchmail_polling_interval}"
160
		fi
161
	else
162
		echo "$0: extra argument ignored"
163
	fi
115
else
164
else
116
	uid=`id -u`
165
	# global or 'umbrella' run
117
        if [ "x${fetchmail_users}" != "x" -a "x$1" != "x" -a "$uid" = "0" ]; then
166
	uid=$(id -u)
167
	if [ "x${fetchmail_users}" != "x" -a "x$1" != "x" -a "$uid" = "0" ]; then
118
		# root mode: multiple user profiles are handled by recursive
168
		# root mode: multiple user profiles are handled by recursive
119
		# calls of this script
169
		# calls of this script
120
		for user in ${fetchmail_users}; do
170
		for user in ${fetchmail_users}; do
121
			echo "===> fetchmail user: ${user}"
171
			echo "===> fetchmail user: ${user}"
122
			$fetchmail_script $1 ${user}
172
			$fetchmail_script "$1" "${user}"
123
			retcode="$?"
173
			retcode="$?"
124
			if [ "0${retcode}" -ne 0 ]; then
174
			if [ "0${retcode}" -ne 0 ]; then
125
				failed="${user} (${retcode}) ${failed:-}"
175
				failed="${user} (${retcode}) ${failed:-}"
Lines 133-150 Link Here
133
			# There is only one global configuration file
183
			# There is only one global configuration file
134
			globalconfig=GLOBALCONFIG
184
			globalconfig=GLOBALCONFIG
135
		fi
185
		fi
136
		$fetchmail_script $1 `id -u -n` $globalconfig
186
		$fetchmail_script "$1" "$(id -u -n)" $globalconfig
137
		retcode="$?"
187
		retcode="$?"
138
		if [ "0${retcode}" -ne 0 ]; then
188
		if [ "0${retcode}" -ne 0 ]; then
139
			failed="${user} (${retcode}) ${failed:-}"
189
			failed="${name} (${retcode}) ${failed:-}"
140
			exit 1
190
			exit 1
141
		else
191
		else
142
			success="${user} ${success:-}"
192
			success="${name} ${success:-}"
143
		fi
193
		fi
144
		exit 0
194
		exit 0
145
        fi
195
        fi
146
fi
196
fi
147
197
198
148
# actually execute the fetchmail program
199
# actually execute the fetchmail program
149
export FETCHMAILUSER=$fetchmail_user
200
export FETCHMAILUSER=$fetchmail_user
150
run_rc_command "$1"
201
run_rc_command "$1"
(-)mail/fetchmailconf/Makefile (+1 lines)
Lines 1-6 Link Here
1
# $FreeBSD$
1
# $FreeBSD$
2
2
3
PORTNAME=	fetchmailconf
3
PORTNAME=	fetchmailconf
4
PORTREVISION=	0
4
DISTNAME=	fetchmail-${DISTVERSIONPREFIX}${DISTVERSION}${DISTVERSIONSUFFIX}
5
DISTNAME=	fetchmail-${DISTVERSIONPREFIX}${DISTVERSION}${DISTVERSIONSUFFIX}
5
# NOTE: MASTER_SITES in ../fetchmail must NOT use the $PORTNAME variable,
6
# NOTE: MASTER_SITES in ../fetchmail must NOT use the $PORTNAME variable,
6
# else _this_ port (fetchmailconf) becomes unfetchable
7
# else _this_ port (fetchmailconf) becomes unfetchable

Return to bug 249860