Servizio ODMR / ATRN: Difference between revisions

From RVM Wiki
Jump to navigation Jump to search
Aggiunta sezione upgrade e parametrizzata installazione.
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category: Postfix]]
= SERVER: =
= SERVER: =


Line 37: Line 38:


== Installazione Demone odmrd ==
== Installazione Demone odmrd ==
Controllare la versione disponibile su http://plonk.de/sw/odmr, cambiare il valore della variabile VERSION nello script seguente:


<pre>  
<pre>
export VERSION=09rc9 && \
cd /files/src && \
cd /files/src && \
wget http://plonk.de/sw/odmr/odmrd09rc6.tar.gz && \
wget http://plonk.de/sw/odmr/odmrd$VERSION.tar.gz && \
mkdir odmrd09rc6 && \
mkdir odmrd && \
cd odmrd09rc6 && \
cd odmrd && \
tar xvzf ../odmrd09rc6.tar.gz && \
tar xvzf ../odmrd$VERSION.tar.gz && \
cp odmrd-09rc6.pl /root/bin/odmrd && \
cp odmrd-$VERSION.pl /root/bin/odmrd && \
chmod 755 /root/bin/odmrd \
chmod 755 /root/bin/odmrd \
cp odmrd.conf /etc && \
cp odmrd.conf /etc && \
Line 100: Line 103:


Riavvio inetd e verifica ascolto demone:
Riavvio inetd e verifica ascolto demone:
<pre>
/etc/init.d/inetd restart


/etc/init.d/inetd restart
netstat -anp | grep 366
 
tcp        0      0 0.0.0.0:366            0.0.0.0:*              LISTEN      13635/inetd
netstat -anp | grep 366
</pre>
tcp        0      0 0.0.0.0:366            0.0.0.0:*              LISTEN      13635/inetd
 


== Verifica risposta demone odmr ==
== Verifica risposta demone odmr ==
Line 220: Line 223:
</pre>
</pre>


Se ci sono email in coda per una precedente configurazione come relay, flushare la coda, cosicchè verranno messe in odmr:
postqueue -f
postqueue -p
== Aggiornamento di odmrd ==
Per aggiornare il pacchetto invece di installarlo, controllare la versione disponibile su http://plonk.de/sw/odmr.
<pre>
export VERSION=09rc9 && \
cd /files/src && \
/bin/rm -rf odmrd* && \
wget http://plonk.de/sw/odmr/odmrd$VERSION.tar.gz && \
mkdir odmrd && \
cd odmrd && \
tar xvzf ../odmrd$VERSION.tar.gz && \
/bin/cp -f odmrd-$VERSION.pl /root/bin/odmrd && \
chmod 755 /root/bin/odmrd && \
wget http://plonk.de/sw/odmr/odmrspool.pl && \
/bin/cp -f odmrspool.pl /root/bin && \
chmod 755 /root/bin/odmrspool.pl && \
cd .. && \
rm -rf odmr* && \
echo UPGRADE DONE !
</pre>
Controllare poi che versione risulta installata:
cat /root/bin/odmrd | grep 'my $prognam' | cut -f2 --delim='"'
Non è necessario riavviare postfix o inetd.


= CLIENT =
= CLIENT =

Latest revision as of 12:47, 17 June 2005

SERVER:

Creazione database

mysql -p <<EOFile
drop database odmr;
create database odmr;
use odmr;

CREATE TABLE acct (
  user varchar(30) NOT NULL default '',
  date int(10) unsigned NOT NULL default '0',
  b_in int(10) unsigned NOT NULL default '0',
  b_out int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (user,date)
) TYPE=MyISAM;

CREATE TABLE domain (
  domain varchar(64) NOT NULL default '',
  user varchar(30) NOT NULL default '',
  PRIMARY KEY  (domain),
  KEY user (user)
) TYPE=MyISAM;

INSERT INTO domain VALUES ('marzottospa.com', 'marzottospa.com');

CREATE TABLE user (
  user varchar(30) NOT NULL default '',
  pass varchar(15) NOT NULL default '',
  PRIMARY KEY  (user)
) TYPE=MyISAM;

INSERT INTO user VALUES ('marzottospa.com', 'ottozram');
EOFile


Installazione Demone odmrd

Controllare la versione disponibile su http://plonk.de/sw/odmr, cambiare il valore della variabile VERSION nello script seguente:

export VERSION=09rc9 && \
cd /files/src && \
wget http://plonk.de/sw/odmr/odmrd$VERSION.tar.gz && \
mkdir odmrd && \
cd odmrd && \
tar xvzf ../odmrd$VERSION.tar.gz && \
cp odmrd-$VERSION.pl /root/bin/odmrd && \
chmod 755 /root/bin/odmrd \
cp odmrd.conf /etc && \
wget http://plonk.de/sw/odmr/odmrspool.pl && \
cp odmrspool.pl /root/bin && \
chmod 755 /root/bin/odmrspool.pl && \
cd .. && \
rm -rf odmr* && \
adduser --system odmr && \
addgroup --system odmr && \
echo SETUP DONE !


Attivazione demone in inetd

vi /etc/inetd.conf:
...
odmr      stream  tcp     nowait  odmr    /root/bin/odmrd  odmrd
...

Definizione servizio odmr in services

vi /etc/services:
...
odmr            366/tcp                         # On Demand Mail Relay Protocol
...


Modifica configurazione demone odmrd

vi /etc/odmrd.conf
...
debug 1
mysql_user root
# nome utente mysql per accesso al database odmr
mysql_pass thepass
# password utente mysql
standalone 0
...


Creazione directory di spool odmr

mkdir -p /var/spool/odmr && \
chown odmr:odmr /var/spool/odmr 


Installazione librerie Perl necessarie

apt-get install libdigest-hmac-perl


Riavvio inetd e verifica ascolto demone:

/etc/init.d/inetd restart

netstat -anp | grep 366
tcp        0      0 0.0.0.0:366             0.0.0.0:*               LISTEN      13635/inetd

Verifica risposta demone odmr

telnet localhost 366
Trying 127.0.0.1...
Connected to qda.
Escape character is '^]'.
220 qda odmrd v0.9rc6 ODMR service ready
quit
221 have a nice day
Connection closed by foreign host.


Verifica autenticazione con fetchmail

apt-get install fetchmail
fetchmail --proto odmr --fetchdomains marzottospa.com --verbose --username marzottospa.com localhost
Enter password for marzottospa.com@localhost:

fetchmail: 5.9.11 querying localhost (protocol ODMR) at Mon Apr  4 16:42:28 2005: poll started
fetchmail: SMTP< 220 qda odmrd v0.9rc6 ODMR service ready
fetchmail: SMTP> EHLO localhost
fetchmail: SMTP< 250-qda Hello qda [127.0.0.1:54143]
fetchmail: SMTP< 250-AUTH CRAM-MD5
fetchmail: SMTP< 250 ATRN
fetchmail: ODMR> AUTH CRAM-MD5
fetchmail: ODMR< 334 PDE2NzkuNjc3Mjk2Njk4MzMuNTQ1MC4xMTEyNjI1NzQ4QHFkYT4=
fetchmail: ODMR> bWFyem90dG9zcGEuY29tIDJiNjhlMTY2YmFiZjE1Y2FhZTA1ZTVmODAyOWQ5NjU2
fetchmail: SMTP< 235 authenticated marzottospa.com
fetchmail: ODMR> ATRN marzottospa.com
fetchmail: ODMR< 453 no mail waiting
fetchmail: You have no mail.
fetchmail: ODMR> QUIT
fetchmail: SMTP< 221 have a nice day
fetchmail: 5.9.11 querying localhost (protocol ODMR) at Mon Apr  4 16:42:28 2005: poll completed
fetchmail: normal termination, status 0


Abilitazione trasporto odmr in Postfix

vi /etc/postfix/master.cf
...
odmr     unix  -       n       n       -       -       pipe
       flags=h. user=odmr:odmr eol=\r\n argv=/root/bin/odmrspool.pl -f ${sender} -t ${nexthop}  ${recipient}
...


Definizione domini da gestire in odmr in postfix

vi /etc/postfix/transport
...
marzottospa.com         odmr:
...

ATTENZIONE: BISOGNA CHE CI SIA UN UTENTE CON DOMINIO LEMAN.IT INSERITO NEL DATABASE POSTFIX, CHE NON ABBIA I FLAG EMAIL E ALIAS ATTIVATI, E CHE ABBIA ATTIVATO IL FLAG DI RELAY

Compilazione transport map

postmap /etc/postfix/transport
/etc/init.d/postfix restart


Provare mandare una email di prova a localhost:

 telnet localhost 25
