blob: 6ca38683e2b2a77917ebf40877de15ba3b5cd889 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
#!@RCD_SCRIPTS_SHELL@
#
# $NetBSD: qmailsmtpd.sh,v 1.22 2018/11/28 16:22:41 schmonz Exp $
#
# @PKGNAME@ script to control qmail-smtpd (SMTP service).
#
# PROVIDE: qmailsmtpd mail
# REQUIRE: qmailsend
name="qmailsmtpd"
# User-settable rc.conf variables and their default values:
: ${qmailsmtpd_postenv:="SSL_UID=$(@ID@ -u @UCSPI_SSL_USER@) SSL_GID=$(@ID@ -g @UCSPI_SSL_GROUP@)"}
: ${qmailsmtpd_tcpflags:="-ne -vRl0"}
: ${qmailsmtpd_tcphost:="0.0.0.0"}
: ${qmailsmtpd_tcpport:="25"}
: ${qmailsmtpd_datalimit:="540000000"}
: ${qmailsmtpd_pretcpserver:=""}
: ${qmailsmtpd_tcpserver:="@PREFIX@/bin/sslserver"}
: ${qmailsmtpd_presmtpd:="@PREFIX@/bin/greetdelay @PREFIX@/bin/rblsmtpd -r zen.spamhaus.org @PREFIX@/bin/fixsmtpio"}
: ${qmailsmtpd_smtpdcmd:="@PREFIX@/bin/qmail-smtpd"}
: ${qmailsmtpd_postsmtpd:=""}
: ${qmailsmtpd_log:="YES"}
: ${qmailsmtpd_logcmd:="logger -t nbqmail/smtpd -p mail.info"}
: ${qmailsmtpd_nologcmd:="@PREFIX@/bin/multilog -*"}
: ${qmailsmtpd_tls:="auto"}
: ${qmailsmtpd_tls_dhparams:="@PKG_SYSCONFDIR@/control/dh2048.pem"}
: ${qmailsmtpd_tls_cert:="@PKG_SYSCONFDIR@/control/servercert.pem"}
: ${qmailsmtpd_tls_key:=""}
if [ -f /etc/rc.subr ]; then
. /etc/rc.subr
fi
rcvar=${name}
required_files="@PKG_SYSCONFDIR@/control/me"
required_files="${required_files} @PKG_SYSCONFDIR@/control/concurrencyincoming"
required_files="${required_files} @PKG_SYSCONFDIR@/control/rcpthosts"
required_files="${required_files} @PKG_SYSCONFDIR@/tcp.smtp.cdb"
command="${qmailsmtpd_tcpserver}"
procname=nb${name}
start_precmd="qmailsmtpd_precmd"
extra_commands="stat pause cont cdb reload"
stat_cmd="qmailsmtpd_stat"
pause_cmd="qmailsmtpd_pause"
cont_cmd="qmailsmtpd_cont"
cdb_cmd="qmailsmtpd_cdb"
reload_cmd=${cdb_cmd}
qmailsmtpd_configure_tls() {
if [ "auto" = "${qmailsmtpd_tls}" ]; then
if [ -f "${qmailsmtpd_tls_dhparams}" ] && [ -f "${qmailsmtpd_tls_cert}" ]; then
qmailsmtpd_enable_tls
else
qmailsmtpd_disable_tls
fi
elif [ -f /etc/rc.subr ] && checkyesno qmailsmtpd_tls; then
qmailsmtpd_enable_tls
else
qmailsmtpd_disable_tls
fi
}
qmailsmtpd_disable_tls() {
qmailsmtpd_postenv="${qmailsmtpd_postenv} DISABLETLS=1"
}
qmailsmtpd_enable_tls() {
qmailsmtpd_postenv="${qmailsmtpd_postenv} DHFILE=${qmailsmtpd_tls_dhparams}"
qmailsmtpd_postenv="${qmailsmtpd_postenv} CERTFILE=${qmailsmtpd_tls_cert}"
if [ -f "${qmailsmtpd_tls_key}" ]; then
qmailsmtpd_postenv="${qmailsmtpd_postenv} KEYFILE=${qmailsmtpd_tls_key}"
fi
}
qmailsmtpd_precmd()
{
if [ -f /etc/rc.subr ] && ! checkyesno qmailsmtpd_log; then
qmailsmtpd_logcmd=${qmailsmtpd_nologcmd}
fi
qmailsmtpd_configure_tls
# tcpserver(1) is akin to inetd(8), but runs one service per process.
# We want to signal only the tcpserver process responsible for this
# service. Use argv0(1) to set procname to "nbqmailsmtpd".
command="@PREFIX@/bin/pgrphack @SETENV@ - ${qmailsmtpd_postenv}
@PREFIX@/bin/softlimit -m ${qmailsmtpd_datalimit} ${qmailsmtpd_pretcpserver}
@PREFIX@/bin/argv0 ${qmailsmtpd_tcpserver} ${procname}
${qmailsmtpd_tcpflags} -x @PKG_SYSCONFDIR@/tcp.smtp.cdb
-c `@HEAD@ -1 @PKG_SYSCONFDIR@/control/concurrencyincoming`
-u `@ID@ -u @QMAIL_DAEMON_USER@` -g `@ID@ -g @QMAIL_DAEMON_USER@`
${qmailsmtpd_tcphost} ${qmailsmtpd_tcpport}
${qmailsmtpd_presmtpd} ${qmailsmtpd_smtpdcmd} ${qmailsmtpd_postsmtpd}
2>&1 |
@PREFIX@/bin/pgrphack @PREFIX@/bin/setuidgid @QMAIL_LOG_USER@ ${qmailsmtpd_logcmd}"
command_args="&"
rc_flags=""
}
qmailsmtpd_stat()
{
run_rc_command status
}
qmailsmtpd_pause()
{
if ! statusmsg=`run_rc_command status`; then
@ECHO@ $statusmsg
return 1
fi
@ECHO@ "Pausing ${name}."
kill -STOP $rc_pid
}
qmailsmtpd_cont()
{
if ! statusmsg=`run_rc_command status`; then
@ECHO@ $statusmsg
return 1
fi
@ECHO@ "Continuing ${name}."
kill -CONT $rc_pid
}
qmailsmtpd_cdb()
{
@ECHO@ "Reloading @PKG_SYSCONFDIR@/tcp.smtp."
cd @PKG_SYSCONFDIR@
@PREFIX@/bin/tcprules tcp.smtp.cdb tcp.smtp.tmp < tcp.smtp
@CHMOD@ 644 tcp.smtp.cdb
}
if [ -f /etc/rc.subr ]; then
load_rc_config $name
run_rc_command "$1"
else
@ECHO_N@ " ${name}"
qmailsmtpd_precmd
eval ${command} ${qmailsmtpd_flags} ${command_args}
fi
|