This is a small HOWTO about doing source routing with Squid and Linux. With Squid you can specifiy the outgoing IP address using ACLs. That means that you can select the outgoing IP using the information inside HTTP messages, thing that you can’t do with a firewall. The syntax is simple:


acl somedomain dstdomain somedomain.com
tcp_outgoing_address 1.2.3.4 somedomain

Those two lines say: “If the request is asking for somedomain.com, go to the world using IP 1.2.3.4″.

Now the Linux part. If you have more than one public IP address and you want to make the Squid configuration to work you need some iproute lines.


ip rule add table 10 from 1.2.3.4
ip route add table 10 default via GW

And those two lines says: “If the source IP of the packaet is 1.2.3.4, go via GW”.

Source routing with Linux is simple. What you do is to create a new table. This table will be used by that packets that match the criteria specified in “ip rule”. The “default table” is the table main, everything goes there if there is no rule. Is the table that you see with “ip route” or “route -n” (please, don’t use the last command anymore).

 

Post to Twitter

 

I documented the procedure in the 389DS Wiki: http://directory.fedoraproject.org/wiki/Howto:DebianPackages

Tested on Debian Squeeze, current status: works for me :)

Feedback is welcome!

Post to Twitter

 

One of the tools that I’ve looked for in Linux was a good graphical LDAP client. I had ADS (Apache Directory Studio) in my list but I’ve never tried until today. It’s very complete and the interface is very good. It’s a pure LDAP client, it’s not a frontend for LDAP user administration or things like that. One of the great things that I found using it today is the “intelligent copy&paste” . If you copy and paste an entry in the same container ADS opens a windows called “Select copy strategy” with the following options:

  • Stop copy process
  • Ignore entry and continue
  • Overwrite entry and continue
  • Rename entry and continue: This is great, because you can use an object as templete and then you copy it with the new name in two-clicks.
Another great things are the connection wizard, attribute auto-completion, etc, etc… I’ve been using it for a few minutes and I’ve found a lot of useful things.

Post to Twitter

 

Today I calculated the space saved in one of the stores thanks to archiving+compression in one of the Zimbra servers that I’ve installed more than one ayer ago. The archiving volume has 273GB of email that uses 159GB of disk after compression. That’s 42% of saving.

I’m using a script to archive mails in the Open Source Edition that I’ve developed last year, running without any problems for more that 12 months.

It’s in my toolbox: https://github.com/diegows/toolbox

Post to Twitter

 

Attaching a sieve script to a shared folder is a little tricky. First, you need to understand that Cyrus has two types of repositories where you can have Sieve scripts: Personal and Global. Personal is per user and global is for every user. Global scripts aren’t applied on incoming messages by default, users must include them in their scripts.

Also, there are two types of Global scripts: global and global per domain.

When you log into Cyrus IMAP with sieveshell you have the following combinations (I suppose that you have manager and manager@example.com as admin in imapd.conf):

  • sieveshell -a manager -u manager localhost: To edit global scripts.
  • sieveshell -a manager@example.com -u manager@example.com localhost: To edit global script of example.com domain.
  • sieveshell -a user@example.com -u user@example.com localhost: To edit personal scripts of some user.

Scripts for shared folders work different from user scripts. The last ones are uploaded to the user’s repository and attached to the inbox when you activate them. The first ones must be uploaded to the global domain repository and attached to a shared folder by an user that has permission on it. You have to use the second combination of the listed above to load them and cyradm (or another compatible client) to do the attach:


sieveshell -u manager@example.com -a manager@example.com localhost
> put /tmp/my_script my_script
cyradm -u user@example.com localhost
localhost.localdomain> mboxcfg shared.folder@example.com sieve my_script

Post to Twitter

 

Escribí un script para hacer “Message Archiving” en la versión Open Source/Community de Zimbra. Está en producción desde julio del 2010 sin quejas hasta ahora.

Espero que les sirva.

I wrote an script to do “Message Archiving” for the Zimbra Open Source/Community Edition. It’s been running since July 2010 without any problems.

I hope it helps…

Post to Twitter

 

Introducción

Este artículo describe como usar SMTP y TLS para cifrar la comunicación entre el cliente y el servidor, incluyendo la autenticación de ambas partes. La ides es que el servidor nos autentique como usuarios validos usando certificados x509.

Configuración en el servidor (Postfix)

smtpd_tls_cert_file=/etc/postfix/tls-cert.pem
smtpd_tls_key_file=/etc/postfix/tls-key.pem
smtpd_tls_CAfile = /etc/postfix/cacert.pem
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache
smtpd_tls_ask_ccert = yes
smtpd_tls_loglevel = 1

smtpd_recipient_restrictions =
        permit_mynetworks
        permit_tls_clientcerts
        reject_unauth_destination

relay_clientcerts = hash:/etc/postfix/relay_clientcerts

