Modalità di lettura

Plugins per Roundcube

Changelog

  • Apr 27, 2026
    - qmailforward upgraded to v1.0.5 (bug fix: sql call is not done if the forward is not a valid email address)
  • Dec 19, 2025
    - composer is now installed in /usr/local/bin and not in RC dir
  • Apr 19, 2025
    - sauserprefs aggiornato alla versione 1.20.2
  • 23 marzo 2025
    - il driver vpopmaild del plugin password è nuovamente funzionante, ora che il problema è stato sistemato dal lato vpopmail (versione 5.6.7 in poi).

 

  •  

MariaDB replica setup

MariaDB uses asynchronous replication based on binary logs (binlog). Master (source) writes changes to the binary log, slave (replica) reads the binlog from the master and replays events locally. Replication is one-way by default (master to slave).

Master configuration

Configure MariaDB by editing /etc/my.cnf.d/mariadb-server.cnf

[mysqld]
server-id=1
log_bin=binlog
binlog_format=ROW
bind-address = 0.0.0.0

bind-address = 0.0.0.0 assures that the server is accessible from the outnet. Check with netstat

netstat -plunt|grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      417359/mariadbd

Restart MariaDB, then check the binary log file name and the binary log position:

MariaDB [(none)]> SHOW MASTER STATUS;  
+---------------+----------+--------------+------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+---------------+----------+--------------+------------------+
| binlog.000001 |    14446 |              |                  |
+---------------+----------+--------------+------------------+
1 row in set (0.000 sec)

Create the user for the replication from the slave:

CREATE USER 'replica'@'SlaveIP%' IDENTIFIED BY 'password';
GRANT REPLICATION SLAVE ON *.* TO 'replica'@'SlaveIP';
FLUSH PRIVILEGES;

Dump the databases you want to backup (vpopmail, roundcubemail and spamassassin in my example):

mysqldump -u root -p --databases vpopmail roundcubemail spamassassin --single-transaction --master-data=2 > dump.sql

Slave configuration

Prepare the server by editing /etc/my.cnf.d/mariadb-server.cnf. Assign a unique id:

# replica 
server-id=2       # unique id
log_bin=binlog    # to revert master - slave 
read_only=ON      # cannot alter the database
# databases to replicate (it will read only these db from log)
replicate-do-db=vpopmail
replicate-do-db=roundcubemail
replicate-do-db=spamassassin

Log into MariaDB, stop the current slave (if it exists) and drop the databases to be cloned;

STOP SLAVE;
RESET SLAVE ALL;
DROP DATABASE IF EXISTS vpopmail;
DROP DATABASE IF EXISTS spamassassin;
DROP DATABASE IF EXISTS roundcubemail;

Use scp to copy the dump you have done earlier (here I am connecting via secure key):

scp -i '/root/.ssh/ed25519' root@MasterIP:/root/dump.sql .

Import the dump:

mysql -u root -p < dump.sql

Open the dump.sql file and identify the line holding the log file and the log position:

-- CHANGE MASTER TO MASTER_LOG_FILE='binlog.000001', MASTER_LOG_POS=65327;

The same thing can be achieved by using grep

grep "CHANGE MASTER TO" dump.sql      
-- CHANGE MASTER TO MASTER_LOG_FILE='binlog.000001', MASTER_LOG_POS=65327;

Enter the slave server and configure the master:

CHANGE MASTER TO MASTER_HOST='MasterIP', MASTER_USER='replica', MASTER_PASSWORD='replicaPWD', MASTER_LOG_FILE='binlog.000001', MASTER_LOG_POS=65327;

Then start the slave on MariaDB and verify its status:

MariaDB [(none)]> START SLAVE; 
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                 Master_Host: MasterIP
                  Master_User: replica
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: binlog.000001
          Read_Master_Log_Pos: 719355
               Relay_Log_File: mariadb-relay-bin.000003
                Relay_Log_Pos: 357109
        Relay_Master_Log_File: binlog.000001
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:  
          Replicate_Ignore_DB:  
           Replicate_Do_Table:  
       Replicate_Ignore_Table:  
      Replicate_Wild_Do_Table:  
  Replicate_Wild_Ignore_Table:  
                   Last_Errno: 0
                   Last_Error:  
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 719355
              Relay_Log_Space: 357420
              Until_Condition: None
               Until_Log_File:  
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:  
           Master_SSL_CA_Path:  
              Master_SSL_Cert:  
            Master_SSL_Cipher:  
               Master_SSL_Key:  
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:  
               Last_SQL_Errno: 0
               Last_SQL_Error:  
  Replicate_Ignore_Server_Ids:  
             Master_Server_Id: 1
               Master_SSL_Crl:  
           Master_SSL_Crlpath:  
                   Using_Gtid: No
                  Gtid_IO_Pos:  
      Replicate_Do_Domain_Ids:  
  Replicate_Ignore_Domain_Ids:  
                Parallel_Mode: optimistic
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
             Slave_DDL_Groups: 0
Slave_Non_Transactional_Groups: 90
   Slave_Transactional_Groups: 980
         Replicate_Rewrite_DB:  
1 row in set (0.000 sec)

If Slave_IO_Running: Yes and Slave_SQL_Running: Yes it's ok. Seconds_Behind_Master inform us if the server is aligned.

You can insert data into Master and check if they are replicated no Slave.

Promoting the backup server to production

Connect to mariadb from command line and check the slave status and that the slave is synced with master (Seconds_Behind_Master: 0):

SHOW SLAVE STATUS\G

Check that:

Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Seconds_Behind_Master: 0

If slave is perfectly synced with master stop the replica

STOP SLAVE;
RESET SLAVE ALL;

Set the mariadb server writable

SET GLOBAL read_only=OFF;

Exit from MariaDB command line and modify the config file so that read_only is commented out.

[mysqld] 
# replica 
server-id=2 
log_bin=binlog 
#read_only=ON 
replicate-do-db=vpopmail 
replicate-do-db=roundcubemail

Restart the server. Now the database server is in production.

  •  

Spamassassin TxRep Reputation plugin e filtro Bayesiano (SQL)

TxRep was designed as an enhanced replacement of the AutoWhitelist plugin. TxRep, just like AWL, tracks scores of messages previously received, and adjusts the current message score, either by boosting messages from senders who send ham or penalizing senders who have sent spam previously. This not only treats some senders as if they were whitelisted but also treats spammers as if they were blacklisted. Each message from a particular sender adjusts the historical total score which can change them from a spammer if they send non-spam messages. Senders who are considered non-spammers can become treated as spammers if they send messages which appear to be spam. Simpler told TxRep is a score averaging system. It keeps track of the historical average of a sender, and pushes any subsequent mail towards that average.

The Bayesian classifier in Spamassassin tries to identify spam by looking at what are called tokens; words or short character sequences that are commonly found in spam or ham. If I've handed 100 messages to sa-learn that have the phrase penis enlargement and told it that those are all spam, when the 101st message comes in with the words penis and enlargment, the Bayesian classifier will be pretty sure that the new message is spam and will increase the spam score of that message.

In pratica Bayes è un classificatore statistico: guarda i token (parole, header, URL, ecc.) e calcola la probabilità che il messaggio sia spam senza interessarsi di chi manda, ma solo del contenuto.

Invece TxRep tiene traccia della reputazione del mittente (indirizzo email + IP).


Changelog

  • 18 agosto 2025: aggiunte parecchie informazioni alla sezione "Addestramento del sistema bayesiano"

  •  
❌