Gentoo Archives: gentoo-commits

From: Michael Orlitzky <mjo@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: mail-filter/opendkim/files/, mail-filter/opendkim/
Date: Wed, 27 Mar 2019 17:19:13
Message-Id: 1553707087.28706fe998d7ea18549d78aa1bfee4da6bb18ffa.mjo@gentoo
1 commit: 28706fe998d7ea18549d78aa1bfee4da6bb18ffa
2 Author: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
3 AuthorDate: Wed Mar 27 15:48:17 2019 +0000
4 Commit: Michael Orlitzky <mjo <AT> gentoo <DOT> org>
5 CommitDate: Wed Mar 27 17:18:07 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=28706fe9
7
8 mail-filter/opendkim: new revision to overhaul service scripts.
9
10 The OpenRC service script has been largely rewritten in this revision,
11 to solve a number of problems:
12
13 * The PID file is now stored securely (bug 629914).
14
15 * Different PID files are used for multiple instances (bug 536162).
16
17 * The detection of boolean options in the config file is more robust,
18 allowing "1", "0", "yes", "false", et cetera.
19
20 * The socket is now located in a conf.d file, rather than parsed from
21 the config file. The service script ensures that the directory
22 containing the socket has the correct permissions, and the conf.d
23 file comes with a big warning to that effect. Note that the (commented-
24 out) example directory IS NOT shared with the PID file.
25
26 * An error is thrown if we can't remove a stale socket.
27
28 * Modern OpenRC service script standards have been adopted.
29
30 Some minor changes have been made to the systemd service for
31 consistency, but none of them have been tested. More work needs to be
32 done here anyway; for example, we most likely want a tmpfiles.d entry
33 for the local socket directory if the user configures one. This should
34 be documented in opendkim.service.conf, and tested by someone who uses
35 systemd.
36
37 Closes: https://bugs.gentoo.org/536162
38 Bug: https://bugs.gentoo.org/629914
39 Signed-off-by: Michael Orlitzky <mjo <AT> gentoo.org>
40 Package-Manager: Portage-2.3.62, Repoman-2.3.11
41
42 .../{opendkim-r2.service => opendkim-r3.service} | 2 +-
43 mail-filter/opendkim/files/opendkim.confd | 18 ++++++
44 mail-filter/opendkim/files/opendkim.init.r4 | 55 ----------------
45 mail-filter/opendkim/files/opendkim.init.r5 | 73 ++++++++++++++++++++++
46 mail-filter/opendkim/files/opendkim.service.conf | 2 +
47 ...-2.10.3-r6.ebuild => opendkim-2.10.3-r7.ebuild} | 26 ++++----
48 6 files changed, 109 insertions(+), 67 deletions(-)
49
50 diff --git a/mail-filter/opendkim/files/opendkim-r2.service b/mail-filter/opendkim/files/opendkim-r3.service
51 similarity index 84%
52 rename from mail-filter/opendkim/files/opendkim-r2.service
53 rename to mail-filter/opendkim/files/opendkim-r3.service
54 index 006ff822d7f..a102c0a6900 100644
55 --- a/mail-filter/opendkim/files/opendkim-r2.service
56 +++ b/mail-filter/opendkim/files/opendkim-r3.service
57 @@ -4,7 +4,7 @@ Documentation=man:opendkim(8) man:opendkim.conf(5) man:opendkim-genkey(8) man:op
58 After=network.target nss-lookup.target syslog.target
59
60 [Service]
61 -ExecStart=/usr/sbin/opendkim -f -x /etc/opendkim/opendkim.conf
62 +ExecStart=/usr/sbin/opendkim -f -x /etc/opendkim/opendkim.conf -p $OPENDKIM_SOCKET
63 ExecReload=/bin/kill -USR1 $MAINPID
64 RuntimeDirectory=opendkim
65 RuntimeDirectoryMode=0750
66
67 diff --git a/mail-filter/opendkim/files/opendkim.confd b/mail-filter/opendkim/files/opendkim.confd
68 new file mode 100644
69 index 00000000000..03bb8d88e2b
70 --- /dev/null
71 +++ b/mail-filter/opendkim/files/opendkim.confd
72 @@ -0,0 +1,18 @@
73 +# This overrides the "Socket" line in your opendkim.conf configuration
74 +# file, and is required (so that we don't have to try to parse the
75 +# configuration file in an init script). The default below listens
76 +# on the network.
77 +#
78 +# If you would rather use a local (UNIX) socket, try the following:
79 +#
80 +# WARNING: The directory containing this socket will have its owner
81 +# changed to "opendkim".
82 +#
83 +#OPENDKIM_SOCKET="local:/run/opendkim/opendkim.sock"
84 +#
85 +# More examples of valid socket syntax can be found in the opendkim(8)
86 +# man page, under the "-p socketspec" option. However -- contrary to
87 +# what that man page says -- if you want to use a local socket, the
88 +# "local:" prefix is not optional here.
89 +#
90 +OPENDKIM_SOCKET="inet:8891@localhost"
91
92 diff --git a/mail-filter/opendkim/files/opendkim.init.r4 b/mail-filter/opendkim/files/opendkim.init.r4
93 deleted file mode 100644
94 index 8c349b85dd3..00000000000
95 --- a/mail-filter/opendkim/files/opendkim.init.r4
96 +++ /dev/null
97 @@ -1,55 +0,0 @@
98 -#!/sbin/openrc-run
99 -# Copyright 1999-2019 Gentoo Authors
100 -# Distributed under the terms of the GNU General Public License v2
101 -
102 -CONFFILE=/etc/opendkim/${SVCNAME}.conf
103 -
104 -depend() {
105 - use dns logger net
106 - before mta
107 -}
108 -
109 -check_cfg() {
110 -
111 - PIDFILE=$(sed -ne 's/^[[:space:]]*PidFile[[:space:]]\+//p' "${CONFFILE}")
112 - local PIDDIR="${PIDFILE%/*}"
113 - if [ ! -d "${PIDDIR}" ] ; then
114 - checkpath -q -d -o opendkim:opendkim -m 0755 "${PIDDIR}" || return 1
115 - fi
116 - if [ ! -f "${CONFFILE}" ] ; then
117 - eerror "Configuration file ${CONFFILE} is missing"
118 - return 1
119 - fi
120 - if [ -z "${PIDFILE}" ] ; then
121 - eerror "Configuration file needs PidFile setting - recommend adding 'PidFile /var/run/opendkim/${SVCNAME}.pid' to ${CONFFILE}"
122 - return 1
123 - fi
124 -
125 - if egrep -q '^[[:space:]]*Background[[:space:]]+no' "${CONFFILE}" ; then
126 - eerror "${SVCNAME} service cannot run with Background key set to yes!"
127 - return 1
128 - fi
129 -}
130 -
131 -start() {
132 - check_cfg || return 1
133 -
134 - # Remove stalled Unix socket if no other process is using it
135 - local UNIX_SOCKET=$(sed -ne 's/^[[:space:]]*Socket[[:space:]]\+\(unix\|local\)://p' "${CONFFILE}")
136 -
137 - if [ -S "${UNIX_SOCKET}" ] && ! fuser -s "${UNIX_SOCKET}"; then
138 - rm "${UNIX_SOCKET}"
139 - fi
140 -
141 - ebegin "Starting OpenDKIM"
142 - start-stop-daemon --start --pidfile "${PIDFILE}" \
143 - --exec /usr/sbin/opendkim -- -x "${CONFFILE}"
144 - eend $?
145 -}
146 -
147 -stop() {
148 - check_cfg || return 1
149 - ebegin "Stopping OpenDKIM"
150 - start-stop-daemon --stop --pidfile "${PIDFILE}"
151 - eend $?
152 -}
153
154 diff --git a/mail-filter/opendkim/files/opendkim.init.r5 b/mail-filter/opendkim/files/opendkim.init.r5
155 new file mode 100644
156 index 00000000000..ad45f420e3c
157 --- /dev/null
158 +++ b/mail-filter/opendkim/files/opendkim.init.r5
159 @@ -0,0 +1,73 @@
160 +#!/sbin/openrc-run
161 +# Copyright 1999-2019 Gentoo Authors
162 +# Distributed under the terms of the GNU General Public License v2
163 +
164 +CONFFILE="/etc/opendkim/${RC_SVCNAME}.conf"
165 +required_files="${CONFFILE}"
166 +
167 +command="/usr/sbin/opendkim"
168 +pidfile="/run/${RC_SVCNAME}.pid"
169 +command_args="-P ${pidfile} -x ${CONFFILE} -p ${OPENDKIM_SOCKET}"
170 +
171 +depend() {
172 + use dns logger net
173 + before mta
174 +}
175 +
176 +check_cfg() {
177 + #
178 + # The opendkim.conf man page says,
179 + #
180 + # For parameters that are Boolean in nature, only the first byte
181 + # of the value is processed... For negative values, the following
182 + # are accepted: "F", "f", "N", "n", "0".'
183 + #
184 + if grep --quiet '^[[:space:]]*Background[[:space:]]\+[FfNn0]' \
185 + "${CONFFILE}"; then
186 + eerror "${RC_SVCNAME} cannot run in the foreground!"
187 + return 1
188 + fi
189 +}
190 +
191 +start_pre() {
192 + # If this isn't a restart, make sure that the user's config isn't
193 + # busted before we try to start the daemon (this will produce
194 + # better error messages than if we just try to start it blindly).
195 + #
196 + # If, on the other hand, this *is* a restart, then the stop_pre
197 + # action will have ensured that the config is usable and we don't
198 + # need to do that again.
199 + if [ "${RC_CMD}" != "restart" ]; then
200 + check_cfg || return $?
201 + fi
202 +
203 + if [ -S "${OPENDKIM_SOCKET}" ] && ! fuser -s "${OPENDKIM_SOCKET}"; then
204 + # Remove stalled Unix socket if no other process is
205 + # using it
206 + if ! rm "${UNIX_SOCKET}"; then
207 + eerror "failed to remove stale unix socket ${OPENDKIM_SOCKET}"
208 + return 2
209 + fi
210 + fi
211 +
212 + # This relies on the "local:" prefix being there, but the conf.d
213 + # file explicitly states that it's not optional (contrary to what
214 + # the opendkim(8) man page says).
215 + if [ "${OPENDKIM_SOCKET#local:}" != "${OPENDKIM_SOCKET}" ]; then
216 + # The socket begins with "local:"
217 + OPENDKIM_SOCKET_PATH="${OPENDKIM_SOCKET#local:}"
218 + OPENDKIM_SOCKET_DIR="${OPENDKIM_SOCKET_PATH%/*}"
219 +
220 + # This is dangerous, but there's a big warning about it
221 + # in the conf.d file.
222 + checkpath --directory --owner opendkim "${OPENDKIM_SOCKET_DIR}"
223 + fi
224 +}
225 +
226 +stop_pre() {
227 + # If this is a restart, check to make sure the user's config
228 + # isn't busted before we stop the running daemon.
229 + if [ "${RC_CMD}" = "restart" ]; then
230 + check_cfg || return $?
231 + fi
232 +}
233
234 diff --git a/mail-filter/opendkim/files/opendkim.service.conf b/mail-filter/opendkim/files/opendkim.service.conf
235 new file mode 100644
236 index 00000000000..380ba22ac94
237 --- /dev/null
238 +++ b/mail-filter/opendkim/files/opendkim.service.conf
239 @@ -0,0 +1,2 @@
240 +[Service]
241 +Environment="OPENDKIM_SOCKET=inet:8891@localhost"
242
243 diff --git a/mail-filter/opendkim/opendkim-2.10.3-r6.ebuild b/mail-filter/opendkim/opendkim-2.10.3-r7.ebuild
244 similarity index 88%
245 rename from mail-filter/opendkim/opendkim-2.10.3-r6.ebuild
246 rename to mail-filter/opendkim/opendkim-2.10.3-r7.ebuild
247 index b375078ae11..ec539e9dbc5 100644
248 --- a/mail-filter/opendkim/opendkim-2.10.3-r6.ebuild
249 +++ b/mail-filter/opendkim/opendkim-2.10.3-r7.ebuild
250 @@ -53,13 +53,15 @@ pkg_setup() {
251 src_prepare() {
252 default
253
254 - sed -i -e 's:/var/db/dkim:/etc/opendkim:g' \
255 - -e 's:/var/db/opendkim:/var/lib/opendkim:g' \
256 - -e 's:/etc/mail:/etc/opendkim:g' \
257 - -e 's:mailnull:opendkim:g' \
258 - -e 's:^#[[:space:]]*PidFile.*:PidFile /run/opendkim/opendkim.pid:' \
259 - opendkim/opendkim.conf.sample opendkim/opendkim.conf.simple.in \
260 - stats/opendkim-reportstats{,.in} || die
261 + # We delete the "Socket" setting because it's overridden by our
262 + # conf.d file.
263 + sed -e 's:/var/db/dkim:/etc/opendkim:g' \
264 + -e 's:/var/db/opendkim:/var/lib/opendkim:g' \
265 + -e 's:/etc/mail:/etc/opendkim:g' \
266 + -e 's:mailnull:opendkim:g' \
267 + -e '/^[[:space:]]*Socket/d' \
268 + -i opendkim/opendkim.conf.sample opendkim/opendkim.conf.simple.in \
269 + stats/opendkim-reportstats{,.in} || die
270
271 sed -i -e 's:dist_doc_DATA:dist_html_DATA:' libopendkim/docs/Makefile.am \
272 || die
273 @@ -120,8 +122,10 @@ src_install() {
274
275 dosbin stats/opendkim-reportstats
276
277 - newinitd "${FILESDIR}/opendkim.init.r4" opendkim
278 - systemd_newunit "${FILESDIR}/opendkim-r2.service" opendkim.service
279 + newinitd "${FILESDIR}/opendkim.init.r5" opendkim
280 + newconfd "${FILESDIR}/opendkim.confd" opendkim
281 + systemd_newunit "${FILESDIR}/opendkim-r3.service" opendkim.service
282 + systemd_install_serviced "${FILESDIR}/${PN}.service.conf" "${PN}.service"
283
284 dodir /etc/opendkim
285 keepdir /var/lib/opendkim
286 @@ -192,8 +196,8 @@ pkg_config() {
287 # MTA configuration
288 echo
289 einfo "If you are using Postfix, add following lines to your main.cf:"
290 - einfo " smtpd_milters = unix:/var/run/opendkim/opendkim.sock"
291 - einfo " non_smtpd_milters = unix:/var/run/opendkim/opendkim.sock"
292 + einfo " smtpd_milters = unix:/run/opendkim/opendkim.sock"
293 + einfo " non_smtpd_milters = unix:/run/opendkim/opendkim.sock"
294 einfo " and read http://www.postfix.org/MILTER_README.html"
295
296 # DNS configuration