Category Archives: Computing

Hardware, software, computer science and the rest

My Keyboard is shouting

When I came home from work on monday I couldn’t login into my computer because all the letters i typed came out in uppercase. I pressed the caps lock and all the shift keys multiple times which had no effect. I removed and reinserted the USB dongle but the problem remained. I rebooted my computer but that didn’t help either. I finally power cycled the keyboard by removing the battery which also didn’t solve the problem. I was really annoyed at this point and had to get out my old keyboard as a temporary replacement. To be sure I also tried the broken keyboard on our laptop where I got exactly the same problem.

Silke and I tried to disassemble my keyboard, a Logitech diNovo Mac Edition Keyboard, but failed to open the case. Silke managed to remove the key caps of both shift keys but we couldn’t spot any defects. We finally had to give up and declare the keyboard a loss. This is quite disappointing considering that I bought that keyboard less than two years ago.

As Logitech are not selling any Mac keyboards at the moment and I wasn’t sure whether I wanted another one anyway I decided to buy an original Apple keyboard. I use the same keyboard at work and  get along with it quite well. Fortunately you can just order keyboard in US layout (and not only in International English) in Apple’s UK online store these days.

I was quite pleased when the Apple Store promised to deliver the keyboard within two days using the standard delivery method. I was even more pleased when the keyboard really turned up today. I really wish that Amazon UK’s delivery service was anyway near as quick as that.

Anyway, I’m happily typing along on the keyboard and now all is good.

Using S.M.A.R.T. under NetBSD

NetBSD has supported S.M.A.R.T. for a long time. But this functionality is well hidden. You can enable S.M.A.R.T. and check a single disk like this:

# atactl wd0 smart enable
SMART supported, SMART enabled
# atactl wd0 smart status
SMART supported, SMART enabled
id value thresh crit collect reliability description                    raw
1 200   51     yes online  positive    Raw read error rate            0
3 151   21     yes online  positive    Spin-up time                   9441
4 100    0     no  online  positive    Start/stop count               16
5 200  140     yes online  positive    Reallocated sector count       0
7 200    0     no  online  positive    Seek error rate                0
9  89    0     no  online  positive    Power-on hours count           8477
10 100    0     no  online  positive    Spin retry count               0
11 100    0     no  online  positive    Calibration retry count        0
12 100    0     no  online  positive    Device power cycle count       15
192 200    0     no  online  positive    Power-off retract count        4
193 134    0     no  online  positive    Load cycle count               199998
194 114    0     no  online  positive    Temperature                    38
196 200    0     no  online  positive    Reallocated event count        0
197 200    0     no  online  positive    Current pending sector         0
198 100    0     no  offline positive    Offline uncorrectable          0
199 200    0     no  online  positive    Ultra DMA CRC error count      0
200 100    0     no  offline positive    Write error rate               0

While this is very useful for manual checks it doesn’t provide automatic health reporting. And the recent abrupt failure of the backup hard disk in a friend’s machine reminded me of the importance of such monitoring. I therefore decided to implement an automated solution on top of NetBSD’s S.M.A.R.T. support.

The first step was to enable S.M.A.R.T. at system startup. I added the following lines to /etc/rc.local to make that happen:

echo "Turning on S.M.A.R.T.:"
for disk in $(sysctl -n hw.disknames | tr " " \\n | grep ^wd)
do
        echo -n "${disk}: "
        atactl $disk smart enable
done

Now I only needed something that checks the reported metrics every night. I therefore added the following snippet to /etc/daily.local:

found=
for disk in $(sysctl -n hw.disknames | tr " " \\n | grep ^wd)
do
        relocated=$(atactl $disk smart status |
          sed -n -e 's/.* Reallocated sector count[^0-9]*//p')
        if [ $relocated -gt 0 ]; then
                if [ -z "$found" ]; then
                        found=true
                        echo ""
                        echo "SMART checks:"
                fi
                echo "Disk $disk has $relocated relocated sectors."
        fi
done
unset disk found relocated

The above shell code reports any IDE and SATA hard disks with relocated sectors. If a hard disk reports a lot of relocated sectors or their number is growing quickly in a short time frame the disk will probably fail very soon.

Let’s hope that this way I will get an advance warning before the next major catastrophe.

Automated attacks against Postfix

Yesterday evening I discovered thousands of lines like these in my server’s mail logfile:

Jun 12 08:58:37 colwyn postfix/smtpd[25605]: warning: unknown[212.154.6.176]: SASL CRAM-MD5 authentication failed: PDM3MjM3NzE1Mzk1NjU1MDEuMTMwNzg2NTUxNUBjb2x3eW4uemhhZHVtLm9yZy51az4=
Jun 12 08:58:44 colwyn postfix/smtpd[25605]: warning: unknown[212.154.6.176]: SASL CRAM-MD5 authentication failed: PDU0MDA0NDczMjgzNjU2NDAuMTMwNzg2NTUyMkBjb2x3eW4uemhhZHVtLm9yZy51az4=
[...]
Jun 12 23:00:15 colwyn postfix/smtpd[12864]: warning: unknown[212.154.6.176]: SASL CRAM-MD5 authentication failed: PDQ2NjM4MzI0NTAyNTQ2ODIuMTMwNzkxNjAxM0Bjb2x3eW4uemhhZHVtLm9yZy51az4=
Jun 12 23:00:26 colwyn postfix/smtpd[12864]: warning: unknown[212.154.6.176]: SASL CRAM-MD5 authentication failed: PDMxMTA4OTY1MjgzOTM0OTkuMTMwNzkxNjAyNEBjb2x3eW4uemhhZHVtLm9yZy51az4=

It looks like somebody has written a program which tries to exploit a security vulnerability in Postfix’s Cyrus SASL component.

Fortunately NetBSD isn’t affected as the bundled Postfix binaries don’t include Cyrus SASL support. But if you are using Postfix 2.8.2 or older from pkgsrc with the sasl option enabled you should update to Postfix 2.8.3 or newer as soon as possible.