PDA

View Full Version : Piccoli problemi con mail-server


DigitalKiller
15-06-2006, 17:19
Ciao a tutti!
In ufficio ho configurato un mail-server con fetchmail, postifx, procmail, clamav, amavis, spamassassin, solid-pop3d. Funziona tutto correttamente, ma mancano solo 2 cose :D
Vorrei che i messaggi, sia in entrata che in uscita, filtrati da amavis venissero "marcati", cioè vorrei che venisse aggiunto un tag nell'header o eventualmente un commento nel corpo del messaggio. Nel file /etc/amavis/conf.d/20-debian_defaults c'è la direttiva:
$X_HEADER_TAG = 'X-Virus-Scanned';
ma questo tag non viene aggiunto.
Ultima cosa. Ho notato che le ricevute di ritorno delle emial, vengono considerate spam. Per evitare questo, devo dare in pasto a sa-learn il messaggio usando il flag --ham o devo fare qualcos'altro?
Grazie! :)

Pirulicchio
16-06-2006, 12:59
Intanto ti uppo perchè la cosa interessa anche a me poi aggiungo:
il mio problema è questo, vorrei che amavis quando trova un virus o spam mandi all'interessato una mail di avvertimento o cambi l'header con ****SPAM**** invece di mettere questi messaggi automaticamente nella cartella /var/lib/amavis/quarantine che inizialmente manco esisteva il file di configurazione dovrebbe essere questo

use strict;

# ADMINSTRATORS:
# Debian suggests that any changes you need to do that should never
# be "updated" by the Debian package should be made in another file,
# overriding the settings in this file.
#
# The package will *not* overwrite your settings, but by keeping
# them separate, you will make the task of merging changes on these
# configuration files much simpler...

# see /usr/share/doc/amavisd-new/examples/amavisd.conf-default for
# a list of all variables with their defaults;
# see /usr/share/doc/amavisd-new/examples/amavisd.conf-sample for
# a traditional-style commented file
# [note: the above files were not converted to Debian settings!]
#
# for more details see documentation in INSTALL, README_FILES/*
# and at http://www.ijs.si/software/amavisd/amavisd-new-docs.html


# COMMONLY ADJUSTED SETTINGS:

$QUARANTINEDIR = "$MYHOME/quarantine";

$log_recip_templ = undef; # disable by-recipient level-0 log entries
$DO_SYSLOG = 1; # log via syslogd (preferred)
$SYSLOG_LEVEL = 'mail.debug'; # switch to mail.info to drop debug output, etc

$enable_db = 1; # enable use of BerkeleyDB/libdb (SNMP and nanny)
$enable_global_cache = 1; # enable use of libdb-based cache if $enable_db=1

$inet_socket_port = 10024; # default listenting socket

$sa_spam_subject_tag = '***SPAM*** ';
$sa_tag_level_deflt = 2.0; # add spam info headers if at, or above that level
$sa_tag2_level_deflt = 6.31; # add 'spam detected' headers at that level
$sa_kill_level_deflt = 6.31; # triggers spam evasive actions
$sa_dsn_cutoff_level = 10; # spam level beyond which a DSN is not sent

$sa_mail_body_size_limit = 200*1024; # don't waste time on SA if mail is larger
$sa_local_tests_only = 0; # only tests which do not require internet access?

# Quota limits to avoid bombs (like 42.zip)

$MAXLEVELS = 14;
$MAXFILES = 1500;
$MIN_EXPANSION_QUOTA = 100*1024; # bytes
$MAX_EXPANSION_QUOTA = 300*1024*1024; # bytes

# OTHER MORE COMMON SETTINGS (defaults may suffice):

# You should:
# Use D_DISCARD to discard data (viruses)
# Use D_BOUNCE to generate local bounces by amavisd-new
# Use D_REJECT to generate local or remote bounces by the calling MTA
# Use D_PASS to deliver the message
#
# Whatever you do, *NEVER* use D_REJECT if you have other MTAs *forwarding*
# mail to your account. Use D_BOUNCE instead, otherwise you are delegating
# the bounce work to your friendly forwarders, which might not like it at all.
#
# On dual-MTA setups, one can often D_REJECT, as this just makes your own
# MTA generate the bounce message. Test it first.
#
# Bouncing viruses is stupid, always discard them after you are sure the AV
# is working correctly. Bouncing real SPAM is also useless, if you cannot
# D_REJECT it (and don't D_REJECT mail coming from your forwarders!).

$final_virus_destiny = D_DISCARD; # (data not lost, see virus quarantine)
$final_banned_destiny = D_REJECT; # D_REJECT when front-end MTA
$final_spam_destiny = D_BOUNCE;
$final_bad_header_destiny = D_PASS; # False-positive prone (for spam)

