24 ottobre 2017 Roberto Puzzanghera0 commenti
Se si vuole evitare il rischio di compromettere il proprio server a causa di account che inviano indiscriminatamente messaggi a tutto il mondo, ad esempio per via di di una password che è stata violata in qualche modo, si può utilizzare lo script rcptcheck-overlimit.sh di Luca Franceschini, che deve essere usato insieme alla patch rcptcheck (una patch derivata da Luca da un lavoro originale di Jay Soffian).
Sin da quando nel 2016 Luca ha deciso di unire la sua "combo patch" con la mia, egli sta continuando a dare il suo personale contributo alla stessa risolvendo bug, aggiungendo nuove patch e nuove funzionalità, spesso scrivendone lui stesso il codice. Lo script da lui condiviso qui è solo l'ultimo della serie ed è piuttosto sorprendente (almeno per me) osservare quante cose vengono fatte mettendo insieme appena 20 righe di buon linguaggio shell.
Ciò che segue è un semplice copia & incolla delle note poste dall'autore in testa allo stesso script.
This script limits the number of emails sent by relayclients (authusers or ip with RELAYCLIENT
in tcprules). You must define the variable RCPTCHECK=/var/qmail/bin/rcptcheck-overlimit.sh
and RCPTCHECKRELAYCLIENT="1".
This script will be called for every accepted rcptto
. If RELAYCLIENT
is not defined the script terminates with the exit code 112 (ignore/accept). Messages sent to domains in rcpthosts will NOT be accounted for.
For every accepted rcptto
with RELAYCLIENT
defined, a char 'X' will be appended to a file in the directory $OVERLIMITDIR
; this file name will be the authuser, if defined, or the client ip address.
The script will look for an entry corresponding to the client (authuser or ip) in $LIMITSCONTROLFILE
and use the number found as the maximum number of allowed outgoing emails.
If the OVERLIMITDIR
is not writable by the user running qmail-smtpd
or the LIMITSCONTROLFILE
cannot be read, the script terminates with 112 (ignore/accept). In case of overlimit, an exit code 113 (reject/overlimit) will be returned to qmail-smtpd
and the connection will be dropped with a 421. $LIMITSCONTROLFILEFILE
can contain comments, '0' means unlimited, the entry starting with ':' will be considered the default limit.
If the default entry can't be found, the default will be set to unlimited. In case more lines match the client name, only the last will be used.
A cronjob must be created to periodically cleanup files in $OVERLIMITDIR
: to use daily limits, schedule the job once a day.
Cronjob example:
0 3 * * * find /var/qmail/overlimit/ -type f -exec rm -f "{}" \; 1> /dev/null
$LIMITSCONTROLFILE
example:
:1000 1.2.3.4:3000 test@example.com:0
Known bugs:
Scaricare come segue
cd /var/qmail/bin/ wget https://notes.sagredo.eu/files/qmail/patches/rcptcheck/rcptcheck-overlimit.sh chmod +x rcptcheck-overlimit.sh
Creare la cartella $OVERLIMIT
dove verrà tracciato il numero di messaggi inviati da un dato IP/auth-user, e assegnare pieni privilegiand all'utente che esegue qmail-smtpd
(vpopmail
nel nostro caso):
mkdir /var/qmail/overlimit chown -R vpopmail.vchkpw /var/qmail/overlimit chmod -R 755 /var/qmail/overlimit
creare il control file relaylimits
e modificarlo secondo le proprie necessità secondo le istruzioni di cui sopra:
touch /var/qmail/control/relaylimits cat > /var/qmail/control/relaylimits << __EOF__ :1000 __EOF__
Modificare poi i propri script qmail-smtpd/run
e qmail-submission/run
export RCPTCHECK=/var/qmail/bin/rcptcheck-overlimit.sh export RCPTCHECKRELAYCLIENT="1"
Preparare infine un cronjob per ripulire periodicamente i file in $OVERLIMITDIR
, per esempio:
0 3 * * * find /var/qmail/overlimit/ -type f -exec rm -f "{}" \; 1> /dev/null
E naturalmente ricordarsi di riavviare qmail
.
markasjunk skin not working
9 dicembre 2019 08:08
usage 2048 keys
8 dicembre 2019 14:06
chkuser
8 dicembre 2019 09:46
chkuser
7 dicembre 2019 23:10
usage 2048 keys
7 dicembre 2019 07:54
usage 2048 keys
7 dicembre 2019 05:33
usage 2048 keys
7 dicembre 2019 05:28
markasjunk skin not working
6 dicembre 2019 13:53
markasjunk skin not working
6 dicembre 2019 06:39
chkuser
4 dicembre 2019 01:34
Tags
apache clamav dkim dovecot ezmlm fail2ban ftp guide hacks lamp letsencrypt linux linux-vserver lxc mariadb mediawiki mozilla mysql owncloud patches php proftpd qmail qmailadmin rbl roundcube rsync sieve simscan slackware spamassassin ssh ssl tcprules tex ucspi-tcp vpopmail vqadmin