Archive for the ‘software’ Category.

Firefox 3.5 and DNS Prefetches

Perhaps not a very new feature, but Firefox 3.5 prefetches de DNS results of all links on a page.

What does this mean? That firefox does a lot of DNS requests in cleartext(no encryption)  for all links in a website, even if the page itself is encrypted, on a local network or is a local file. When viewing secure pages it then leaks information on what page you are looking at (e.a. if you do a lot of .indymedia.org dns requests, you’re probably looking at the indymedia.nl frontpage), same for pages on an intranet.

For people using webmail, this also means someone(for instance a spammer) can implement a callback/phonehome method by putting a domainname in the mail and whith a 0 cache value.

I’d consider this a bad policy, luckily you can turn it off, but not too easy.
A short howto:

go to the page “about:config”, it might give you a warning about voiding your waranty, I don’t think you have any anyway, so go ahead.

  1. Rightclick on something white in the page and select new->boolean
  2. Name the boolean: network.dns.disablePrefetch
  3. Set the value to True
  4. Rightclick again on something white and select again new->boolean
  5. Name the boolean: network.dns.disablePrefetchFromHTTPS
  6. set the value to True

If you now type network.dns in the filter you should see 2 entries in bold with the names you’ve given them (network.dns.disablePrefetch and network.dns.disablePrefetchFromHTTPS) of the type ‘boolean’ with the values set to ‘true’. Your firefox should now no longer try to fetch lots dns results and it’ll improve your privacy a little bit.

For those running apache webservers, you can control it from the server-side by doing the following:

  1. Enable mod_headers (a2enmod headers)
  2. Add this line to your apache or virtual host configuration: Header add x-dns-prefetch-control “off”
  3. Restart your webserver

For those only having control over the HTML you can add the following to your <head></head> section:

<meta http-equiv="x-dns-prefetch-control" content="off">

Wii Presenter

Just created a small page for packages I build: Packages
Main reason for this is the making and publishing of my wiipresenter packages, Wiipresenter is nice tool for doing presentations with the WiiMote, it’s not finished yet, but works quite well already. Sadly though, the original makers don’t do much about them, but Dag Wiers made some patches to get them to work on recent systems, and packaged them in RPM. Since I don’t use any RPM based systems I build some debian packages for it.
So Wiipresent runs in a terminal still, but intelligently guesses the application in current focus to adapt it’s functionality to it. In openoffice presenter you navigate through the slides, in firefox you can switch your tabs and scroll through the pages. When pressing A+B in any application it toggles the mouse control with the motion sensor. It can also resize text, switch between applications(like alt-tab) and much more.

Great application, and now also as a debian package, i386 and amd64.

New Perl module

Released a small new perl module, it isn’t extremely unique. But it does do what I want in what I think is the best way. And hopefully also accoording to others.

It’s called Hash::Mogrify and provides a couple of nicely formatted and overloaded functions.

  • kmap provides a map like function for keys
  • vmap a map like functions for values
  • hmap does it for both keys and funtions
  • ktrans is like kmap but works through a translation hash instead of a code block.

I’ve already released a 0.02 version with some added features that where requested. If you have some cool sugestions for what it should do, let me know and I might implement them.

Ofcourse you can find it on CPAN

Playing arround with X11::Aosd

So in my desire to map some ACPI buttons on my thinkpad, I noticed this ‘battery’ button (Fn+F2). I thought it would be nice if I get this nice graph showing me my battery state.

Sadly osd_cat only does bars and text, and I wanted a nice pie or something. So I looked around for perl modules which could do more. In comes X11::Aosd.

X11::Aosd is a Cairo powered OSD interface which works quite nicely. As it’s an XS module it works fast and efficient, but as usual lacks in -proper- usage documenation.

The script I ended up writing (which called by another script that actually read the battery info) became as followed:

#!/usr/bin/perl -w
use strict;
use Getopt::Long;
use X11::Aosd ':all';

my $per   = 100;
my $mx    = 200;
my $my    = 200;
my $text;

my $res = GetOptions("percentage=i" => \$per,
                     "xoffset=i"    => \$mx,
                     "yoffset=i"    => \$my,
                     "text=s"       => \$text,
);

my $pi = 3.14159265358979;
my $rad = ((2*$pi) / 100) * $per;

my $aosd = X11::Aosd->new;

$aosd->set_transparency(TRANSPARENCY_COMPOSITE);

