Blog, GNU/Linux

Postfix+Amavisd-new+Spamassasin+Clamav

Since I had to disable the PTR check in Postfix at Binware because in Spain 90% of mail servers are badly configured and they were all rejected, and now we have lot of spam.

So I decided to install Spamassassin and Clamav to detect and reject some of this spam.

First of all, we need to install needed packages:

apt-get install spamassassin amavisd-new clamav clamav-daemon

We will begin configuring amavisd-new, the configuration files are at /etc/amavis/conf.

In file 20-debian_defaults I changed the header that will be added to each mail processed:

$X_HEADER_LINE = "AntiSpam/Antivirus Scanner at $mydomain";

We need to activate antispam and antivirus check in amavis, this is found in file 15-content_filter_mode. We need to uncomment @bypass_virus_checks_maps and @bypass_spam_checks_maps. The file will look like this:

use strict;

# You can modify this file to re-enable SPAM checking through spamassassin
# and to re-enable antivirus checking.

#
# Default antivirus checking mode
# Please note, that anti-virus checking is DISABLED by
# default.
# If You wish to enable it, please uncomment the following lines:


@bypass_virus_checks_maps = (
   \%bypass_virus_checks, \@bypass_virus_checks_acl, \$bypass_virus_checks_re);


#
# Default SPAM checking mode
# Please note, that anti-spam checking is DISABLED by
# default.
# If You wish to enable it, please uncomment the following lines:


@bypass_spam_checks_maps = (
   \%bypass_spam_checks, \@bypass_spam_checks_acl, \$bypass_spam_checks_re);

1;  # ensure a defined return

By default, amavis will use the hostname for $mydomain, but thats not what I want, so I edited file 05-domain_id, setting $mydomain to binware.org

use strict;

# $mydomain is used just for convenience in the config files and it is not
# used internally by amavisd-new except in the default X_HEADER_LINE (which
# Debian overrides by default anyway).

$mydomain = 'binware.org';

# amavisd-new needs to know which email domains are to be considered local
# to the administrative domain.  Only emails to "local" domains are subject
# to certain functionality, such as the addition of spam tags.
#
# Default local domains to $mydomain and all subdomains.  Remember to
# override or redefine this if $mydomain is changed later in the config
# sequence.

@local_domains_acl = ( ".$mydomain" );

1;  # ensure a defined return

Next step is to add the clamav user to the amavis group, so that amavis can call clamav

adduser clamav amavis

Now it’s time to configure postfix. The first file to edit is main.cf:

# Amavisd-new
content_filter = amavis:[127.0.0.1]:10024

And in master.conf add this at the end of file:

amavis unix - - - - 2 smtp
  -o smtp_data_done_timeout=1200
  -o smtp_send_xforward_command=yes

127.0.0.1:10025 inet n - - - - smtpd
  -o content_filter=
  -o local_recipient_maps=
  -o relay_recipient_maps=
  -o smtpd_restriction_classes=
  -o smtpd_client_restrictions=
  -o smtpd_helo_restrictions=
  -o smtpd_sender_restrictions=
  -o smtpd_recipient_restrictions=permit_mynetworks,reject
  -o mynetworks=127.0.0.0/8
  -o strict_rfc821_envelopes=yes
  -o smtpd_bind_address=127.0.0.1

That’s all! Now restart services:

/etc/init.d/clamav-daemon restart
/etc/init.d/clamav-freshclam restart
/etc/init.d/amavis restart
/etc/init.d/postfix restart
Blog, Development

Eclipse Configuration for Web Development

After trying very different IDE and many Eclipse IDE flawors, this is the best configuration I have found, and all the components are free.

First of all we need to download Eclipse Classic from the Eclipse website.

One of the first things we need to do is to change eclipse.ini, we will make it start faster and increase the memory limit

--launcher.XXMaxPermSize
256m
-vm
/usr/bin/java
-vmargs
-Xms40m
-Xmx1024m

The path to Java VM depends on your installation and system, in windows you must search for “javaw.exe”. Setting the path to Java VM makes that Eclipse stops searching for the Java VM every start, which makes the start faster.

Now we can start installing the required Plugins. In “Help->Install New Software…” we will add the following Update Sites.

  • Aptana – http://update15.aptana.org/studio/25914/

    Aptana Install

  • Mylyn – http://download.eclipse.org/tools/mylyn/update/e3.4

    Mylyn Install

  • Mylyn Extras – http://download.eclipse.org/tools/mylyn/update/extras

    Mylyn Extra Install

  • SVNKit – http://community.polarion.com/projects/subversive/download/eclipse/2.0/galileo-site/

    SVNKit Install

  • EPIC (Perl) – http://e-p-i-c.sourceforge.net/updates/testing optional, only if you need Perl

    EPIC Install

