Blog O' Matty


USENIX LISA 2005 roundup

This article was posted by Matty on 2005-12-12 00:51:00 -0400 -0400

I just got back from LISA 2005, and had a blast in San Diego! As with every conference I attend, there were some key highlights:

The conference was a blast, and I got to meet a lot of cool people while I was there. Hopefully Lisa 2006 will be just as good!

DNS domain expiration checker

This article was posted by Matty on 2005-12-11 17:28:00 -0400 -0400

I just released version 1.0 of domain-check. domain-check queries WHOIS data and prints domain expiration dates, and works very similar to ssl-cert-check. Since seeing is believing, I will provide several examples to show just what domain-check can do.

The first example shows how domain-check can be used to print the expiration date for the domain prefetch.net:

$ domain-check -d prefetch.net

Domain Registrar Status Expires Days Left
----------------------------------- ----------------- -------- ----------- ---------
prefetch.net INTERCOSMOS MEDIA Valid 13-feb-2006 64

The next example show how domain-check can be used to print the expiration date for the domains listed in the file “domains”:

$ domain-check -f domains

Domain Registrar Status Expires Days Left
----------------------------------- ----------------- -------- ----------- ---------
sun.com NETWORK SOLUTIONS Valid 20-mar-2010 1560
google.com EMARKMONITOR INC. Valid 14-sep-2011 2103
prefetch.net INTERCOSMOS MEDIA Valid 13-feb-2006 64
spotch.com GANDI Valid 03-dec-2006 357

And the final example shows how domain-check can be used to e-mail admin@prefetch.net if a domain listed in the file “domains” will expire in 60-days or less:

$ domain-check -a -f domains -q -x 60 -e admin@prefetch.net

Send me an E-mail if you have comments or suggestions.

Stripping leading zeros with bash

This article was posted by Matty on 2005-12-11 16:56:00 -0400 -0400

I needed to strip leading zeros from a variable, and found the “#” modifier in the shell manual pages:

$ FOO=09

$ echo ${FOO#0}
9

The number of occurences of the value following the # indicates how many to strip, and can also be applied to ASCII characters:

$ FOO=AAB

$ echo ${FOO#AA}
B

This is some nifty stuff!

Finding memory leaks with OS X

This article was posted by Matty on 2005-12-09 17:09:00 -0400 -0400

The UNIX standard library provides the malloc() and free() routines to dynamically allocate and free memory. These routines allow developers to increase and decrease memory (the programs heap) as needed, which allows the process to increase or decrease memory consumption as demand increases or decreases. This works great when care is taken to free memory that is no longer needed, but issues (e.g., memory leaks) can occur if memory is allocated and never free()‘ed. If you are using OS X, you can use the leaks(1) command to check a program or process for memory leaks:

$ cat test.c


#include <stdlib.h>

int main(int argc, char**argv)
{
void *foo;
char *bar = "this is a string";

foo = (void *)malloc(128);

foo = bar;

sleep(60);
return 0;
}

$ test &

$ leaks test

Process 262: 8 nodes malloced for 2 KB
Process 262: 1 leak for 128 total leaked bytes.
Leak: 0x00500120 size=128
0x00000000 0x00000000 0x00000000 0x00000000 ................
0x00000000 0x00000000 0x00000000 0x00000000 ................
0x00000000 0x00000000 0x00000000 0x00000000 ................
0x00000000 0x00000000 0x00000000 0x00000000 ................
0x00000000 0x00000000 0x00000000 0x00000000 ................
0x00000000 0x00000000 0x00000000 0x00000000 ................
0x00000000 0x00000000 0x00000000 0x00000000 ................
0x00000000 0x00000000 0x00000000 0x00000000 ................

I digs me some OS X!

Saving CPP processed files

This article was posted by Matty on 2005-12-03 11:38:00 -0400 -0400

My friend Clay sent me a cool tip this week. If you would like to save files that have been processed with cpp, you can set the CFLAGS “-save-temps” option:

$ export CFLAGS=-save-temps

$ make

This will cause a bunch of .i files to be created, which can simplify the process of figuring out how applications work (going macro hunting is no fun at all!).