$aosd->set_position_with_offset(
    COORDINATE_CENTER,
    COORDINATE_CENTER,
    200, 200, 0, 0
);
$aosd->set_renderer(sub {
    my ($cr) = @_;
    $cr->set_source_rgba (1, 0.6, 0, 1) if($per < 30);
    $cr->set_source_rgba (1, 0, 0, 1)   if($per < 10);
    $cr->set_source_rgba (0, 1, 0, 1)   if($per >= 30);

    $cr->set_line_width(10);
    $cr->set_line_cap('round');
    $cr->arc(100, 75, 70, 0, $rad);

    $cr->line_to(100,75);
    $cr->line_to(170,75) if($per < 100);
    $cr->stroke;
    $cr->fill;

    if($text) {
        $cr->move_to(0, 175);
        $cr->select_font_face("Sans", 'normal', 'bold');
        $cr->set_font_size (23);
        $cr->show_text($text);
        $cr->fill;
    }
});

$aosd->show;
$aosd->loop_once;

It’s a simple piece but it works. I kinda like X11:Aosd even though it’s less then perfect docs, toghether with the original cairo docs you get a nice idea. Maybe more examples later.

btw, Thinkpad F<n> acpi buttons(Fn+Function) are quite simple in their acpi mapping: 00000080 00001003 is F3, 00000080 00001002 is F2, etc

Another Thinkpad script, volume.

I was missing my volume buttons on my thinkpad, I’m sure the default flavours of (XU|KU|U)buntu handle this nicely (can’t say I checked though ;). But since I run ion3 I get none of that fluffyness.

There are ofcourse already some onelines and scripts outthere that fix this problem, and I certainly copied from them what was useful, but I wanted my OSD feedback. So I wrote the following script, not fancy but it works.
It depends on the following packages:

  • perl
  • alsa-utils
  • xosd-bin

/usr/local/bin/ibmvolume.pl

#!/usr/bin/perl -w
use strict;
## Script made for Lenovo Thinkpad X61s
## for different cards you might need a different numid.

my $nvol  = '28';
my $nmute = '29';

my $volinfo  = `amixer cget numid=28`;
my $muteinfo = `amixer cget numid=29`;

my ($min, $max, $cur) =
    $volinfo =~ /.*min=(.+?),.*max=(.+?),.*values=([0-9]+).*/si;
my $per = int($cur / ($max / 100));

my ($mute)  = $muteinfo =~ /.*values=([a-z]+).*/si;
my $invmute = ($mute eq 'on') ? 'off' : 'on';

if($#ARGV < 0) {
    print "Min: $min, Max: $max, Cur: $cur($per%), Mute: $mute($invmute)\n";
    print "Usage: $0 (up|down|mute|show)\n";
    exit 1;
}

my $command = shift;

my %controls = (
    up   => "amixer -q cset numid=$nvol ".($cur+1),
    down => "amixer -q cset numid=$nvol ".($cur-1),
    mute => "amixer -q cset numid=$nmute $invmute",
);

system($controls{$command}) if $controls{$command};

my $cmute = ($command eq 'mute') ? $invmute : $mute;

my $font = '*-lucidatypewriter-bold-r-normal-sans-24-240-75-75-m-140-iso8859-1';

system("osd_cat -b percentage -f $font  -c green -A center -o 600 -d 1 -T 'Volume($cmute):' -P $per &");

Sadly the osd_cat tool can wait no shorter than 1 second, I would’ve liked something more like 0.5 second.

This now works from the commandline, taking commands like ‘up’, ‘down’, ‘mute’ and ’show’. Now one can use something like ‘xbindkeys’ to link it to key events like ‘XF86AudioRaiseVolume’ and ‘XF86AudioLowerVolume’.

But I just put the following code in my (lua) config for ion3:

~/.ion3/cfg_bindings.lua

defbindings("WMPlex.toplevel", {
    kpress("XF86AudioRaiseVolume", "ioncore.exec_on(_, '/usr/local/bin/ibmvolume.pl up')"),
    kpress("XF86AudioLowerVolume", "ioncore.exec_on(_, '/usr/local/bin/ibmvolume.pl down')"),
    kpress("XF86AudioMute", "ioncore.exec_on(_, '/usr/local/bin/ibmvolume.pl mute')"),
})

And don’t forget to reload ion3 afterwards :)

Simple but useful ACPI + Thinkpad script

I always got anoyed when X crashed, or hanged and I couldn’t do anything anymore, while I knew the rest of the system was still functional and I should be able to get my screen session back.

The ‘easy’ way for this would be to SSH into your workstation, but I like to keep sshd turned off on those machines. preferably no external services on workstations at all actually.

Now I have a Thinkpad, and Thinkpads have this ugly Thinkpad/Thinkvantage button, especially ugly in it’s inner workings, and because of that it’s useful here.

The Thinkvantage button is not a keyboard event (which at this point is controlled by a broken Xorg) but it’s polled by the ACPI daemon, which runs as root. So when you press the button, an ACPI event is generated, which can have scripts linked to them.

A quick fix would be to put ‘chvt 2′ in the /etc/acpi/thinkpad-thinkpad.sh script on debian. But I wanted a little more and  changed it to the following:

