summaryrefslogtreecommitdiff
path: root/user/netqmail/netqmail.initd
diff options
context:
space:
mode:
authorLaurent Bercot <ska-adelie@skarnet.org>2023-01-15 19:39:25 +0000
committerLaurent Bercot <ska-adelie@skarnet.org>2023-01-15 22:47:38 +0000
commitc7463dd3f6857af03af871bea754535feb0af3e6 (patch)
tree298f6b2e9cd1627f959370cf06c73ef8bfc5f90c /user/netqmail/netqmail.initd
parent8bc45c494da91875604612d85e5bb596892b096c (diff)
downloadpackages-c7463dd3f6857af03af871bea754535feb0af3e6.tar.gz
packages-c7463dd3f6857af03af871bea754535feb0af3e6.tar.bz2
packages-c7463dd3f6857af03af871bea754535feb0af3e6.tar.xz
packages-c7463dd3f6857af03af871bea754535feb0af3e6.zip
user/netqmail: support STARTTLS, manage conflict with ssmtp
Diffstat (limited to 'user/netqmail/netqmail.initd')
-rw-r--r--user/netqmail/netqmail.initd64
1 files changed, 20 insertions, 44 deletions
diff --git a/user/netqmail/netqmail.initd b/user/netqmail/netqmail.initd
index dae9c4d55..36e43e74e 100644
--- a/user/netqmail/netqmail.initd
+++ b/user/netqmail/netqmail.initd
@@ -12,39 +12,30 @@ makesmtpd()
{
set -e
ip="$1"
- usetls="$2"
- if "$usetls" ; then
- s="s"
- port=25
- else
- s=
- port=465
- fi
- if s6-tcpserver6-socketbinder -dBb0 -- "$ip" "$port" true 2>/dev/null ; then
+ ext="$2"
+ if s6-tcpserver6-socketbinder -dBb0 -- "$ip" 25 true 2>/dev/null ; then
ipv=6
relayfor="$smtprelay6"
- elif s6-tcpserver4-socketbinder -dBb0 -- "$ip" "$port" true 2>/dev/null ; then
+ elif s6-tcpserver4-socketbinder -dBb0 -- "$ip" 25 true 2>/dev/null ; then
ipv=4
relayfor="$smtprelay4"
else
return 1
fi
- service="smtp${s}d-$ip"
+ service="smtpd-$ip"
sdir=/run/services/"$service"
- logdir=/var/log/"smtp${s}d-$ip"
+ logdir=/var/log/"smtpd-$ip"
mkdir -p -m 0755 "$logdir"
chown qmaill:qmaill "$logdir"
chmod 2700 "$logdir"
rm -rf "$sdir"
- cp -a /etc/qmail/services/smtp"${s}"d"${ipv}"-skeleton "$sdir"
+ cp -a /etc/qmail/services/smtpd"${ipv}"-skeleton"$ext" "$sdir"
echo "$ip" > "$sdir"/env/IP
- if "$usetls" ; then
- echo "$SMTPSD_KEYFILE" > "$sdir"/env/KEYFILE
- echo "$SMTPSD_CERTFILE" > "$sdir"/env/CERTFILE
- fi
+ echo "$KEYFILE" > "$sdir"/env/KEYFILE
+ echo "$CERTFILE" > "$sdir"/env/CERTFILE
for j in $relayfor ; do
mkdir -p -m 0755 "$sdir/data/rules/ip${ipv}/$j/env"
@@ -59,23 +50,15 @@ stop()
{
set -e
. /etc/conf.d/netqmail
- ebegin "Stopping SMTP and SMTPS listeners"
+ ebegin "Stopping SMTP listeners"
dirs=""
logs=""
- for i in ${SMTPD_IPS} ; do
+ for i in ${IPS} ; do
rm -f "/run/service/smtpd-$i"
s6-svc -d "/run/services/smtpd-$i"
dirs="$dirs /run/services/smtpd-$i"
logs="$logs /run/services/smtpd-$i/log"
done
- if test -r "$SMTPSD_KEYFILE" && test -r "$SMTPSD_CERTFILE" ; then
- for i in ${SMTPSD_IPS} ; do
- rm -f "/run/service/smtpsd-$i"
- s6-svc -d "/run/services/smtpsd-$i"
- dirs="$dirs /run/services/smtpsd-$i"
- logs="$logs /run/services/smtpsd-$i/log"
- done
- fi
s6-svwait -D $dirs
eend $?
@@ -99,6 +82,11 @@ start()
{
set -e
. /etc/conf.d/netqmail
+ if test -r "$KEYFILE" && test -r "$CERTFILE" ; then
+ ext=""
+ else
+ ext="-notls"
+ fi
ebegin "Parsing the relay subnets"
smtprelay4=
@@ -122,31 +110,19 @@ start()
s6-svwait -U /var/qmail/services/qmail
eend $?
- for i in ${SMTPD_IPS} ; do
+ mkdir -p /run/services
+ for i in ${IPS} ; do
ebegin "Creating a service directory for a SMTP listener on $i"
- makesmtpd "$i" false
+ makesmtpd "$i" "$ext"
eend $?
done
- if test -r "$SMTPSD_KEYFILE" && test -r "$SMTPSD_CERTFILE" ; then
- for i in ${SMTPSD_IPS} ; do
- ebegin "Creating a service directory for a SMTPS listener on $i"
- makesmtpd "$i" true
- eend $?
- done
- fi
dirs=""
- ebegin "Starting SMTP/S listeners"
- for i in ${SMTPD_IPS} ; do
+ ebegin "Starting SMTP listeners"
+ for i in ${IPS} ; do
ln -nsf "../services/smtpd-$i" "/run/service/smtpd-$i"
dirs="$dirs /run/service/smtpd-$i"
done
- if test -r "$SMTPSD_KEYFILE" && test -r "$SMTPSD_CERTFILE" ; then
- for i in ${SMTPSD_IPS} ; do
- ln -nsf "../services/smtpsd-$i" "/run/service/smtpsd-$i"
- dirs="$dirs /run/service/smtpsd-$i"
- done
- fi
s6-svscanctl -aN /run/service
s6-svwait -U $dirs
eend $?