You have noticed that at each start a Window Asking for Installing Addiontal Features. Now that we can start installing this features. For me the most important are:

  • Aptana PHP

    Aptana PHP Install

  • Aptana PyDev optional, only if you need Python

    Aptana PyDev Install

  • Ajax Libraries You can select all or just the one you need

    Aptana Ajax Libraries Install

After installing all needed plugins we can start with the configuration.

  1. General\Workspace
    • Text file encoding -> UTF-8
    • New text file line delimiter -> Unix
  2. General\Editors\Text Editors
    • Displayed tab width -> 4
    • Insert spaces for tabs -> True
    • Show line number -> True
    • Show print margin -> True
    • Print margin column -> 80
  3. General\Keys
    • Show Whitespace Characters (Text Editing) -> Binding: Ctrl+Alt+Space -> When: Editing Text
  4. Aptana\Editors

    • Formattings -> Insert selected proposal with ‘Tab’ key as well as ‘Enter’ key -> True
    • Tab Insertion -> Use spaces (current width is 4)
  5. Aptana\Editors\PHP
    • Create project file in new PHP project -> False
  6. Aptana\Editors\PHP\Formatting
    • Edit… ->
      • Profile Name -> ZendStandards
      • Control Statemets ->
        • Insert new line before ‘else’ in an ‘if’ statement -> False
        • Insert new line before ‘catch’ in an ‘try’ statement -> False
        • Insert new line before ‘while’ in an ‘do’ statement -> False
        • ‘if else’ – Keep ‘then’ statement on same line -> False
      • Braces ->
        • Method declaration -> Next line
        • Blocks -> Same line
        • Blocks in case statement -> Same line
        • ‘switch’ statement -> Same line
  7. Install/Update\Automatic Updates
    • Automatically find new updates and notify me -> True
  8. Team\SVN – SVN Client
    • SVN Client -> SVN Kit
    • SVN Client -> Use SVN Merge View -> True
  9. Team\SVN\Automatic Properties
    • Add: * -> svn:keywords=Id

I use the Aptana Perspective with this views:

  • Right Top
    • Aptana Standard Views\Project
  • Right Bottom
    • General\Outline
    • Aptana Standard Views\PHP Elements Views
    • Aptana Standard Views\References
  • Bottom
    • General\Tasks
    • Aptana Standard Views\Validation
    • General\Console
    • Team\History
    • Team\SVN Properties
    • EPIC\RegExp only if you installed EPIC
  • Left
    • Tasks\Task List

I like that the Oultine is automatically expanded, so that I have an overview of the file at every moment, but Aptana does not autoexpand the Outline. I use the following workaround:

  • Create a new General Project called “_Monkey”
  • Create a folder called scripts
  • Create a javascript file called autoExpandOutline.js with the following content
    /* 
     * 
     * Menu: EHU > HandlerService (Auto expand outline)
     * Kudos: Ingo Muschenetz & Kevin Lindsey & Steve Daniels
     * License: EPL 1.0
     * Listener: getPartService().addPartListener(this);
     * DOM: http://localhost/com.aptana.ide.scripting
     * DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.javascript
     * 
     * 
    */
     
    function getPartService()
    {
        var workbench = Packages.org.eclipse.ui.PlatformUI.getWorkbench();
        var result = null;
     
        if (workbench)
        {
            var window = null;
     
            runOnUIThread(function() {
                window = workbench.getActiveWorkbenchWindow();
     
                if (window != null)
                {
                    result = window.getPartService();
                    //out.println("result set to " + result);
                }
                else
                {
                    //out.println("window is not defined");
                }
            });
        }
        else
        {
            //out.println("workbench is not defined");
        }
     
        //out.println("getPartService() is returning " + result);
     
        return result;
    }
     
    function partBroughtToTop(part)
    {
      //out.println("part*()\n");
    }  
     
    function partClosed(part)
    {
      //out.println("part*()\n");
    }
     
    function partDeactivated(part)
    {
      //out.println("part*()\n");
    }  
     
    function partOpened(part)
    {
      //out.println("part*()\n");
    }
     
    function partActivated(part)
    {
      if (part.getEditorInput)
      {
        expandOutline();
      }
    }
     
    function partVisible(part)
    {
      //out.println("part*()\n");
    }
     
    function partHidden(part)
    {
      //out.println("part*()\n");
    }
     
    function expandOutline()
    {
      //out.println("expandOutline()\n");
      try
      {
        //out.println("try\n");
        var editor = editors.activeEditor.textEditor;
     
        editor.getOutlinePage().getTreeViewer().expandAll();
      }
      catch (e)
      {
        //out.println("catch\n");
      }
    }
    

Each new project that you create must use this project as reference, and now every time you open a file the Outline will be expanded automatically when you enter into the Editor

