How to send an entire domain to /dev/null in Postfix

September 29th, 2006

At Exoweb, our software developers use bogus email addresses of the form *@example.com (where I mean “example.com” literally, not as an example) to test their software’s ability to send email. Since I don’t want our Postfix server to attempt to deliver these messages out on the Internet, I need Postfix to handle these messages and blackhole them (make them disappear, sent to /dev/null). So what follows are instructions on how to blackhole an entire domain in Postfix.

First, we add a virtual_alias_maps entry to /etc/postfix/main.cf so that we can specify example.com as one of our virtual domains:

virtual_alias_maps = hash:/etc/postfix/virtual_alias

Inside /etc/postfix/virtual_alias, add a catchall address:

@example.com      blackhole@localhost

We have to use blackhole@localhost here and not /dev/null/ because virtual_alias_maps cannot run commands—it can only forward to real addresses. So we put an entry inside /etc/aliases to handle the blackhole:

blackhole:      /dev/null

This assumes that one of your mydestination domains in main.cf is localhost so that Postfix will actually consult the aliases file.

In order to make these changes take affect, you have to rebuild the aliases database, build the virtual_alias database, and reload your Postfix configuration. Respectively:

# newaliases
# postmap /etc/postfix/virtual_alias
# postfix reload

Now, any emails you send to blackhole@localhost will disappear, and so will any emails addressed to anyone@example.com (provided they are relayed through your Postfix server).

Footnote: The top-level and second-level domain names that are reserved for testing can be found in RFC 2606.

How to convert CHM files under Linux

September 24th, 2006

CHM files, known as Microsoft Compressed HTML Help files, are a common format for eBooks and online documentation. They are basically a collection of HTML files stored in a compressed archive with the added benefit of an index.

Under Linux, you can view a CHM file with the xchm viewer. But sometimes that’s not enough. Suppose you want to edit, republish, or convert the CHM file into another format such as the Plucker eBook format for viewing on your Palm. To do so, you first need to extract the original HTML files from the CHM archive.

This can be done with the CHMLIB (CHM library) and its included helper application extract_chmLib.

In Debian or Ubuntu:

$ sudo apt-get install libchm-bin
$ extract_chmLib book.chm outdir

where book.chm is the path to your CHM file and outdir is a new directory that will be created to contain the HTML extracted from the CHM file.

In other Linuxes, you can install it from source. First download the libchm source archive from the above website. I couldn’t get the extract_chmLib utility to compile under the latest version 0.38, so I used version 0.35 instead.

$ tar xzf chmlib-0.35.tgz
$ cd chmlib-0.35/
$ ./configure
$ make
$ make install
$ make examples

After doing the “make examples“, you will have an executable extract_chmLib in your current directory. Here is an example of running the command with no arguments and the output it produces:

$ ./extract_chmLib
usage: ./extract_chmLib <chmfile> <outdir>

After running the utility to extract the HTML files from your CHM file, the extracted files will appear in <outdir>. There won’t be an “index.html” file, unfortunately. So you’ll have to inspect the filenames and/or their contents to find the appropriate main page or Table of Contents.

Now the HTML is yours to enjoy!

Resources

I got help in writing this article from here and here.

Mirror

September 22nd, 2006

It’s pretty amazing what you find when you search for “mirror” in Google Images and Flickr. This is a collection of what I just found.


[Mirror collection]

Spaghetti Wiring

September 18th, 2006

When you work in a software development shop, spaghetti code is most certainly frowned upon. What about spaghetti wiring?

[Spaghetti wiring]

So this was the remains of the small electrical fire that occurred 15 minutes before I arrived at the office today… the charged main circuit to the room that houses most of our developers, their computers, and the all-important Ice Box.

Do you think this is enough to convince the building management that the building’s wiring needs professional help? No, unfortunately, I think we’ll still have to fight them to get adequate electrical capacity and safety. :(

I Love Chocolate Too!

July 15th, 2006

This piece of writing that came across my desk made me laugh really hard today:

Cities are the centers of ecomoy developement, the centers of power, water and fossile fuel consumption and the centers of pollutant producing. The atmospheric pollution in cities is maily from vehicle dispersion, industrial consuming, energy producing and resident-consuming chocalate.

I think the author means charcoal, as in residential heating. ;)

Stop using backup email spooling

July 7th, 2006

Here’s a great opinion piece from the blog of my DNS provider entitled: Want to reduce email spam to your mail server? Stop using backup spooling.

It is with regret that we have come to the following conclusion, but here it is: Offsite backup SMTP spoolers and backup mail exchangers have become worse than useless.

The problem is spam and the software that delivers it exploiting the weak authentication schemes inherent in the SMTP protocol itself. It used to be an annoyance, then it became a concern, it is now an epidemic and has resulted in the death of the offsite backup MX handler.

The author then goes on to explain what the problem is and why you won’t really miss your backup spooling. It’s a very interesting point of view (in a good way) that’s worth considering.

Earthquake in Beijing

July 4th, 2006

We felt an earthquake in Beijing today at approximately 03:57:30 UTC 4 July 2006. The building, my desk, and I went back and forth for about one second. Very weird feeling. It was my first one, I think.

Xie Lei, at work, was scared because she remembers the earthquake that hit Beijing in 1976. I’ll have to read up on that one, but I seem to remember reading that the pagoda at Bei Hai park was partially destroyed in an earthquake then.

Update: From the news I’ve learned that today’s earthquake was magnitude 5.1.

My First Love in Bluegrass

June 10th, 2006

I’ve been listening to Prairie Pickin’—a bluegrass radio show from my hometown—all day today. It airs every Thursday night (local time) and there’s an Internet stream available, so I’ve got a cron job set up that “records” the stream for me so I can listen to the show whenever I get around to it.

“Prairie Pickin’” was my first introduction to Bluegrass music, and I’ve got recordings going back to May of 2001 when I started listening to the show. At the time, it was hosted by the insane Rob Baker and sweet Anna Somerville, and I credit the two of them for my love of Bluegrass today. Rob still does the show, but now the wise Doug Ritchie is his co-host.

Well, last month, Doug surprised Rob with a track going back to those early days. It was a recording of Rob Baker and the great David Ward performing live in Edmonton, opening for Lynn Morris.

The song is “Hold Whatcha Got”, and David and Rob call themselves “The Lonesome Brothers”, which is derived from the meta-band Lonesome and Then Some. This band was my first love in Bluegrass. I followed them everywhere. So hearing a part of their music today brought back all those good memories. I love David’s vocals and Rob’s harmony. Totally in the pocket.

Hold Whatcha Got, by David Ward and Rob Baker (2:36, 2.4 MB)

Wow

May 14th, 2006

All I can say is wow: The Best and the Interesting.

A Solar Eclipse for the 2008 Olympics

April 4th, 2006

[Total Solar Eclipse, by Astrobrian]I just found out today that there will be a total solar eclipse in China one week before the 2008 Olympics begin!

This event will occur on 1 August 2008, giving us 2 minutes and 27 seconds of maximum totality. The line of totality will pass through Siberia, skirt along the western Chinese-Mongolian border, and pass through central China southwest of Beijing. (It will only be visible as a partial eclipse at sunset in Beijing itself.)

This is great news for people thinking about coming to Beijing for the Olympics. Just come a week early, catch the eclipse, and then tour around China until the Olympics start. I can’t wait. :) Spread the news.