My Hackergotchi

Updated: Never — Philip's Blog

Now featuring regular updates!

Tue, 15 Jun 2010

11:48 – What are they smoking?

My current activities occasionally need me to look at the kind of files GTKWave groks. Works well and all that, but this particular UI quirk is a little puzzling...

Stoned user interface

Mmhmm ... I'm sure this makes sense to the particular (special) kind of mind that writes GUI applications. Pretty amusing.

Sun, 02 Aug 2009

15:39 – Preparing for HAR

Christophe blogs (vaguely) about preparing and hardening laptops for (security) conferences. I wonder why a laptop shouldn't always be "hardened" though?

I've blogged before about how I prefer to use deterministic scripts over fragile background magic for configuring networking on my laptop.

The @conference script on my laptop is as follows:

#!/bin/sh

rm -f $HOME/@*

sudo iwconfig wlan0 essid conf_essid

sudo iptables -P INPUT DROP
sudo iptables -P FORWARD DROP
sudo iptables -P OUTPUT ACCEPT

sudo iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A INPUT -i lo -j ACCEPT
sudo iptables -A INPUT -p icmp --icmp-type 3 -j ACCEPT
sudo iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT
sudo iptables -A INPUT -p icmp --icmp-type 11 -j ACCEPT
sudo iptables -A INPUT -p icmp --icmp-type 12 -j ACCEPT
sudo iptables -A INPUT -p tcp --syn --dport 22 -j ACCEPT

sudo dhclient wlan0
tunnel

Instead of spending a lot of time identifying and disabling unnecessary services, I just drop packets I don't care about on the floor. Much simpler!

Christophe and others also forget to mention the following:

  • Be careful with ssh-agent forwarding. Remember that root on machines you forward agent connections to can pretend to be you using any of the identities loaded into the agent. If you have to run ssh-agent, don't allow it to be forwarded from untrusted machines. If you have to enable forwarding, don't load keys into the agent you don't need forwarded. (Of course you're not using the same SSH key for everything, right?)

Regarding physical security:

  • Use disk encryption. Don't rely on a screensaver when leaving your laptop unsupervised, just switch the machine off. Don't suspend either.
  • Don't carry unique copies of data you can't afford to lose on your laptop, have known-good backups at home. Make sure you have backups of your dotfiles too and that you can access them remotely. That may mean you need to take a copy of an SSH key on a USB stick too.
  • Take a (known to be working) bootable USB stick so you can reinstall your laptop if someone steals your disk or if you break it during the conference.

Common sense, I think?

Wed, 01 Jul 2009

22:23 – When will Firefox be able to print?

I run a business. This means I often have to print stuff for my accountant. I also feel that for the prices I charge my customers, the least I can do is send them an invoice on a piece of paper.

Unfortunately, Firefox still can't print.

With the exception of three countries (of which I am aware) everyone in the world uses ISO-standard A4 paper. For some reason however, Firefox continues to insist that I should be using "Letter" paper. I can't imagine where it gets this idea. It can't possibly be my "locale" (which is set to C) and I've certainly not configured this crazy papersize anywhere.

When will this be fixed?

I don't so much mind a default -- even if it's stupidly set to something only three countries in the world use -- if I could override it. I can click on "file" and on "page setup" until I'm blue in the face. The PostScript being sent to my printer continues to be wrong. Even if I "print to file", it's wrong. I can then fiddle with the PostScript to make it right, but I should not have to do that.

I really don't feel like grepping through the hundreds of megabytes of source code that Mozilla is to find where this silly papersize is coded to change it. Software should have sensible defaults. If software gives an option to override defaults, it should actually accept the override, not just ignore me.

Grumpy. Very very grumpy.

The web sucks. Browsers suck. I'm told that as technologies advance, humans regress as a form of self-defence. Have humans regressed too far? Is technology having to catch up with the dimwits?

Let's go back to simple.

Mon, 23 Feb 2009

22:33 – Coming to terms with awesome 3

A couple of months ago, I installed awesome 3. I initially held off upgrading for a while because some of the features scared me. It turns out it wasn't so scary after all, but I just didn't have time to properly adapt my world to the new config file format.

Tonight I finally took the plunge and kicked awesome 2 off my system to force myself to use awesome 3 and properly configured it.