Trying 127.0.0.1...
Connected to qda.
Escape character is '^]'.
220 fire.qdatainformatica.com ESMTP Postfix (Debian/GNU)
helo p
250 fire.qdatainformatica.com
mail from: gabriele@rvmgroup.it
250 Ok
rcpt to: ennio.lore@leman.it
250 Ok
data
354 End data with <CR><LF>.<CR><LF>
subject: test 1123

test1123
.
250 Ok: queued as C552B104442
quit
221 Bye
Connection closed by foreign host.
tail /var/log/mail.log | grep odmr
May 23 11:23:33 fire postfix/pipe[14085]: ED82E105013: to=<ennio.lore@leman.it>, relay=odmr, delay=3, status=sent (leman.it)


Verificare che ci sia la mail in spool

ls /var/spool/odmr/leman.it/
total 12
drwx------    2 odmr     odmr         4096 May 23 11:23 .
drwxr-xr-x    4 odmr     odmr         4096 May 23 11:23 ..
-rw-------    1 odmr     odmr          936 May 23 11:23 msg.1116840213.14086.5600


Se ci sono email in coda per una precedente configurazione come relay, flushare la coda, cosicchè verranno messe in odmr:

postqueue -f
postqueue -p


Aggiornamento di odmrd

Per aggiornare il pacchetto invece di installarlo, controllare la versione disponibile su http://plonk.de/sw/odmr.

export VERSION=09rc9 && \
cd /files/src && \
/bin/rm -rf odmrd* && \
wget http://plonk.de/sw/odmr/odmrd$VERSION.tar.gz && \
mkdir odmrd && \
cd odmrd && \
tar xvzf ../odmrd$VERSION.tar.gz && \
/bin/cp -f odmrd-$VERSION.pl /root/bin/odmrd && \
chmod 755 /root/bin/odmrd && \
wget http://plonk.de/sw/odmr/odmrspool.pl && \
/bin/cp -f odmrspool.pl /root/bin && \
chmod 755 /root/bin/odmrspool.pl && \
cd .. && \
rm -rf odmr* && \
echo UPGRADE DONE !

Controllare poi che versione risulta installata:

cat /root/bin/odmrd | grep 'my $prognam' | cut -f2 --delim='"'

Non è necessario riavviare postfix o inetd.

CLIENT

Installare fetchmail

apt-get install fetchmail

Da server destinazione prendere posta:

fetchmail --proto odmr --fetchdomains leman.it  --verbose --username leman.it fire.qdatainformatica.com
Enter password for leman.it@fire.qdatainformatica.com:

fetchmail: 6.2.5 querying fire.qdatainformatica.com (protocol ODMR) at Mon 23 Ma                                   y 2005 11:53:48 AM CEST: poll started
fetchmail: SMTP< 220 fire.qdatainformatica.com odmrd v0.9rc6 ODMR service ready
fetchmail: SMTP> EHLO localhost
fetchmail: SMTP< 250-fire.qdatainformatica.com Hello ppp-191-17.24-151.libero.it                                    [151.24.17.191:10200]
fetchmail: SMTP< 250-AUTH CRAM-MD5
fetchmail: SMTP< 250 ATRN
fetchmail: ODMR> AUTH CRAM-MD5
fetchmail: ODMR< 334 PDU3NTIuMTYzNjQwMDgyMTIuMTQzODUuMTExNjg0MjAyNEBmaXJlLnFkYXR                                   haW5mb3JtYXRpY2EuY29tPg==
fetchmail: ODMR> bGVtYW4uaXQgOTE5M2M5YjM1ZjgxOGQ5MzBlNjVkMzFhOTJlYzFkMzg=
fetchmail: SMTP< 235 authenticated leman.it
fetchmail: ODMR> ATRN leman.it
fetchmail: ODMR< 250 ok, turnaround now
fetchmail: Turnaround now...
fetchmail: ODMR> 220 fire.leman.priv ESMTP Postfix (Debian/GNU)
fetchmail: ODMR< EHLO fire.qdatainformatica.com
fetchmail: ODMR> 250-fire.leman.priv
fetchmail: ODMR> 250-PIPELINING
fetchmail: ODMR> 250-SIZE 10240000
fetchmail: ODMR> 250-VRFY
fetchmail: ODMR> 250-ETRN
fetchmail: ODMR> 250-AUTH NTLM LOGIN PLAIN DIGEST-MD5 CRAM-MD5
fetchmail: ODMR> 250-AUTH=NTLM LOGIN PLAIN DIGEST-MD5 CRAM-MD5
fetchmail: ODMR> 250 8BITMIME
fetchmail: ODMR< MAIL FROM:<gabriele@rvmgroup.it> SIZE=936
fetchmail: ODMR> 250 Ok
fetchmail: ODMR< RCPT TO: <ennio.lore@leman.it>
fetchmail: ODMR> 250 Ok
fetchmail: ODMR< DATA
fetchmail: ODMR> 354 End data with <CR><LF>.<CR><LF>
fetchmail: receiving message data
fetchmail: ODMR> 250 Ok: queued as 2EF8F6401B7
fetchmail: ODMR< RSET
fetchmail: ODMR> 250 Ok
fetchmail: ODMR< QUIT
fetchmail: ODMR> 221 Bye
fetchmail: Polling fire.qdatainformatica.com
fetchmail: 6.2.5 querying fire.qdatainformatica.com (protocol ODMR) at Mon 23 Ma                                   y 2005 11:53:50 AM CEST: poll completed
fetchmail: normal termination, status 0

