Postfix on Ubuntu 12.04 with Comcast

After having had Ubuntu 12.04 installed for months, I finally moved my old Fedora services over to it, including Postfix. Here’s how I configured it.

I configured /etc/aliases so that local email destined for ‘root’ (including regularly scheduled system cron jobs) is delivered to my local account, instead of being sent to root@comcast.net (they don’t appreciate getting my SPAM):

root: myusername@localhost

I added the following to /etc/postfix/main.cf. Notice that I appended a “.NOT” to the relayhost. I did this initially so that I could send test email messages, and make sure message delivery was correct, before allowing email to go to my ISP. More on this later.

alias\_maps = hash:/etc/aliases
alias\_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, localhost.$mydomain, localhost, robinson-lin
relayhost = [smtp.comcast.net.NOT]:587
smtp\_sasl\_auth\_enable = yes
smtp\_sasl\_password\_maps = hash:/etc/postfix/sasl\_passwd
smtp\_sasl\_security\_options =
sender\_canonical\_maps = hash:/etc/postfix/sender\_canonical
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox\_command = /usr/bin/procmail -a "$EXTENSION"
mailbox\_size\_limit = 0
recipient\_delimiter = +
inet\_interfaces = loopback-only

I added the following to /etc/postfix/sasl\_passwd:

smtp.comcast.net MyUsername:MyPassword

I added the following to /etc/postfix/sender\_canonical:

jaredrob MyUsername@comcast.net

I ran the following commands:

  chmod o-r /etc/postfix/sasl_passwd
  postfix check
  postmap /etc/postfix/sasl\_passwd
  postmap /etc/postfix/sender\_canonical
  postalias /etc/aliases

Next, I tested my email configuration by sending test email messages (using ‘mutt’ or ‘mail’)…

  1. From my local linux account to my local linux account, to make sure local delivery worked and didn’t get sent to my ISP.
  2. From the local ‘root’ account to my local linux account.
  3. From the local ‘root’ account to my local ‘root’ account, to make sure it was forwarded to my local user account (remember /etc/aliases?)
  4. From my local account to an external account (gmail, etc.)
    1. I didn’t expect it to be delivered at this point. Remember the “.NOT” I added to my relay host? This way, I was able to see where outbound email was destined using “mailq”. This saved me grief because I found misconfigurations that would have lost the email.  I used ‘postsuper -d ALL’ to delete all test messages from the queue.
    2. When I knew delivery was destined for the correct machines, I removed the “.NOT” from main.cf, and ran “service postfix reload” (as root).
    3. Next, I sent email to an external email address, and made sure it was delivered

Then I configured and ran ‘fetchmail’ briefly (hitting CTRL-C after a few were downloaded), and made sure messages were delivered to my local account properly. I’ve been pleased using Ubuntu with postfix, fetchmail and procmail and archivemail. I often log in remotely using SSH and use mutt to read my email. I also use Google Mail. I’ve set up rules to forward some email to my ISP account, which get downloaded using fetchmal via cron job.

Why do I bother saving my email to my local machine? I like redundancy and backups, I like the speed of using a command line email reader, and I have ten years of email archived on my local machine. It’s been very useful to be able to search through that email for old software license keys, website passwords, email addresses and such.

Backpacking in the Uintahs

In July, my oldest son and I went backpacking into the Uintahs for three days, thanks to the “can-do” attitude from my father-in-law. It’s been twenty two years since I’ve been to the Uintahs, and I was nervous about my ability to hike nine miles, as well as for my nine-year old. We went on practice hikes to prepare. My old external frame backpack was still in mostly working condition, except that the mesh backing had become loose. Apparently, not even nylon lasts that long when “tight”. So I bought a used internal frame backpack and used it instead.

From everything I read, good quality socks were the most important part of backpacking comfort, so we bought morino wool socks. They kept our feet dry, comfortable and blister free. It took us nine hours to hike the beautiful trail, and it felt so good to make it to camp and to eat dinner.

We packed as light as we could, and instead of a camera, I brought my iPod. This was one of the times I wished I had a smartphone with more pixel density. I put it in a ziplock back to protect it from the elements, or from a leaky water container.