$virus_admin = "postmaster\@$mydomain"; # due to D_DISCARD default

# Leave empty (undef) to add no header
$X_HEADER_LINE = "Debian $myproduct_name at $mydomain";

# REMAINING IMPORTANT VARIABLES ARE LISTED HERE BECAUSE OF LONGER ASSIGNMENTS

#
# DO NOT SEND VIRUS NOTIFICATIONS TO OUTSIDE OF YOUR DOMAIN. EVER.
#
# These days, almost all viruses fake the envelope sender and mail headers.
# Therefore, "virus notifications" became nothing but undesired, aggravating
# SPAM. This holds true even inside one's domain.
#

@viruses_that_fake_sender_maps = (new_RE(
[qr'\bEICAR\b'i => 0], # av test pattern name
[qr/.*/ => 1], # true for everything else
));

@keep_decoded_original_maps = (new_RE(
# qr'^MAIL$', # retain full original message for virus checking (can be slow)
qr'^MAIL-UNDECIPHERABLE$', # recheck full mail if it contains undecipherables
qr'^(ASCII(?! cpio)|text|uuencoded|xxencoded|binhex)'i,
# qr'^Zip archive data', # don't trust Archive::Zip
));


# for $banned_namepath_re, a new-style of banned table, see amavisd.conf-sample

$banned_filename_re = new_RE(
# qr'^UNDECIPHERABLE$', # is or contains any undecipherable components

# block certain double extensions anywhere in the base name
qr'\.[^./]*\.(exe|vbs|pif|scr|bat|cmd|com|cpl|dll)\.?$'i,

qr'\{[0-9a-z]{4,}(-[0-9a-z]{4,}){0,7}\}?'i, # Windows Class ID ext. - CLSID)

qr'^application/x-msdownload$'i, # block these MIME types
qr'^application/x-msdos-program$'i,
qr'^application/hta$'i,

# qr'^message/partial$'i, qr'^message/external-body$'i, # rfc2046 MIME types

# [ qr'^\.(Z|gz|bz2)$' => 0 ], # allow any in Unix-compressed
# [ qr'^\.(rpm|cpio|tar)$' => 0 ], # allow any in Unix-type archives
# [ qr'^\.(zip|rar|arc|arj|zoo)$'=> 0 ], # allow any within such archives

qr'.\.(exe|vbs|pif|scr|bat|cmd|com|cpl)$'i, # banned extension - basic
# qr'.\.(ade|adp|app|bas|bat|chm|cmd|com|cpl|crt|emf|exe|fxp|grp|hlp|hta|
# inf|ins|isp|js|jse|lnk|mda|mdb|mde|mdw|mdt|mdz|msc|msi|msp|mst|
# ops|pcd|pif|prg|reg|scr|sct|shb|shs|vb|vbe|vbs|
# wmf|wsc|wsf|wsh)$'ix, # banned ext - long

# qr'.\.(mim|b64|bhx|hqx|xxe|uu|uue)$'i, # banned extension - WinZip vulnerab.

qr'^\.(exe-ms)$', # banned file(1) types
# qr'^\.(exe|lha|tnef|cab|dll)$', # banned file(1) types
);
# See http://support.microsoft.com/default.aspx?scid=kb;EN-US;q262631
# and http://www.cknow.com/vtutor/vtextensions.htm


# ENVELOPE SENDER SOFT-WHITELISTING / SOFT-BLACKLISTING

@score_sender_maps = ({ # a by-recipient hash lookup table,
# results from all matching recipient tables are summed

# ## per-recipient personal tables (NOTE: positive: black, negative: white)
# '[email protected]' => [{'[email protected]' => 10.0}],
# '[email protected]' => [{'.ebay.com' => -3.0}],
# '[email protected]' => [{'[email protected]' => -7.0,
# '.cleargreen.com' => -5.0}],

## site-wide opinions about senders (the '.' matches any recipient)
'.' => [ # the _first_ matching sender determines the score boost

new_RE( # regexp-type lookup table, just happens to be all soft-blacklist
[qr'^(bulkmail|offers|cheapbenefits|earnmoney|foryou)@'i => 5.0],
[qr'^(greatcasino|investments|lose_weight_today|market\.alert)@'i=> 5.0],
[qr'^(money2you|MyGreenCard|new\.tld\.registry|opt-out|opt-in)@'i=> 5.0],
[qr'^(optin|saveonlsmoking2002k|specialoffer|specialoffers)@'i => 5.0],
[qr'^(stockalert|stopsnoring|wantsome|workathome|yesitsfree)@'i => 5.0],
[qr'^(your_friend|greatoffers)@'i => 5.0],
[qr'^(inkjetplanet|marketopt|MakeMoney)\d*@'i => 5.0],
),

# read_hash("/var/amavis/sender_scores_sitewide"),

{ # a hash-type lookup table (associative array)
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]'=> -3.0,
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]' => -3.0,
'[email protected]' => -5.0,
'[email protected]' => -3.0,
'returns.groups.yahoo.com' => -3.0,
'[email protected]' => -3.0,
lc('[email protected]') => -3.0,
lc('[email protected]') => -5.0,

# soft-blacklisting (positive score)
'[email protected]' => 3.0,
'.example.net' => 1.0,

},
], # end of site-wide tables
});

