January 2005 Archives

Kyle Rankin

AddThis Social Bookmark Button

Related link: http://larve.net/people/hugo/2003/scratchpad/VirtualFoldersInMutt.html

My email is generally well-organized. I have a lot of different folders and procmail rules that automatically move email to the various categories of email I’ve set up. Sometimes, though, I can’t exactly remember which category a message is in. While mutt, my preferred email client, is great at searching for a term within a folder, it isn’t as easy to search all of your email folders at once. I found a few possible solutions to this problem, and ended up rolling my own solution.

I was first inspired by this post that described using mairix to create a virtual folder in mutt. Mairix indexes all of your email folders, and allows you to search through this index with basic keyword searches. It then outputs the results into a maildir (or mbox if you want) so you can treat it like a virtual folder.

I set up mairix for a bit and tried it out, however I realized that most of my searches aren’t simple “what emails contain these single words in them” much of the time. Some times I want to search for two words next to each other, but that’s something mairix doesn’t seem to be able to do. Sometimes I even want to use regular expressions in my searches, which mairix doesn’t support.

My solution is a script called “maildirsearch” and looks like this:

#!/bin/sh

MAILDIRS="$HOME/mail"
VFOLDER="search"
VFOLDERPATH="$MAILDIRS/$VFOLDER/cur/"
FOLDERS=`awk '{print $2}' $HOME/.mutt/mailboxes | sed 's/^"=(.*)\"$/1 /' 
| xargs echo`