The second day, we did a day trip of eleven miles, attempting to reach the top of Mount Emmons at 13,440 feet. We climbed up the boulders of the mountain, and walked across the crest of the mountain. It was also a giant boulder field, above the timber line, and it’s amazing that anything grows there in such a harsh climate. Giant spiders were plentiful, and their webs were impressively strong. We avoided them when we could, and broke others, sending their inhabitants scurrying. The ground cover was a hardy, crunchy variety. The yellow flowers gave it a rugged beauty. We occasionally heard the bark of a dog from one of the lakes far below.
We reached about 13,000 feet and spotted a white, hairy mountain goat. My energenic brother-in-law, Dan, went ahead of us. We were out of breath in the thin air and stopped frequently. We communicated with Dan via radio. We ran out of time to make it to the top, unless we wanted to hike back in the dark or spend the night on the mountain, so we turned back. Dan passed us on the return trip, and we saw his head bobbing up and down on the boulders a mile or more ahead of us. Later, we noticed that we got sunburned more quickly than at lower altitudes.

At one point, Dan picked up a stack of layered sandstone rocks and carried them so as to slow himself down.

The last mile before we got back to camp, I felt like I could lay down in one of the few flat places, in the dirt, and go to sleep. We kept going and made it back to camp. We boiled water with my 20-year-old MSR whisperlite stove, and my in-laws boiled their water with a new alcohol stove. My son and I enjoyed rehydrated chicken and potatoes for dinner.

Amusingly, as tired as I was, I couldn’t sleep until nearly 3 A.M. because my Walrus backpacking tent was too hot. So I read from the scriptures on my iPod, and typed out some of our experiences on the iPod touch-screen keyboard while laying in my tent.

During our hike back to the trail head on the third day, we passed a forest ranger riding a horse, as well as an entire family riding their horses for a day trip. I was a bit jealous, since my back was in pain. For the last two miles, I carried my son’s pack in my arms, which counter balanced me so that there was no back pain. We were also able to keep up a quicker pace that way. Reaching the trail head felt great. Taking a shower forty five minutes later felt even better.

Our next adventure is to hike Mount Timpanogos.

The Missing PrintMaster Address Book

Janice got frustrated tonight when her address book disappeared.

She had been using PrintMaster to add address book entries so she could print mailing labels, and the addresses reportedly disappeared. When I looked at it, PrintMaster couldn’t find an address book. Janice mentioned that we used it to print mailing labels a few months ago. Since PrintMaster stores its address book in an unspecified location, I went searching the file system for the address book, knowing that it had to be somewhere.

Since I’m a Linux and shell scripting regular, I resorted to comfortable tools: Cygwin bash and find. I didn’t find file names containing the word “address” in her home directory, so I searched my user’s home directory. Nothing. I searched c:\Users\Public and one I created, c:\Users\Shared. Still nothing.

So I searched the entire C: drive, and found C:\ProgramData\Broderbund Software\Print\PrintMaster\Books\ADDRESS.ABK

Interestingly, I couldn’t open it from Janice’s account — permission was denied. There were no permissions on the file. So I started my cygwin shell as Administrator, and then I could view it. I made a copy of the file and used cacls to give Janice access to the file:

cacls.exe JaniceAddress.ABK /e /g "Janice":f

At that point, PrintMaster was able to find and use the address book.

Now that I think about it, I could have run Explorer as Administrator, and the security tab of the file properties window would have been easier to use than cacls.

Why Linux?

I’ve acquired a used desktop computer with 6GB RAM, and I’ve been trying to figure out whether to put Linux or Windows 7 on it in the long term. I’d like it to be useful to the whole family.

Windows 7 is great for playing DVDs, Youtube movies, doing Netflix streaming, games, printing to our aging Kodak EasyShare 5100 printer, syncing with my iPod Touch, and it has a fantastic photo screensaver. Some of our favorite applications are available for Windows, but not Linux.

Windows has great parental control software available — via it’s built-in controls, or via third party software. We limit the amount of time our children can be on the computer each day, and we limit the kinds of websites they can visit.

Linux, on the other hand, costs less and supports the sound card and the graphics card better than Windows. And much to my surprise, Linux now supports our Kodak printer (but not its scanner).

There are several Linux distributions available, and I’ve tried Fedora 17 and Ubuntu 12.04 on this machine in their 64 bit variants. Both are well supported by a vibrant community and by commercial companies.

Fedora doesn’t play DVDs, has trouble with some Youtube videos, can’t stream Netflix, doesn’t have parental controls, doesn’t sync with my iPod Touch, and doesn’t even include a screensaver — just a screen blanker (thanks to the unfinished state of its shiny new-and-highly-immature desktop, Gnome 3). It’s possible to rectify many of these limitations, but it takes time to find and configure the software. Netflix streaming isn’t an option. Getting a photo screensaver requires the use of an alternate desktop environment, like KDE or XFCE. In short, Fedora isn’t family desktop ready.