Eclipse Layout

Blog, Development

MooStepForm

Hoy repasando los RSS, he visto que anieto2k ha publicado un script para jQuery que convertia un formulario en varios pasos. Lo que ha hecho tener la idea de hacer lo mismo pero con Mootools.

El funcionamiento es el mismo que el script de anieto2k, busca por defecto un formulario (estoy preparandolo para que funcione con mas de uno…) con la class stepMe y lo divide por fieldsets.

Se puede personalizar al crear la clase:

  • strBack: ‘string de volver’
  • strNext: ‘string de siguiente’
  • blockEl: ‘tag para usar en la division’
  • className: ‘class del formulario’

He adjuntado un pequeño fichero HTML para verlo en funcionamiento (AVISO: no tiene CSS!!)

Lo podeis descargar aqui: MooStepForm v.0.1

Blog, MacOSX

Recompilar MAMP

El soporte de LDAP en MAMP 1.7.1 esta roto asi que tube que recompilar el PHP, lo cual me obligo a recompilar todas sus dependencias, pero como no encontre ninguna guia de como realizarlo correctamente, aqui esta como lo hice yo.

Lo primero es descargarse el codigo fuente proporcionado por la gente de MAMP, y su version compilada.

Codigo fuente: MAMP 1.7.1 (src)

Version Intel: MAMP 1.7.1 (intel)

Version PPC: MAMP 1.7.1 (ppc)

Una vez que tengamos esto, hay que instalar MAMP la version compilada en /Applications y asi ya tenemos toda la estructura correcta lista para solo recompilar lo necesario.

Ahora descomprimimos el codigo fuente y vamos compilando las diferentes librerias:

CURL

tar zxvf curl-7.16.2.tar.gz
cd curl-7.16.2
./configure --prefix=/Applications/MAMP/Library
make
make install

Freetype

tar zxvf freetype-2.3.4.tar.gz
cd freetype-2.3.4
./configure --enable-shared --configure=/Applications/MAMP/Library/
make
make install

Gettext

tar zxvf gettext-0.16.1.tar.gz
cd gettext-0.16.1
./configure --prefix=/Applications/MAMP/Library
make
make install

IMAP (Parche para osx: imap-2006i-osx.patch)

