Pyrrhic Victory Dance

November 18th, 2006 by pim

I hate to be the one saying I told you so, but I told you so. Hardware security is only now starting to get some serious consideration. Unfortunately, I think TPM and other hardware-lockdown systems that are currently being considered have too much focus on subverting user control, they are ultimately bound to be factors of aggrevation, not mitigation, when it comes to such new threats.

Threads and your uid/gid

November 16th, 2006 by pim

First of all, what is up with the Debian 2.4 kernel? I’m glad that Etch will default to 2.6, but the 2.4 kernel that has been with Debian for so long is just plain Ghetto. Running multithreaded applications on a non-NPTL kernel is atrocious. But, on a positive note, running into this trailer park kernel on a machine that was upgraded to Etch from an earlier version, all this did point me to an interesting tidbit about using setuid and friends: If you want to use these to drop privileges, make sure you do this before you start any threads or madness will ensue.

dpkg version sorting

November 16th, 2006 by peter

Use this as you would use | sort | to sort package names according to dpkg versioning logic:

#!/usr/bin/perl
sub dpkgcomp
{
return 1 if(system(”dpkg –compare-versions $a lt $b”));
return -1 if(system(”dpkg –compare-versions $a gt $b”));
return 0;
}
@l = <>;
chomp(@l);
@s = sort dpkgcomp @l;
print join(”\n”, @s), “\n”;

php: isUrlOffline( $url )

November 15th, 2006 by Coos
function isUrlOffline( $url )
{
	// setup socket with timeout of 0.1 seconds
	// return -1 for error ; false for offline

	$urlpatt = '%http:\/\/([a-z-\.0-9]+)(:(\d+)){0,1}(.*)%i’;
	$am = array();
	preg_match($urlpatt, $url, $am);

	if (empty($am[1]))
	{
		return -1;
	}
	$address = gethostbyname($am[1]);
	$service_port = empty($am[3]) ? 80 : $am[3];

	$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
	if ($socket < 0)  return -1;

	socket_set_block($socket);
	socket_set_option(
		$socket,SOL_SOCKET, SO_SNDTIMEO
		, array("sec"=>0,"usec"=>100)
	);

	$result = socket_connect($socket, $address, $service_port);
	if ($result < 0 )   return -1;

	$in = "HEAD / HTTP/1.1\\r\\n";
	$in .= "Host: " . $am[1] . "\\r\\n";
	$in .= "Connection: Close\\r\\n\\r\\n";

	socket_write($socket, $in, strlen($in));

	$buf = "";
	while ($out = socket_read($socket, 2048))
	{
		$buf .= $out;
	}
	socket_close($socket);

	return preg_match("%HTTP/.+ 200 OK%",$buf);
}

testing performancing firefox extension

November 15th, 2006 by Coos

It seems clean enough, setting up multiple blogs is easy …
http://performancing.com/forum/firefox

the inline mode lets you browse while typing the entry for your blog, I like that

Adding Desktops to VirtueDesktops

October 2nd, 2006 by Coos

To enable all the features for DesktopManager or VirtueDesktops (like being able to move windows across desktops) all you have to do is add yourself to the procmod group….

sudo niutil -appendprop “/” “/groups/procmod” “users” `id -un`

[http://blog.medallia.com/2006/05/smacbook_pro.html#comment-26]

setting css float with javascript in IE

September 29th, 2006 by Coos

Just a quick reminder to self:
IE 6 (7) don’t seem to render style.float when set with javascript,
so when you want a div to float left *dont* try using:

 div.styleFloat = 'left';
 div.style['float'] = ‘left’;
 div.style.float = ‘left’;

Read the rest of this entry »

POSIX timeout bogosity

September 26th, 2006 by pim

Grace uses pthread conditionals to facilitate communication between threads. Worker threads waiting for new events can either wait indefinitely for an event or sleep on it for a determined number of milliseconds. The latter is implemented using the pthread_cond_timedwait() call. And this is where design-by-committee has gone completely insane. Someone thought he was being clever and specified the resolution for this call to be set in nanoseconds. Just what you need if you want to trigger conditionals in your particle accelerator. A bit of a bummer, though, if you want to use this call in, you know, actual real world conditions.

Read the rest of this entry »

If XML is a Rock, Liberal Parsing is a Hard Place

September 21st, 2006 by pim

Historically, the Grace library has been really forgiving, if not lax, in parsing XML formats. In an ideal world, every document is well-formed, but sometimes it’s a seller’s market (take RSS feeds) and you have to work with what you get. Although this worked out well in general, we were having a lot of problems with less-than-well-formed documents every time a new module was checked in. Each OpenPanel module comes with an XML file that contains information about the object classes it represents, their relationships to other classes and their impact on the user interface. It’s easy to make a mistake here, but hard to understand what goes wrong if things don’t work out and you get unhelpful errors.

Read the rest of this entry »

IE css empty div extra padding bug

September 21st, 2006 by Coos

Most webdevelopers will have been in the situation that you want to use a background-image in an empty div and there is this whitespace padding at the bottom of the image.
Your stylesheet may look like

#mtdiv {
    position:relative;
    height:8px;
    width:12px;
    background-image: url(/images/bg_small.png);
    background-repeat: no-repeat;

    /* dit i tell you i hate IE? */
    border:1px solid;
}

Read the rest of this entry »