Este es un fragmento con los parámetros de configuración que se agregaron al main.cf de Postfix. A continuación la explicacion:

  • tls-cert.pem y tls-key.pem son las claves publica y privada del SMTP servidor.
  • cacert.pem es la clave publica de la CA.
  • El certificado, la clave privada y el certificado de la CA se crearon con el script CA.sh que viene con openssl:
    1. Agregue -extensions v3_ca a la linea

      $CA -out ${CATOP}/$CACERT $CADAYS -extensions v3_ca -batch
    2. ./CA.sh -newca

      pide la passphrase y otros parámetros necesarios para el certificado.

    3. Edite el CA.sh y le agregue -nodes a la línea:

      $REQ -new -keyout newkey.pem -out newreq.pem $DAYS
    4. ./CA.sh -newreq

      para crear el request del certificado para el postfix.

    5. ./CA.sh -sign

      para firmar el request.

    6. cp newcert.pem /etc/postfix/tls-cert.pem
      cp newreq.pem /etc/postfix/tls-key.pem
    7. Pongan los permisos de tls-key.pem a 600 por seguridad.

Y listo!

Configuración de un cliente (msmtp)

Como uso Mutt+msmtp para enviar correo configure el segundo para que se valide con Postfix usando los certificados x509.

  1. Cree el certificado del lado cliente de la misma forma que lo hice del lado servidor (ver sección anterior, ./CA.sh -newreq y ./CA.sh -sign).
  2. Copie elnewcert.pem y newkey.pem como postfix-cert.pem y postfix-key.pem respectivamente al ~/.ssl/ de mi desktop.
  3. Luego configure el ~/.msmtprc con los siguientes datos:

    account example
    host mail.example.com.ar
    from diego@example.com.ar
    tls on
    tls_starttls on
    tls_certcheck off
    tls_key_file ~/.ssl/postfix-key.pem
    tls_cert_file ~/.ssl/postfix-cert.pem
    tls_trust_file ~/.ssl/cacert.pem
    
    account default: example
    

Y eso seria todo…

Post to Twitter

 

Armé un simple módulo de Sieve para Python, para usar en scripts. Espero que les sirva.

Click acá buscarlo en GitHUB

Post to Twitter

 

SASL como todo concepto abstracto no es simple de explicar. En principio es un mecanismo a través del cual los protocolos orientados a conexiones (LDAP, SMTP, IMAP) se desligan del manejo de la autenticación, la cual pasa a ser una serie de bits cuyo contenido no tiene importancia para el protocolo. El objetivo es mantener todos los mecanismos de autenticación en un lugar común a todos los protocolos, con la ventaja de eliminar redundancia de código y con la posibilidad de que se soporten nuevos mecanismos de autenticación sin tocar una linea de codigo en las implementaciones de los servicios.

Expliquemos mejor como funciona con un ejemplo concreto. Supongamos que tenemos un SMTP (Postfix) que soporta SASL a través de la librería Cyrus-SASL. A su vez esta libreria tiene los plugins para soportar los mecanismos de autenticación PLAIN y DIGEST-MD5. Veamos el comienzo de la comunicación SMTP:

S: 220 mail.ejemplo.com.ar ESMTP Postfix
C: ehlo woitasen.com.ar
S: 250-mail.ejemplo.com.ar
S: 250-PIPELINING
S: 250-SIZE 10240000
S: 250-VRFY
S: 250-ETRN
S: 250-STARTTLS
S: 250-AUTH PLAIN DIGEST-MD5
S: 250-ENHANCEDSTATUSCODES
S: 250-8BITMIME
S: 250 DSN

La C indica los mensajes enviados por el cliente y la S los enviados por el servidor.

Este es el clásico comando HELO del protocolo SMTP. Se usa para que el cliente se anuncie al servidor, el cual contesta con una serie de parámetros informativos. El mas importante ahora es el “250-AUTH”, el cual indica que el servidor soporta autenticación a través de los mecanismos PLAIN y DIGEST-MD5. En realidad, el servidor soporta SASL y es esta quien soporta esos mecanismos de autenticación.

Ahora bien, para que todo funcione el cliente tambien debe soportar SASL. Supongamos que el cliente usa Cyrus-SASL. Si la libreria tiene solo el plugin para autenticar con DIGEST-MD5, entonces se produce la siguiente secuencia de mensajes:

C: AUTH DIGEST-MD5
S: 334
   PENCeUxFREJoU0NnbmhNWitOMjNGNndAZWx3b29kLmlubm9zb2Z0LmNvbT4=
C: ZnJlZCA5ZTk1YWVlMDljNDBhZjJiODRhMGMyYjNiYmFlNzg2ZQ==
S: 235 Authentication successful.

El cliente le esta indicando al servidor que quiere autenticar con DIGEST-MD5, el servidor le contesta 334 enviando un “challenge” al cual el cliente responde. El intercambio finaliza con la confirmación de que la autenticación finalizo correctamente.

Ahora veamos como encaja SASL. EL challenge, es esa secuencia de caracteres enviados por el servidor luego del 334. Esta secuencia es generada por la librería SASL. Al servidor SMTP no le importa el contenido de este mensaje. El cliente recibe el challenge y lo procesa con su librería SASL, la cual devuelve otra secuencia de caracteres que el cliente envía al servidor. La función de SASL es generar estos mensajes y de avisarle al servidor si la autenticación finalizo correctamente o no.

Entonces, para ir cerrando, SASL se encarga del manejo de los mensajes de autenticación, siendo algo abstracto para los protocolos orientados a servicios. Si aparece un nuevo mecanismo de autenticación y la librería de SASL lo soporta, automaticamente el servicio también tendrá soporte sin tocar una linea código.

Post to Twitter

© 2012 DiegoWoitasen Suffusion theme by Sayontan Sinha