Mostly, I just had to delete stuff I don't want from the default config file. For the time being, I'm also sticking with dmenu rather than using the awful (what's in a name?) prompt bits. The latter wants to rely on bash and that makes my teeth hurt. On FreeBSD systems I don't install bash at all and on Linux I move it out of my PATH where it can't hurt anyone. When I have another moment, I will take a look at making awful complete in a more sensible way.

I'm very happy with the way everything now nicely hooks into Lua. That means I can do away with the silly awesome-status script I had to run every minute to update my clock and some widgets.

I'll put my config files online eventually.

Tue, 23 Dec 2008

20:56 – Yearly cleanup

I spent much of today doing my annual "winter cleaning". For some reason, I have a feeling there should be a periodic script for this, preferably one which can read my mind.

Some notes:

  • Many files named "foo", "tmp", "t" and "_" (am I the only one who likes to redirect stdout to _ "to make it easy to delete"?)
  • A non-zero number of these files turned out to contain useful information. It seems I made that decision about some of the files earlier, because some were named "foo.keep".
  • Curiously, I found not a singled file called "1" this year. A break from tradition.
  • My "$HOME/tmp" directory contained more data than any other under my home directory.
  • I discovered many config files bearing a comment "mangled pph 20071223". A year to the day since the last winter cleaning, in other words.

Productive day! In a tidy sort of way.

I also found a number of local pkgsrc patches, but I think I've sent most of the relevant ones (ie: suitable for human consumption) to Geert for committing to pkgsrc and/or upstream. I'll go through those in a bit more detail tomorrow and Thursday.

Thu, 04 Dec 2008

12:14 – Static analysis junkie

I admit it: I'm a static analysis junkie. :-)

In addition to getting the FreeBSD Coverity builds into shape again (about which I'll have more to say again in a couple of days), I use FlexeLint fairly religiously on most of my code. Everyone should decide for themselves if running a lint is worth it but for myself, I can say with full confidence that it improves the quality of my code.

Of course, FlexeLint is fairly expensive if you don't have anyone to pay for it for you. There are free alternatives however, like splint or even the venerable xlint by Jochen Pohl or one of the ancient lints included with certain Unix operating systems I won't name.

Recently, Gimpel have released a new version of FlexeLint. One of the main new features in this version is thread analysis. It is nowhere near as thorough as Coverity (I wouldn't expect it to be), but it's remarkably good at checking for balanced locking -- every lock needs an accompanying unlock -- even across fairly tricky code paths.

Over the past couple of days, I've been setting the new version loose on some multithreaded code I wrote a while back (some of which has been fairly widely deployed with few reported bugs) and it has been finding some surprising issues. Surprising in the sense of how can this ever work?! even. Concurrency is a funny business.

If your only excuse not to run static analysis is fear of the copious output a first lint run generates, perhaps you should reconsider. That's often "only" a matter of proper configuration -- which admittedly is a bit of a black art.

Maybe the bugs of the month on Gimpel's website can turn you into a static analysis junkie too?

Tue, 14 Oct 2008

18:42 – Running my own Jabber server

Waiting for other (useful) stuff to compile today, I spent some time setting up my own Jabber server. I've had jabberd compiled on a machine for a long time, I just hadn't gotten around to setting it up yet.

This was surprisingly simple, except for the SSL bits. I spent a good half hour wondering why BitlBee refused to connect with a very strange message:

jabber - Couldn't log in: Stream error: host-unknown: service requested for unknown domain

Turns out that the example <id... parameter in c2s.xml was formatted in such a way to make it non-obvious that I also had to change an example.net on the last line:

<id realm='example.net'
    pemfile='/usr/local/etc/jabberd/server.pem'
    mumble-mumble
>example.net</id>

Silly of me. Even sillier of me to have hacked XMPP STARTTLS support into OpenSSL s_client to try to debug it... As soon as I saw the example.net, a simple grep found the config bug immediately. Difficult works too. :-)

If anyone is interested, the patch is here: openssl_xmpp.diff.

I'll try to con Ben into including that upstream. :-)

Anyway - please replace philip@jabber.belnet.be with philip@paeps.cx on your Jabber roster.

Tue, 07 Oct 2008

10:05 – There are 10 types of people in the world

I've been quiet. Mmhmm.

Currently, I'm rewriting an application for a customer which is presenting me with at least a couple of WTFs every day. Most recently, I've been puzzling over the original author's creativity in decoding a binary protocol without using bitwise shift operators.

Everywhere you would expect "shift left by n bits", there is a "multiply by 2^n". This makes understanding the protocol a bit tricky because the brain wants to be in "it's a number" mode rather than "it's a stream of bits" mode.

Of course, the original application is rife with sign-bugs too. :-)

In other news, it appears that I'll be giving a talk at EuroBSDcon. Warner won't be able to make it to France next week, so I will give his "Embedding FreeBSD" talk. I spent a good part of the weekend working on that.

Busy busy.

Wed, 20 Aug 2008

19:12 – French code

An application I've recently inherited is making my eyes bleed. Its authors felt it would be a good idea to write the application in "French C". All the comments are in French, and there are wrapper functions (like boucle) for for "English" C constructions.

I've said it before: localization sucks. French is a very nice language but not for software. Software is written in C and C looks a bit like English.

Live with it.

Fri, 25 Jul 2008

15:46 – Story of my life

After two days of staring at a particularly nasty bug, this feels strangely appropriate...

Good comments are essential to deliver high quality.

Of course, I would never write bad comments. Ahem.