Ubuntu has most of the same limitations as Fedora, but its desktop experience is more polished and the online help is phenomenal. The Ubuntu Software Center not only has application ratings, but can also recommend other apps. Ubuntu automatically told me there were proprietary ATI drivers available, and it was painless to switch to them, with enough improvement in accelerated performance to make it worthwhile. Ubuntu has parental controls in the form of Gnome Nanny, but it doesn’t work with 64 bit Linux, although a web browser extension is an option.

So why do I bother with Linux? It’s an exceedingly useful swiss army knife, runs blazingly fast, and doesn’t slow down over time when software is added. I’m heavily invested in it, and it gives me a technical edge in the workplace. There are thousands of interesting tools that are easy to install — Inkscape, Gimp, meld, Chromium and others. Linux has full featured, freely available development tools for C, C++ and Java — not crippled ones. And it’s multi-user enabled via ssh, remote-X, vncserver, or NX server. Mail servers, web servers and other servers work extremely well. With Linux, it’s easy to see what application or service is slowing down my computer with ‘top’ or ‘iotop’, whereas in Windows, it’s obscured because services run as threads in svchost. I love Linux Live CDs for troubleshooting computer problems, testing hardware and internet connections, and for recovering data from broken Windows installs.

So Linux is great for me as a software developer, but I’m not convinced that Ubuntu, Fedora or any other Linux distribution deserves to be a family desktop environment.

 

HTC Vivid with Ice Cream Sandwich

A few weeks ago, I was able to borrow an HTC Vivid. I upgraded it to the latest version of Android: Ice Cream Sandwich. My overall verdict is that I like it, almost as much as iOS 5. Android is more polished than ever before.

Here’s what I like about the HTC Vivid ICS experience:

  1. Bluetooth keyboard support. Android ICS is the first release that supports my bluetooth keyboard, and that’s a killer feature for me. The GMail app is the worst when using the keyboard, because the keyboard suggestions pop up over the top of what I’m typing, which is very annoying. The other apps, including ColorNote, pop up suggestions just above the words that I type.
  2. Smoother Dropbox integration. Apps integrate with it far more easily by sharing files on the filesystem. This means that it’s much easier to keep my password database synced between computers than on my iPod Touch — I don’t have to think about it.
  3. One device instead of three. The Vivid has the functions of my iPod Touch, my Sansa Clip (FM Radio and Ogg Vorbis support), and phone. It’s easier to carry around one device and charge one device instead of three. On the other hand, it has to be charged more frequently than my iPod and my feature phone. The Sansa Clip is better for exercising because it’s so lightweight.
  4. Faster web experience, especially with web pages utilizing heavy JavaScript.
  5. Better web experience. The larger screen makes it easier to read web pages, books and email. Apple’s browser zooms in and out on the correct regions much better using double tap than does Android’s browser. It’s more convenient to watch YouTube videos on a larger screen and a faster CPU.
  6. Much nicer camera than the iPod Touch.
  7. Power usage stats, per application. The screen uses the most power by a wide margin.
  8. Network usage metering and control per app.

Here’s what I like better about iPod Touch:

  1. Apps are all on the desktop by default, instead of buried.
  2. No costly data plan.
  3. Easier to use apps. Most apps that can be found for both devices are easier to use on iOS than on Android, and they usually have more features on iOS.
  4. Better email app than Google’s Gmail app on Android. The Gmail app is too busy, and I haven’t figured out how to mark messages as unread.
  5. I find the iOS keyboard easier to work with.

When CTRL-C in gdb shuts down a program insted of interrupting it

According to The Linux Programming Interface, a well-behaved multi-threaded UNIX program should use sigwait() or sigwaitinfo() instead of signal() or sigaction(). A linux-only program could even use signalfd().

Unfortunately, Linux/UNIX programs using sigwait() are hard to interrupt in the debugger. Instead of interrupting the program, it terminates the program. How does one work around this problem? See my answer on stackoverflow.

 

Autojump: Faster than ‘cd’

Here’s a cool tool: autojump, written by Joel Schaerer (thanks, Joel). I spend much of my day as a programmer navigating around in the linux filesystem. Built-in tools like ‘pushd’ and ‘popd’ are nice, as are subprocesses — e.g.

 (cd ~/Download && wget http://somewhere.com/path/to/file)

… and when it finishes downloading, I’m still in the directory I was in before the download was started.

Now there’s autojump to add in to the mix. After I ‘cd’ to various directories, later, I can type ‘j Down’ to cd to my Downloads directory. Very convenient. I just wish it were built into every distribution of linux.