Creazione file configurazione fetchmailrc

cat > /etc/fetchmailrc <<EOFile
set daemon 600
poll fire.qdatainformatica.com with protocol odmr
        user leman.it with pass namel
        fetchdomains leman.it
        smtphost 127.0.0.1
EOFile

Debug di fetchmail

/etc/init.d/fetchmail debug-run
/etc/init.d/fetchmail: Initiating debug run of system-wide fetchmail service...
/etc/init.d/fetchmail: script will be run in debug mode, all output to forced to
/etc/init.d/fetchmail: stdout. This is not enough to debug failures that only
/etc/init.d/fetchmail: happen in daemon mode.
/etc/init.d/fetchmail: You might want to direct output to a file, and tail -f it.
/etc/init.d/fetchmail: Stopping the service...
Stopping mail retrieval agent: fetchmail.
/etc/init.d/fetchmail: exit status of service stop was: 0
/etc/init.d/fetchmail: RUNUSER is fetchmail
/etc/init.d/fetchmail: OPTIONS would be -f /etc/fetchmailrc --syslog -i /var/mail/.fetchmail-UIDL-cache
/etc/init.d/fetchmail: Starting service in nodetach mode, hit ^C (SIGINT/intr) to finish run...
fetchmail: starting fetchmail 6.2.5 daemon
fetchmail: 6.2.5 querying fire.qdatainformatica.com (protocol ODMR) at Mon 23 May 2005 12:04:36 PM CEST: poll started
fetchmail: SMTP< 220 fire.qdatainformatica.com odmrd v0.9rc6 ODMR service ready
fetchmail: selecting or re-polling default folder
fetchmail: SMTP> EHLO fire.leman.priv
fetchmail: SMTP< 250-fire.qdatainformatica.com Hello ppp-191-17.24-151.libero.it [151.24.17.191:10207]
fetchmail: SMTP< 250-AUTH CRAM-MD5
fetchmail: SMTP< 250 ATRN
fetchmail: ODMR> AUTH CRAM-MD5
fetchmail: ODMR< 334 PDgwNjcuMTI3NjU5ODU3NTEuMTQ0OTAuMTExNjg0MjY3MkBmaXJlLnFkYXRhaW5mb3JtYXRpY2EuY29tPg==
fetchmail: decoded as <8067.12765985751.14490.1116842672@fire.qdatainformatica.com>
fetchmail: ODMR> bGVtYW4uaXQgOWIyNjE2MDg5NGE5OTJiOTA2MDAwMzQxMGRjODFiNTA=
fetchmail: SMTP< 235 authenticated leman.it
fetchmail: ODMR> ATRN leman.it
fetchmail: ODMR< 453 no mail waiting
fetchmail: You have no mail.
fetchmail: ODMR> QUIT
fetchmail: SMTP< 221 have a nice day
fetchmail: 6.2.5 querying fire.qdatainformatica.com (protocol ODMR) at Mon 23 May 2005 12:04:37 PM CEST: poll completed
fetchmail: not swapping UID lists, no UIDs seen this query
fetchmail: Deleting fetchids file.
fetchmail: sleeping at Mon 23 May 2005 12:04:37 PM CEST

Abilitazione fetchmail ogni "set daemon" secondi

/etc/init.d/fetchmail start