rm $VFOLDERPATH/*

for i in $FOLDERS
do
   for j in `egrep -lR "$@"  $MAILDIRS/$i`
   do
      ln -s $j $VFOLDERPATH/.;
   done;
done;

I store my mail in a series of maildirs on my laptop in ~/mail/. The FOLDERS environment variable is populated with a one-liner that turns my .mutt/mailboxes file from this:

. . .
mailboxes "=oreilly"
mailboxes "=blog"
mailboxes "=nblug"
mailboxes "=google_alerts"
mailboxes "=debian"
mailboxes "=sent-mail"

into a list of folders separated by spaces. Then I egrep through each folder for my search term, finally symlinking any results into my virtual folder that I called “search” and put with the rest of my maildirs.

I realized that when I ran this search in mutt, what would be nice is for mutt to automatically change to this new folder while it was being populated with email. So I created a wrapper script that runs this script in the background, and then runs an extra instance of mutt inside itself, open to my virtual folder. It’s a bit of a hack, but I can’t seem to find a way yet to send commands to a running mutt process from outside mutt. I called this script “muttsearch”:

#!/bin/sh

VFOLDER="search"
$HOME/bin/maildirsearch "$@" &
sleep 1;
mutt -f "=$VFOLDER";

Basically, since it runs mutt -f “=search”, I can watch my search results as they appear, so I can go ahead and read through them without having to wait for the search to finish. Plus I can use all of the standard mutt filtering techniques at that point to refine the search. All that was left is to add a macro to my mutt config:

# search macro
macro index eM "$HOME/bin/muttsearch "
macro browser eM "$HOME/bin/muttsearch "

Now I can just type Esc-M from within mutt and type in my search term. I think for the future I’m going to extend this idea to provide other types of virtual folders from within mutt, possibly to create a folder of flagged messages on the fly.

How do you manage virtual folders in mutt? In your preferred email client?

Kyle Rankin

AddThis Social Bookmark Button

Related link: http://kb.bitdefender.com/site/KnowledgeBase/viewArticle/en/100/Problem_with_Lin…

Windows XP Service Pack 2 seems to break the captive-ntfs installer. The bitdefender knowledge base lists a workaround for the issue but there are also a few other workarounds, including some especially for Knoppix users.

Basically, it appears that the captive-ntfs installer GUI can’t find ntoskrnl.exe so the workaround involves mounting the NTFS partition read-only, and directly pointing the Captive NTFS installer to the Windows directory on that system.

Another possible workaround if you have network connectivity is to skip the filesystem scanning altogether, and have the GUI download and extract the files it needs from XP SP1. Of course if you use this method you will need to wait as the 30MB of data is downloaded, which can be quite a bit of waiting if you need to use this method on multiple machines.

A third workaround that I’ve recently gotten into is to create a special Knoppix config with all of the XP SP1 files that captive needs and store it on a usb key I carry with me. I’ve discussed how to use the Knoppix saveconfig script to create persistent settings previously, although for this you need to do some extra tweaking. What I have come up with is a general-purpose configs.tbz file that contains not only the captive-ntfs files I need, but also the chntpw tool to edit the Windows registry, updated f-prot files using the Knoppix live software installer, dd_rescue, and dd_rhelp to image failing drives.

Basically I go through the various methods to install each of these applications to the live Knoppix CD, then I use the same tar command that the saveconfig script uses to create a tarball of all of the directories I need to keep:
BZIP2=-9 tar -cpPjf /mnt/sda1/sysadmin/configs.tbz /home/knoppix/.dist/ /home/knoppix/.knx-live-inst/ /home/knoppix/Software/ /home/knoppix/Desktop/Extra\ Software/ /var/lib/captive/*.sys /var/lib/captive/ntoskrnl.exe

Now I have all of these various directories backed up into my sysadmin/configs.tbz file on my usb drive. I copy the standard knoppix.sh file that saveconfig creates to that directory as well, and then next time I boot Knoppix, if I want to use my sysadmin config, I type knoppix myconfig=/dev/sda1/sysadmin at the boot: prompt. This saves me all the time that it normally takes to download and install any of these tools individually, plus I can use everything on a machine that doesn’t have a network connection at all.

I also use this method to back up other types of configs I use in different directories on the usb drive so I can select any of them at the boot: prompt. I just set up my configuration once, and either use saveconfig, or a tar command to create the configs.tbz. If you are backing up configuration files inside /home/knoppix and you aren’t sure what exactly to back up, you can always have saveconfig back up everything, and then bunzip2 the configs.tbz file, use tar –delete to remove the files you don’t need, or tar -r to add files, and then bzip2 it back up.

AddThis Social Bookmark Button

Related link: http://straphangers.org/photoban/


Monday, January 10th is the last day to submit a comment on the proposed photography ban on New York City subways. If you don’t know about the ban, you can read more at the Straphanger’s web site or please submit a comment against the ban by using this form. N.B.: The form can be confusing at first glance. There are several screens to click through before your message is sent.


My letter to them follows:


Other New Yorkers have argued against the subway photography ban, citing economic (tourism), artistic, and even safety (documenting incidents or unsafe conditions) as reasons to strike down the proposed ban. These arguments may have merit, but they sidestep the real issue: Banning photography within the New York City subway system will not deter criminals or hamper terrorists. The proposed ban will only restrict the rights of law-abiding citizens and tourists.


Digital photography has become widespread, making cameras cheap, powerful, and small (concealable). Cameras are no longer easy to identify. They can be integrated into cell phones and personal digital assistants or concealed in hand bags, hats, or virtually any other object. Many digital cameras even come disguised as other objects—pens are a common example.


Anyone that wants to secretly take photographs inside the subway system may do so with little risk of being detected. Would a police officer be able to distinguish between the casual use of a cell phone or someone pretending to use a cell phone so that they may take a surreptitious photograph? Consider a businessman pretending to review email while taking a snapshot of a signal operations facility? Will law enforcement personnel spot a terrorist who has hidden a cheap, palm-sized digital camera inside a food or beverage container or wrapped it inside his coat? Would this terrorist simply give up if the act of photography were illegal?


Consider also that thousands, if not tens of thousands, of subway photographs are already available on the Internet, in books and magazines and through the municipal archives.


Banning photography under the pretense of security requires that police officers enforce the new rule. The time spent performing this extra duty is better spent patrolling critical parts of the system—those parts that the proposed ban is designed to protect. Posted notices near such facilities indicating a localized ban on photography could be both more effective and more efficient than a system-wide ban, although I do not personally believe even localized bans would deter a real criminal.


The subways need to be protected, but banning photography is a lame attempt at securing them. Law enforcement personnel don’t need to be distracted from their difficult jobs by constantly reminding unaware tourists on crowded subway platforms to put away their cameras, leaving anyone with a concealed camera to photograph other areas of the subway unchecked. Law enforcement training and regular patrols of key facilities are the only way to make the system safer.

Derek Vadala
Brooklyn, NY

Thoughts on the proposed photography ban?