Subject: [alpine-aports] [PATCH] main/dovecot: fix bug #10320: requires entropy before crng init

From: Rolf <[email-masked]>
Date: Sat, 4 May 2019 19:36:25 +0200

Change the dovecot initscript to fix #10320. Also adds "after entropy" and
checks the config before (re)start, making it a bit more robust.
---
 main/dovecot/dovecot.initd | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/main/dovecot/dovecot.initd b/main/dovecot/dovecot.initd
index 721f131ad0..25f301f173 100644
--- a/main/dovecot/dovecot.initd
+++ b/main/dovecot/dovecot.initd
@@ -5,7 +5,6 @@
 description="Secure POP3/IMAP server"
 
 cfgfile=/etc/dovecot/dovecot${instance:+.$instance}.conf
-pidfile=$(doveconf -c $cfgfile -h base_dir 2>/dev/null)/master.pid
 command=/usr/sbin/dovecot
 command_args=${instance:+-c $cfgfile}
 required_files="$cfgfile"
@@ -16,24 +15,39 @@ description_reopen="Reopen log files"
 depend() {
 	need localmount net
 	before mta
-	after bootmisc firewall ldap mysql ntp-client ntpd postgresql saslauthd slapd
+	after bootmisc entropy firewall ldap mysql ntp-client ntpd postgresql saslauthd slapd
 	use logger
 }
 
-start_pre() {
-	ebegin
+checkconfig() {
+	ebegin "Checking $RC_SVCNAME configuration"
+	pidfile=$(doveconf -c $cfgfile -h base_dir 2>/dev/null)/master.pid
 	doveconf -c $cfgfile -x >/dev/null 2>&1 && \
 		checkpath --directory ${pidfile%/*}
 	eend $?
 }
 
+start_pre() {
+	if [ "${RC_CMD}" != "restart" ]; then
+		checkconfig || return $?
+	fi
+}
+
+stop_pre() {
+	if [ "${RC_CMD}" = "restart" ]; then
+		checkconfig || return $?
+	fi
+}
+
 reload() {
+	checkconfig || return $?
 	ebegin "Reloading $RC_SVCNAME configs and restarting auth/login processes"
-	start_pre && start-stop-daemon --signal HUP --pidfile $pidfile
+	start-stop-daemon --signal HUP --pidfile $pidfile
 	eend $?
 }
 
 reopen() {
+	checkconfig || return $?
 	ebegin "Reopening $RC_SVCNAME log files"
 	start-stop-daemon --signal USR1 --pidfile $pidfile
 	eend $?
-- 
2.21.0

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---