Wednesday 30 January 2013

Thunderbird, Apache, Wevdav and Filelink: Rolling your own Thunderbird filelink

Thunderbird, Apache, Filelink

If you are sending an email with a large file attachment, the chances are that it will bounce back with a message saying that the email exceeds the maximum allowed.

Emailing large documents, presentations, images and other multimedia content is the norm these days. This means that bounced emails are a regular plague.

Thunderbird has solved this problem by implementing "Filelink" technology. This works by uploading the attachment to a server and converting the attachment into an embedded link in the email.

Several services are presently included in the Thunderbird offering, including Ubuntu One, YouSendIt and Box. The Mozilla page for filelink is here: Filelink.

However, most users are unlikely to want to trust their attachments to a third party service. There is a way to host your own solution, using Apache and turning on WebDav. 

First, you need to install the Thunderbird addon, Webdav for filelink.
  1. Go to Webdav for filelink and install the add-on in Thunderbird (alternatively, Tools->Addons in Thunderbird and search for it in there and install it).
  2. After you have configured your webdav service in Apache, you will need to configure Webdav for filelink so that it knows which server to log in to and how to authenticate.
Now you need to set up your Apache server so that it supports webdav. Of course you are running Linux.

These days, Apache on Linux usually has the directory /etc/httpd/conf.d. So in this directory, create the file webdav.conf with this content:
 
    LimitXMLRequestBody 50000000

    Alias /webdav "/home/httpd/webdav"
   
        Dav On
        Options +Indexes
        IndexOptions FancyIndexing
        AddDefaultCharset UTF-8
        AuthType Basic
        AuthName "WebDAV Server"
        AuthUserFile /etc/httpd/webdav.users.pwd
        Require valid-user
        Order allow,deny
        Allow from all
   

 
Otherwise, if you don't have the directory, then put that content into your httpd.conf file. httpd.conf is often found in the conf directory.

Note that you may choose to have your webdav directory something other than our setting (/home/httpd/webdav). You will need to create this directory:
  1. mkdir /home/httpd/webdav
  2. chown apache /home/httpd/webdav
  3. chgrp apache /home/httpd/webdav
  4. chmod 700 /home/httpd/webdav
for apache use the user and group name for your apache process.

Now you need to create the password file for authentication to the webdav service:
  1. htpasswd -c /etc/httpd/webdav.users.pwd myuser
  2. Repeat (1) for all the users that you which to grant access to, without the "-c" flag.
where myuser is the user you are giving access to the service to, probably the first time, your own username.

Open your httpd.conf. Check that it has these items in it:
  • LoadModule dav_module modules/mod_dav.so
  • LoadModule dav_fs_module modules/mod_dav_fs.so

  •     # Location of the WebDAV lock database.
        DAVLockDB /var/lib/dav/lockdb
Now run:
  • /etc/init.d/httpd configtest
  • if all is okay:  /etc/init.d/httpd restart
You are ready to test your webdav. In firefox, go to:
 http://mydomain.com/webdav
 (of course you substitute your own domain name for "mydomain.com"!).

You should be prompted to for a username and password, enter the credentials that you created above (in the htpasswd bit).

If that works, then you are nearly there:
  1. Open up Thunderbird
  2. Edit->Preferences->Attachments->Add
  3. Choose "Webdav"
  4. In location enter: http://mydomain.com/webdav
  5. Enter your authentication and choose "remember password" when prompted.
  6. Click OK and you're done
Thunderbird checks that it can authenticate on the webdav service immediatley. The actual verification should be almost immediate. There are two possible points of failure in the above:
  1. You entered the wrong username/password or the server entry isn't correct. This will generate authentication or server error messages in Thunderbird.
  2. The URL is recognised by Apache but it isn't the proper webdav URL. When this happens, Thunderbird tries and tries again for a long time, ultimately failing to authenticate.

From now on, when you create an email and put in one of more large attachments, Thunderbird will ask you if you wish to convert them into a link instead. You can also right-click on an attachment, choose "covert to" and then choose link.

NOTE: If, when you are composing your first email using a large attachment, your Thunderbird filelink keeps failing with "Webdav failed authentication", the chances are that your permissions are not correct for apache to write to the webdav directory on the server that you specified. Check your permissions! Thunderbird has already verified the logging in, so this is actually the wrong message being reported. Unfortunately, you probably won't see these permissions failures in the log files on the server either.

Thursday 17 January 2013

Oracle to Postgres conversion tool

 Do you have Oracle databases that you wish to convert to Postgres? A new version of the Oracle to Postgres conversion too, Ora2Pg, has been released.

About Ora2Pg 
Ora2Pg is an easy and reliable tool to migrate from Oracle to PostgreSQL. It is developed since 2001 and can export most of the Oracle objects (table, view, tablespace, sequence, indexes, trigger, grant, function, procedure, package, partition, data, blob and external table). Ora2Pg works on any platform and is available under the GPL v3 licence. Docs, Download & Support at http://ora2pg.darold.net/

About Postgresql
 Postgresql (Postgres) is an enterprise class database system (DBMS) that is OpenSource, free to use and free of licence fees, that is released under the PostgreSQL License, which is an MIT-style license.

It compares very favourably to enterprise grade databases such as OracleIngres (actian) and DB2. It is an upgrade from mid-range database products and light weight / embedded data stores.

Postgres is actively developed and has a large, active online community with many companies (including Kieser.net) offering commercial Postgres support.