tar zxvf imap-2006i.tar.Z
cd imap-2006i
patch -p1 < imap-2006i-osx.patch
make oxp
cp c-client/*.h /Applications/MAMP/Library/lib/imap-2006i/include/
cp c-client/*.c /Applications/MAMP/Library/lib/imap-2006i/lib/
cp c-client/c-client.a /Applications/MAMP/Library/lib/imap-2006i/lib/libc-client.a

JPEG

tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
./configure --enable-shared --prefix=/Applications/MAMP/Library
ln -s `which glibtool` ./libtool
make
make install

libiconv

tar zxvf libiconv-1.11.tar.gz
cd libiconv-1.11
./configure --enable-shared --prefix=/Applications/MAMP/Library
make
make install

LibIdn

tar xvfz libidn-0.6.14.tar.gz
cd libidn-0.6.14
./configure --enable-shared --prefix=/Applications/MAMP/Library/
make
make install

libmcrypt

tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --enable-shared --prefix=/Applications/MAMP/Library/
make
make install

libpng

tar zxvf libpng-1.2.18.tar.gz
cd libpng-1.2.18
./configure --enable-shared --prefix=/Applications/MAMP/Library
make
make install

libxml

tar zxvf libxml2-2.6.29.tar.gz
cd libxml2-2.6.29
./configure --enable-shared --prefix=/Applications/MAMP/Library
make
make install

libxst

tar zxvf libxslt-1.1.21.tar.gz
cd libxslt-1.1.21
./configure --enable-shared --prefix=/Applications/MAMP/Library/ --with-libxml-prefix=/Applications/MAMP/Library/
make
make install

t1lib

tar zxvf t1lib-5.1.1.tar.gz
cd t1lib-5.1.1
./configure --enable-shared --prefix=/Applications/MAMP/Library/
make without_doc
make install

libexpat

Esta libreria es necesaria y no esta incluida, asi que hay que bajarla de http://sourceforge.net/projects/expat/

tar zxvf expat-2.0.1.tar.gz
cd expat-2.0.1
./configure --enable-shared --prefix=/Applications/MAMP/Library/
make
make install

MySQL

tar xvfz mysql-5.0.41.tar.gz
cd mysql-5.0.41
./configure --prefix=/Applications/MAMP/Library --with-unix-socket-path=/Applications/MAMP/tmp/mysql/mysql.sock --with-tcp-port=9999 --localstatedir=/Applications/MAMP/db/mysql/
make
make install

Apache2

tar zxvf httpd-2.0.59.tar.gz
cd httpd-2.0.59
./configure --prefix=/Applications/MAMP/Library --sysconfdir=/Applications/MAMP/conf/apache --enable-nonportable-atomics --enable-so --enable-cgid --enable-auth-anon --enable-auth-dbm --enable-auth-digest --enable-file-cache --enable-echo --enable-charset-lite --enable-cache --enable-disk-cache --enable-mem-cache --enable-example --enable-ext-filter --enable-case-filter --enable-case-filter-in --enable-deflate --enable-mime-magic --enable-cern-meta --enable-expires --enable-headers --enable-usertrack --enable-unique-id --enable-proxy --enable-proxy-connect --enable-proxy-ftp --enable-proxy-http --enable-bucketeer --enable-http --enable-info --enable-cgid --enable-vhost-alias --enable-speling --enable-rewrite --enable-so --with-ssl=/usr --enable-dav --enable-dav-fs --enable-ssl=shared --enable-mods-shared=most --with-mpm=prefork --without-berkeley-db
make

Si al compilar nos aparece este error:

endrecv.c:965:2: error: #error APR has detected sendfile on your system, but nobody has written a
sendrecv.c:966:2: error: #error version of it for APR yet. To get past this, either write apr_sendfile
sendrecv.c:967:2: error: #error or change APR_HAS_SENDFILE in apr.h to 0.

Entonces tenemos que editar el fichero srclib/apr/include/apr.h y cambiar la linea #define APR_HAS_SENDFILE 1 por #define APR_HAS_SENDFILE 0

Y finalmente para instalar

make install

PHP

tar zxvf php-5.2.5.tar.gz
cd php-5.2.5
./configure --with-mysql=/Applications/MAMP/Library --with-apxs2=/Applications/MAMP/Library/bin/apxs --with-gd --with-jpeg-dir=/Applications/MAMP/Library --with-png-dir=/Applications/MAMP/Library --with-zlib --with-freetype-dir=/Applications/MAMP/Library --prefix=/Applications/MAMP/bin/php5 --exec-prefix=/Applications/MAMP/bin/php5 --sysconfdir=/Applications/MAMP/conf/php5 --with-soap --with-config-file-path=/Applications/MAMP/conf/php5 --enable-track-vars --enable-bcmath --enable-ftp --enable-gd-native-ttf --with-bz2=/usr --with-ldap --with-mysqli=/Applications/MAMP/Library/bin/mysql_config --with-sqlite --with-ttf --with-t1lib=/Applications/MAMP/Library --enable-mbstring=all --with-curl=/Applications/MAMP/Library --enable-dbx --enable-sockets --enable-bcmath --with-imap=shared,/Applications/MAMP/Library/lib/imap-2006i --enable-soap --with-kerberos --enable-calendar --with-pgsql=shared,/Applications/MAMP/Library/pg --enable-dbase --enable-exif --with-libxml-dir=/Applications/MAMP/Library --with-gettext=shared,/Applications/MAMP/Library --with-xsl=/Applications/MAMP/Library --with-pdo-mysql=shared,/Applications/MAMP/Library --with-pdo-pgsql=shared,/Applications/MAMP/Library/pg --with-mcrypt=shared,/Applications/MAMP/Library --with-openssl --with-iconv=shared,/Applications/MAMP/Library
make
make test
make install

Y con esto ya tenemos recompilado el MAMP y listos para funcionar. En cualquiera de las opciones se puede aprovechar para cambiar opciones, añadir o quitar modules, etc…

Blog, Misc

Misexta.tv Download (Firefox Addon)

Bueno, he estado mirando un poco como funciona el desarrollo de extensions para Firefox, y la verdad es que en developer.mozilla.org hay bastante informacion util. Por lo que aqui tengo la primera beta, que es capaz de descargar los videos en HD.

Las cosas que faltan por implementar son:

  • Descarga de videos cortos (descargar por medio del protocolo RTMP)
  • Deteccion de videos con partes, con opcion de descargar las diferentes partes
  • Limpieza de la lista de videos (timeout y numero maximo)
  • Y lo que surja…

El funcionamiento es bastante sencillo, cuando instaleis la extension, tendreis un icono en la barra de estado:

Vais a la pagina de misexta.tv y elegis un video en HD480p:

Una vez que le deis al play, si vais al icono de la barra de estado vereis que os aparece “HD Video”:

Le dais encima y os dejara guardar el video. Como aun no detecta las partes, debereis saltar de una parte a otra para que aparezcan en el menu (por ahora todos se llaman “HD Video”, pero van en orden de arriba a abajo)

Podeis descargar el addon aqui (Solo Firefox 3.0.*):

Actualizacion: Por cambios en misexta.tv el Addon ha dejado de funcionar, estoy trabajando en una nueva version que funcione correctamente.