Category Archives: Linux

Recompile Dovecot with Vpopmail on Debian

Here's a script I use to quickly recompile dovecot with vpopmail support on Debian 6.0. I'm using the backports repository to get the 2.1 version of dovecot.

Now I'm using the following script every time I update and I get a new version of the dovecot packages.

  1.  

The last line also installs all the dovecot packages except for the debug one. You might want to change it if you don't want all.

grub2 notes

Grub2 configuration is in /etc/defaut/grub ( on Debian at least ).

Set GRUB_DEFAULT=saved in /etc/default/grub if you want to start with the last good boot.

update-grub - detects kernels automatically and writes boot lines to /boot/grub/grub.conf

grub-set-default - set the default entry ( First boot entry is number 0 )

grub-reboot - set the boot entry for the next reboot only ( for testing new kernels or other boot stuff especially when you're working remotely )

Which email client for Linux?

I've been a thunderbird user since firefox was named firebird. I was happy with it, I like the way you can easily search over all accounts, how you can archive messages in folders by year by simply hitting the "a" key, I like the threads and even the "gmail" conversations extension even if I don't use it.

One problem with thunderbird is it became unusable when I added an old account which was accumulating mail up to over 170k messages. I know 170k messages is not realistic and no one should have so many messages in inbox but still this made me look for something better.

First let's see what I'm looking for in an email client:

  1. Easy global search like thunderbird
  2. Archive folders and 1 key hit like thudnerbird 🙂
  3. Easy to mark messages as Spam/Junk with a single key hit, would be great to be able to mark multiple messages with a single key ( thunderbird doesn't have this )
  4. Message threads
  5. And last but not least, be able to handle a lot of messages in a folder, don't have to be super fast but at least it shouldn't lock

Here's what I tested so far:

Evolution

This was a nice surprise.
Pro: Evolution downloaded 87k message headers in just a few seconds and had no problems with selecting all and moving around.
Cons:

  • No archives
  • It has global search but it's a bit harder to access
  • Harder junk marking ( shift+ctrl+j instead of just j )
  • Always asks if I want to accept a certificate that's not issued for the exact domain of my email server ( at startup )
  • I could accept all the cons except for the lack of archiving.
    Anyone knows of a plugin that does archiving like thunderbird ? Please let me know!

    Kmail

    Becomes almost unusable with a big inbox ( 87k), hard to select all messages

    Pro: message list groups messages by year ( but this still doesn't beat yearly archives )
    Cons:

    • very slow with a lot of messages, takes a lot of time to fetch message headers
    • adding an account doesn't show it immediately in the accounts list, unless you restart kmail
    • no archives
    • no keyboard shortcut for junk/spam marking ( seriously ???)
    • global search harder to access

    sylpheed

    Pro: It's fast an lightweight but that also means it lacks what I want
    Cons:

    • No archiving
    • No keybboard shortcut for marking junk mail
    • No global search

    Conclusion: there's no client that meets all my needs so I'm going to have to stay with Thunderbird and just use evolution when I want to open a big folder.

    What email client are you using ?

    Better FIX for Inspiron N7110 touchpad

    Seth Forshee created a kernel patch and now the ALPS touchapd on this laptop and probably others is recognized as a touchpad instead of falling back to a psmouse.

    So now you can use the Touchpad tab in the "Mouse and touchpad settings" (gnome) to control the "click to tap", scrolling and other features and you don't have to use the patched syndaemon from my previous post.

    To install this fix on ubuntu just download this deb package, install and reboot. ( tested on Ubuntu 11.10 x86_64 ).

    If you want to know all the details go through the comments on this bug report #545307

    Fix inspiron N7110 ALPS Touchpad in Ubuntu

    I recently purchased a new dell inspiron N7110. The laptop is great and Ubuntu 11.04 works quite well but there is one important problem.

    The problem with most touchpads on laptops is that you'll often touch them accidentally while typing, this gets recorded as a tap/click and the typing cursor might move to another location and thus you might and up tying to a whole different place.

    With synaptics touchpads or ALPS touchpads ( this is what N7110 has - ALPS Glidepoint) you can use syndaemon, a program that would run in background, monitor the keyboard and disable the touchpad while you type. But this program only works for touchpads which are being recognized as synaptics or ALPS touchpads. The touchpad on N7110 was recognized as a simple mouse, Xorg loaded the evdev driver instead of synaptics.

    So I thought that maybe I can modify syndaemon to make it work with mice too. And I did. I noticed a lot of other people have the same problem so this could be useful even if you have a different touchpad that's also recognized as a mouse.
    Download the patch for syndaemon here:
    [download id="32"]

    To apply the patch:

    1.  

    The patch adds a new option to syndaemon to tell it to disable the mouse instead of a touchpad, without this the program will just exit when it can't find the touchpad.

    1.  

    Don't forget to start it every time you start X.

    Of course this is more like a quick hack then a real fix. A real fix would make Xorg or the kernel ( not sure exactly where the problem really is ) recognize this touchpad as a touchpad not as a mouse.

    Wammu backup to CSV for Gmail

    This is a modification to the wammu2csv.pl script that you can still find in google cache if you look for it.

    The problem with the original script was that wammu ( version 0.35 anyway ) seems to generate backup files encoded in UTF-16 and the regular expressions in that script will not work unless the content is first converted from UTF-16.

    Another benefit of the modified script is that now you don't have to convert the backup file from DOS to UNIX anymore.

    To use this script:

    1. Connect to your phone using wammu
    2. Retrieve contacts from phone and save them in a file using the backup function
    3. download [download id="31"] and run:
      ./wammu2csv.pl <your-backup-file> > <your-csv-file>

      This will generate a CSV file that you can import in Gmail

    Qmail Big concurrency

    Wanna send messages faster with your qmail server? Everyone will tell you to increase the remote concurrency. Till you find out that it can only go as high as 255. If you want more then that you have to apply the big concurrency patch

    The Problem

    Applying the patch and setting concurrency ( conf-spawn ) bigger then 509 will break the compilation. I was hoping to get at least 1000 on that new quad core 🙁

    Why 509? It seems the number depends on the maximum size of the FD_SET array used for "monitoring" ( using select ) the file descriptors ( connection sockets or opened files ) . This limit is set in FD_SETSIZE constant to 1024. In case you're wondering ... the formula that gets you from 1024 to 509 is (FD_SETSIZE-5)/2 ( from chkspawn.c )

    Trying to define FD_SETSIZE to a higher value in conf-cc like this -DFD_SETSIZE=4096 doesn't work because FD_SETSIZE is redefined in sys/select.h like this

    1.  

    __FD_SETSIZE is defined somewhere in /usr/include/bits/types.h ( actually typesizes.h ) to 1024. Defining -D__FD_SETSIZE doesn't work either...I even tried both and still no luck.

    The Solution

    After hours of digging through mail archives and sites I found this mailing list post that really helped:
    Re: fd_setsize

    If you just want to get it working just download my patch [download id="14"] , apply it ( after you apply the big concurrency patch ) , set conf-spawn to something big ( but less then 65000 ) and then you should be able to compile qmail.

    If you want to know how it's done, read bellow...

    It seems like the solution is to include bits/types.h, undefine __FD_SETSIZE and then define it to a higher value. The author of that post says that this is not a good idea (from the portability point of view, but I don't care about that ) since programs should never directly include bits/types.h ( true ) but the alternative is to modify that system file, again not a good idea since it will be overwritten by a possible update.

    My first idea was to just use that code from the mailing list post into the select.h2 , since this is the file used to generate select.h and select.h is included in spawn.c and ckhspawn.c but this didn't work because spawn.c was including "select.h" after "sys/types.h" so even if select.h would define __FD_SETSIZE it would be useless since FD_SETSIZE ( this is the one that really matters ) would have been already defined in sys/types.h .

    The solution I found at the time was to just move "select.h" at the top of the file and remove "sys/types.h" since it was already included from select.h but now I realized I could have just as well undefined and defined FD_SETSIZE too inside select.h

    And that's the story about how I got to run 1000 concurrent connection in qmail.

    The real problem

    Now that we can have so much concurrency we hit another wall. Qmail, as most other MTAs, doesn't have any way of controlling the remote concurrency per destination domain.

    At 1000 simultaneous connections it's very likely that it would create a few tens or hundreds of connections simultaneously to the same domain.

    When this happens that domain will just ban your ip.  So how do we fix this one?

    PS: I have an answer but I want to see what you have for a solution 🙂 so hit the comments...

    Fix: ClamAV unrar warning on RHEL

    Problem

    If you install Clamd and clamav on RHEL 5.3 (and maybe olderversions too ) or Centos the clamav rpms don't contain the unrar library so when you star clamd you will get this warning:

    Starting Clam AntiVirus Daemon: LibClamAV Warning: Cannot dlopen: file not found - unrar support unavailable

    Solution

    The solution is really simple. All you have to do is install clamav-devel

    1.  

    and then restart clamd and everything should be ok.
    Solution found thanks to this blog post ( yeah it's in Japanese and no I can't read Japanese but It was easy to figure out )

    SSH to multiple servers and run commands

    Problem

    You need to run a list of commands on a list of servers and record the output of each command.

    Solution

    Create a perl script using Net::SSH::Perl ( a ssh client written as a perl module ). This script will read a list of commands from a file, a list of servers form another file, will connect to each server, execute each command in in the commands file then go to the next server and do the same.

    Installation

    Download the script: [download#8]
    install Net::SSH::Perl

    1.  

    Now you can decompress the script and configure it

    1.  

    put the commands in commands.txt ( one command per line )
    put the servers in servers.txt (one per line ) in this format: user@hostname:port,password

    Now you can test the script: run ./ssh_batch.pl and look at the output in log.txt

    Warning! You can destroy multiple servers with this script!

    Yeah it can do that if you're not carefull about what commands you tell it to run and you log in with a user with too  much permissions. So make sure you know what you are doing before you run it on production servers.

    Ip alias with dhcp in ubuntu

    Problem

    You have a machine running ubuntu, NetworkManager gets the ip from a dhcp server and you want to have another ip that never changes on the same interface (for example if you want to also act as a dhcp server for your local network and both the local and uplink are connected on the same interface).

    Dhclient seems to support this through an "alias" statement and NetworkManager seems to use dhclient but I just couldn't make it work like this.

    Solution

    Create a script in /etc/network/if-up.d/ . Name is as  you wish. My choice was "alias" .

    1.  

    Then make sure the script is executable:

    1.  

    You can replace the ip and mask to fit your needs.
    NetworkManager will run this script automatically after it brings the interface up.

    This worked for me but in the spirit of usability it would have been nice to have this kind of feature directly into NetworkManager's connection configuration gui.

    Do you know any other way of doing this? Please share it in the comments.