git: a8a45bdf49a9 - main - mail/mimedefang: Allow setting MX_MAX_RSS and MX_MAX_AS in rc.conf
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 10 Dec 2021 23:26:15 UTC
The branch main has been updated by 0mp:
URL: https://cgit.FreeBSD.org/ports/commit/?id=a8a45bdf49a9f13b4dd15d986de86a29e3ea45ed
commit a8a45bdf49a9f13b4dd15d986de86a29e3ea45ed
Author: ml@netfence.it <ml@netfence.it>
AuthorDate: 2021-12-10 23:21:13 +0000
Commit: Mateusz Piotrowski <0mp@FreeBSD.org>
CommitDate: 2021-12-10 23:25:57 +0000
mail/mimedefang: Allow setting MX_MAX_RSS and MX_MAX_AS in rc.conf
In order to avoid DOSes due to complex MIME, MIMEDefang sets some limits
on how much memory a process can use (MX_MAX_RSS and MX_MAX_AS).
The provided example init script sets these variables to very low values
(which probably made sense when RAM was much scarcer); the port already
patches that file, increasing them, but they are still way too low in
some cases, resulting in some mail messages crashing the filter and not
passing.
This patch, while retaining the current port defaults, allows these
thresholds to be set in rc.conf.
PR: 256711
Approved by: maintainer
---
mail/mimedefang/Makefile | 2 +
.../files/patch-examples__init-script.in | 47 ++++++++++++++--------
mail/mimedefang/files/patch-mimedefang-filter.5.in | 4 +-
3 files changed, 35 insertions(+), 18 deletions(-)
diff --git a/mail/mimedefang/Makefile b/mail/mimedefang/Makefile
index f1f60724a54d..fd19fc93f26d 100644
--- a/mail/mimedefang/Makefile
+++ b/mail/mimedefang/Makefile
@@ -2,6 +2,8 @@
PORTNAME= mimedefang
PORTVERSION= 2.84
+PORTREVISION= 1
+
CATEGORIES= mail
MASTER_SITES= http://www.mimedefang.org/static/ \
http://fossies.org/linux/misc/
diff --git a/mail/mimedefang/files/patch-examples__init-script.in b/mail/mimedefang/files/patch-examples__init-script.in
index 00fb159a37c1..9483e3f663d1 100644
--- a/mail/mimedefang/files/patch-examples__init-script.in
+++ b/mail/mimedefang/files/patch-examples__init-script.in
@@ -1,6 +1,21 @@
--- examples/init-script.in.orig 2017-09-07 17:52:24 UTC
+++ examples/init-script.in
-@@ -41,6 +41,12 @@ export LC_ALL
+@@ -7,6 +7,14 @@
+ # BEFORE: mail
+ # KEYWORD: shutdown
+
++. /etc/rc.subr
++
++# read settings, set default values
++load_rc_config "$name"
++
++: ${mimedefang_mx_max_rss=100000}
++: ${mimedefang_mx_max_as=300000}
++
+ RETVAL=0
+ prog='mimedefang'
+ SPOOLDIR='@SPOOLDIR@'
+@@ -41,6 +49,12 @@ export LC_ALL
# The socket used by mimedefang to communicate with sendmail
# SOCKET=$SPOOLDIR/mimedefang.sock
@@ -13,21 +28,21 @@
# Run the multiplexor and filters as this user, not root. RECOMMENDED
MX_USER=@DEFANGUSER@
-@@ -138,11 +144,11 @@ MX_MAXIMUM=10
+@@ -138,11 +152,11 @@ MX_MAXIMUM=10
# Limit worker processes' resident-set size to this many kilobytes. Default
# is unlimited.
-# MX_MAX_RSS=10000
-+MX_MAX_RSS=100000
++MX_MAX_RSS=${mimedefang_mx_max_rss}
# Limit total size of worker processes' memory space to this many kilobytes.
# Default is unlimited.
-# MX_MAX_AS=30000
-+MX_MAX_AS=300000
++MX_MAX_AS=${mimedefang_mx_max_as}
# If you want to use the "notification" facility, set the appropriate port.
# See the mimedefang-notify man page for details.
-@@ -189,7 +195,7 @@ then
+@@ -189,7 +203,7 @@ then
. /etc/rc.subr
name=$prog
@@ -36,7 +51,7 @@
# default to not enabled, enable in rc.conf
eval $rcvar=\${$rcvar:-NO}
-@@ -199,6 +205,7 @@ then
+@@ -199,6 +213,7 @@ then
procname=$PROGDIR/$prog-multiplexor
start_cmd="start_it"
stop_cmd="stop_it"
@@ -44,7 +59,7 @@
sig_reload="INT"
reread_cmd="reread_it"
# provide both "reload", the FreeBSD default, with a direct signal to
-@@ -209,6 +216,8 @@ fi
+@@ -209,6 +224,8 @@ fi
# Make sure required vars are set
SOCKET=${SOCKET:=$SPOOLDIR/$prog.sock}
MX_SOCKET=${MX_SOCKET:=$SPOOLDIR/$prog-multiplexor.sock}
@@ -53,7 +68,7 @@
start_it() {
if test -r $PID ; then
-@@ -294,6 +303,29 @@ start_it() {
+@@ -294,6 +311,29 @@ start_it() {
kill `cat $MXPID`
return 1
fi
@@ -83,7 +98,7 @@
return 0
}
-@@ -329,7 +361,7 @@ stop_it() {
+@@ -329,7 +369,7 @@ stop_it() {
rm -f $MX_SOCKET > /dev/null 2>&1
rm -f $SOCKET > /dev/null 2>&1
@@ -92,16 +107,16 @@
printf "Waiting for daemons to exit."
WAITPID=""
test -f $PID && WAITPID=`cat $PID`
-@@ -381,6 +413,12 @@ reread_it() {
+@@ -379,6 +419,12 @@ reread_it() {
+ echo "Could not find process-ID of $prog-multiplexor"
+ fi
fi
- }
-
++}
++
+restart_it() {
+ stop_it wait
+ start_it
+ RETVAL=$?
-+}
-+
+ }
+
if type run_rc_command > /dev/null 2>&1
- then
- # NetBSD/FreeBSD compatible startup script
diff --git a/mail/mimedefang/files/patch-mimedefang-filter.5.in b/mail/mimedefang/files/patch-mimedefang-filter.5.in
index 90a57e1844ba..b16fc89aaded 100644
--- a/mail/mimedefang/files/patch-mimedefang-filter.5.in
+++ b/mail/mimedefang/files/patch-mimedefang-filter.5.in
@@ -1,6 +1,6 @@
---- mimedefang-filter.5.in.orig 2014-05-21 13:51:21 UTC
+--- mimedefang-filter.5.in.orig 2017-09-07 17:46:57 UTC
+++ mimedefang-filter.5.in
-@@ -622,7 +622,7 @@ and entity_contains_virus_sophie unless
+@@ -634,7 +634,7 @@ and entity_contains_virus_sophie unless a socket is pr
routine.
.TP