1; # insure a defined return


Sembra quasi che questo file non venga minimamente considerato già dalle prime righe infatti $QUARANTINEDIR = "$MYHOME/quarantine" invece, /var/lib/amavis/quarantine, forse sbaglio , ma pare prorpio così. Inoltre tante guide fanno riferimento al file amavisd.conf, ma questo non esiste, i file di configurazione sono più di uno e stanno dentro /etc/amavis/conf.d/*. Dist che uso ubuntu con istallazione server.
Ciao....

DigitalKiller
16-06-2006, 14:55
il mio problema è questo, vorrei che amavis quando trova un virus o spam mandi all'interessato una mail di avvertimento o cambi l'header con ****SPAM**** invece di mettere questi messaggi automaticamente nella cartella /var/lib/amavis/quarantine che inizialmente manco esisteva il file di configurazione dovrebbe essere questo

Potresti disattivare il controllo dello spam di amavis, installare spamassassin e configurarlo in modo tale che venga riscritto l'oggetto della mail in caso di spam e, tramite procmail, consegnare ugualmente lo spam all'utente.
Per quanto riguarda invece l'avviso di ricezione di mail infette, basta configurare il file /etc/amavis/conf.d/20-debian_defaults, in modo che l'utente postmaster riceva l'avviso. La riga interessata è questa:
$virus_admin = "postmaster\@$mydomain"; # due to D_DISCARD default

Pirulicchio
16-06-2006, 19:42
Grazie per il tuo aiuto, ma preferirei non usare procmail una cosa in meno da configurare, mi pare quasi impossibile che non si possa fare con amavis, allora che senso ha $sa_spam_subject_tag = '***SPAM*** '; ma poi amavis non si appoggia a /etc/spamassassin/local.cf dove io gli ho detto di cambiare l'header se trova spam bo????
Per ora ho in parte risolto:

$final_virus_destiny = D_REJECT; # (data not lost, see virus quarantine)
$final_banned_destiny = D_REJECT; # D_REJECT when front-end MTA
$final_spam_destiny = D_REJECT;
$final_bad_header_destiny = D_PASS; # False-positive prone (for spam)

in modo che arrivi una mail di avviso all'utente che ha spedito spam o virus, e come hai consigliato tu a postmaster, ma non sono contento, credevo che D_BOUNCE facesse quello che volevo ma niente.
Ciao.........

#!/bin/sh
17-06-2006, 15:14
Grazie per il tuo aiuto, ma preferirei non usare procmail una cosa in meno da configurare, mi pare quasi impossibile che non si possa fare con amavis, allora che senso ha $sa_spam_subject_tag = '***SPAM*** '; ma poi amavis non si appoggia a /etc/spamassassin/local.cf dove io gli ho detto di cambiare l'header se trova spam bo????


Amavisd-new in parte ignora quello che viene messo nel file di configurazione di spamassassin. Adesso non ho sottomano il file di configurazione di amavisd-new che ho al lavoro, ma solo quello di default. Per abilitare il rewrite dell'oggetto dell'email devi mettere la direttiva:

$sa_spam_modifies_subj = 1;

Da notare che amavisd-new in questo modo con la configurazione di default se la mail totalizza un punteggio compreso tra le due soglie la fa passare con il soggetto cambiato, ma con il body inalterato a meno che non abiliti il defang delle mail. Se vuoi che vengano aggiunti anche gli header che indicano il punteggio devi attivare le direttive:

$sa_spam_level_char = '*';
$sa_spam_report_header = 0;

Io poi disattivo anche l'autowhitelist, che mi ha creato solo problemi:

$sa_auto_whitelist = 0;

Se ti scarichi il sorgente cmq c'e' il file (amavisd.conf-example) con tutta la configurazione.

e-Tip
17-06-2006, 23:12
per lo spam...
$sa_kill_level_deflt = 6.31; # triggers spam evasive actions
aumenta questa ad un numero tendente ad infinito e tutte le mail saranno taggate come spam e non quarantinate
(

Pirulicchio
20-06-2006, 17:09
Ho fatto varie prove aggiungendo le voci consigliate da #!/bin/sh ed altro ora la parte per lo spam si presenta in questo modo:

$sa_spam_subject_tag = '***SPAM*** ';
$sa_spam_modifies_subj = 1;
$sa_spam_level_char = '*';
$sa_spam_report_header = 1;
$sa_auto_whitelist = 0;

@spam_modifies_subj_maps= (\$sa_spam_modifies_subj);
@spam_subject_tag_maps = (\$sa_spam_modifies_subj); # N.B.: inconsistent name
@spam_subject_tag2_maps = (\$sa_spam_modifies_subj); # N.B.: inconsistent name
#@spam_subject_tag3_maps = (\$sa_spam_modifies_subj);

$sa_tag_level_deflt = 2.0; # add spam info headers if at, or above that level
$sa_tag2_level_deflt = 6.31; # add 'spam detected' headers at that level
$sa_kill_level_deflt = 6.31; # triggers spam evasive actions

$sa_dsn_cutoff_level = 10; # spam level beyond which a DSN is not sent
#$sa_quarantine_cutoff_level = 70;
$sa_mail_body_size_limit = 200*1024; # don't waste time on SA if mail is larger
$sa_local_tests_only = 0; # only tests which do not require internet access?
inoltre ho deciso di mette:
$final_spam_destiny = D_PASS;
per far passare lo spam, è un pò come mettere $sa_kill_level_deflt a un livello altissimo, con un piccolo inconveniente viene fatta una copia della mail con i vari punteggi headers etc... nella cartella quarantine se fosse possibile evitare, comunque tornado a noi, il problemone :muro: è che non viene assolutamente modificato l'oggetto della mail, io vorrei che venisse ***SPAM*** per poi smistarlo in una cartella apposita, grazie ancora per l'aiuto.
Ciao......

#!/bin/sh
22-06-2006, 09:34
Ho notato che metteva anche e me le mail in quarantena. Per disabilitare la quarantena dello spam occorre mettere:

$spam_quarantine_to = '';

e cioè settare a '' oppure a undef undef il valore di $spam_quarantine_to.

DigitalKiller
22-06-2006, 10:25
Ho notato che metteva anche e me le mail in quarantena. Per disabilitare la quarantena dello spam occorre mettere:

$spam_quarantine_to = '';

e cioè settare a '' oppure a undef undef il valore di $spam_quarantine_to.

In quale file sta questa direttiva? Non sono riuscito a trovarla :(

Per quanto riguarda l'inserimento del tag del controllo virus nell'header dell'email, nessuno ne sa niente?

#!/bin/sh
22-06-2006, 10:40
la devi mettere nel file amavisd.conf. Quale file hai usato? Non hai modificato quello di default?

DigitalKiller
22-06-2006, 11:02
la devi mettere nel file amavisd.conf. Quale file hai usato? Non hai modificato quello di default?
Evidentemente abbiamo distribuzioni o versioni diverse :(
Io utilizzo debian etch con amavis 2.4 (se non sbaglio) e del file /etc/amavis.conf non c'è neppure l'ombra :D

#!/bin/sh
22-06-2006, 20:25
probabilmente su debian hanno cambiato la posizione e il nome del file di configurazione. io uso gentoo che installa il file standard con qualche modifica. come ho detto qualche post sopra il file di configurazione di default lo trovi nel tarball del sorgente di amavisd-new. io ho modificato quello e sono andato molto bene. tra l'altro è molto ben commentato.

DigitalKiller
22-06-2006, 22:20
probabilmente su debian hanno cambiato la posizione e il nome del file di configurazione. io uso gentoo che installa il file standard con qualche modifica. come ho detto qualche post sopra il file di configurazione di default lo trovi nel tarball del sorgente di amavisd-new. io ho modificato quello e sono andato molto bene. tra l'altro è molto ben commentato.

Da quello che ho cambito, per debian è cambiata completamente la struttura del file di configurazione.
Il file /etc/amavis.conf originale infatti è suddiviso in sezioni e ggli sviluppatori di debian hanno creato un file per ogni sezione.
Ho fatto una ricerca della direttiva in ogni file, ma non sono riuscito a trovarla. Domani faccio un tentativo ad aggiungerla

#!/bin/sh
22-06-2006, 23:13
quella direttiva setta una variabile. dovrebbe essere indifferente il punto in cui la metti.