/etc/acpi/thinkpad-thinkpad.sh

#!/bin/sh
CURVT=`/bin/fgconsole`
NEXTVT=`expr $CURVT + 1`

if [ $NEXTVT -gt 8 ]; then
    NEXTVT=1
    echo "looped back to: $NEXTVT" >> /tmp/nextvt.log;
fi

echo "Current VT: $CURVT, Next VT: $NEXTVT" >> /tmp/nextvt.log
if [ "X$NEXTVT" eq "X" ]; then
    /bin/chvt 2;
else
    /bin/chvt $NEXTVT;
fi

So this actually loops through terminal 1 t/m 8, without needing the keyboard-driver.

(don’t forget to reload acpid after chaning any of the scripts).

Non-descriptive errors

I’m sure the problem was in my initial setup. But errors like this really need to be fixed at some point.

Now I run iceweasel(firefox) in a terminal, because I’ve had issues before and firefox is not the kind of program that well, for some reason not really tries to give errors to it’s users. So instead they just send everything to STDOUT or STDERR.

So I setup a fresh system and noticed sound in flash wasn’t working, and my terminal gave me the following message:

ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:3513:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:3513:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:3513:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:3985:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2144:(snd_pcm_open_noupdate) Unknown PCM default
ALSA lib pcm_hw.c:1240:(_snd_pcm_hw_open) Invalid value for card

Now, what this tells me, is that some function, related to alsa is giving ‘no such file or directory’. Apparently something doesn’t exist. But when I start alsamixer, this works. OSS emulation also seems to work. All the right modules apear to be loaded. So I wonder what could be missing?

Now what I didn’t think of the beginning was that I tested alsa under root, and as soon as I noticed nothing with alsa worked as a user. I began to think about permissions and group membership. Which was indeed the problem, I forgot to add myself to the audio group.

All nice and dandy, and I’ve got sound now everywhere I want it. But the biggest issue remains, nothing was missing. as far as I can see there where no ‘files’ that didn’t exist. Which is what the error message seemed to complain about.

I think firefox or iceweasel has a long way to go as far as ‘user friendlyness’ is concerned. I’m sure their clean install doesn’t have this problem due to the lack of any sound support. But with the current web that doesn’t sound to useful. A good clean and clear way of informing users is a must I think, and it doesn’t apear to be there yet.
</rant>

Obscure mplayer problems

Since a little while now, I used to have the problem of the music skipping in mplayer. I guessed bad audio or crappy I/O, but I never noticed any errors anywhere.

What was happening was that when I moved my laptop, bumped against the laptop or table it was standing on it would skip or rewind the music. Sometimes a little, sometimes a lot.

Now I have a Thinkpad X40 and it only happened with mplayer, no other audio/video player.

Since yesterday I finally realised the problem after confirming it was related to me bumping against the table/laptop.

Continue reading ‘Obscure mplayer problems’ »

Remote controlling machines

As most system administrators with many machines in their herd, I am in need of a way of mass maintaining my systems. There are ofcourse quite a bit off tools for this job already available. Most are aimed at fancy enterprise setup where money is no problem, or large clusters where all your machines are the same. They usually also require a pre-installed client on the machine.

I don’t like daemons running on my server. If I had my way I’d turn everything on the servers off. Every port open, is an extra door that needs to be secured and can contain holes.

For the public services I don’t have much choice, my boss wants to provide certain things to certain people. So those I can’t close.

On the administrative side I’ve got more control. Most of my servers now have 2 ‘backdoors’ SSH and Munin, both are secured. Still, I’d rather have 1 ‘backdoor’, certainly not 3.

Munin doesn’t allow you to control anything on the machine, only read. which is fine. None of the tools seem to provide a way to read munin data, so those are out of the question. I used to use SSH + RSA-keys, this gave way too much power to 1 machine in my network though.

So I came up with a simple solution. I haven’t found anything only that does this, but I haven’t looked very hard either.

A very limited shell, a configuration file defines what you can do (can be updated remotely, when given a password). Runs as a simple user, powers can be extended with sudo if desired. This still requires deployment ofcourse, but I like it’s simplicity.

The script can be downloaded from here: http://u2m.nl/software/perl/mcp-client. It’s written in Perl and only depends on Digest::MD5, which is delivered by default in perl 5.8 and later.

Comments & Sugestions welcome ofcourse.

HealthMatrix Screenshots

I wasn’t all too clear it seems in my last post as to what health matrix is. Therefor I made some screen shots and hope they help.

In short, it monitoring. 1 cell = 1 test. you edit cells by clicking on them, give it a script (bash, python, perl aslong as the system knows it). give it an interval, a type, maybe a mail adres. and save it. When it has run atleast once, you can also check it’s output.

HealthMatrix example

HealthMatrix example


Continue reading ‘HealthMatrix Screenshots’ »