Monthly Archive for March, 2008

Poor Man’s Cron Trigger

This is a handy trick I use when I want to execute something as root when some event triggers, but without any interaction between the event and the start of the action. It’s quite unsafe and dirty, but it gets the job done.

When the event happens, make it create a file:

touch /tmp/this-event-happened

Now add the following cronjob as root (or whatever user you want):

* * * * * /bin/rm /tmp/this-event-happened 2>/dev/null && /bin/bash\
/execute/this.sh

First come the stars, which tell cronjob to execute this command every minute. Then we try to remove the /tmp/this-event-happened file. rm will exit with an error-code when the file doesn’t exist, and in that case the script won’t be executed, because we’re chaining it using “&&”, the AND operator. In a shell, and most modern programming languages, if the first parameter of an AND operator is false, it won’t even evaluate the second parameter, because the total result will definetly be false anyway.

If the file does exist, the shell will evaluate the second parameter as well, and thus execute the script. Meanwhile the file will be removed, so everything is set up for the next trigger.

As you can see, very simple. It has some problems though. For example, any user can create files in /tmp, so it’s not very safe. You could create a directory somewhere that’s only accessible to the user that is allowed to generate the event, and put the trigger-file there. Another disadvantage: if the script takes longer than a minute to run, and the event is triggered again, the script will run twice at the same time. So take care when using this!

A Job

De Therminal, Annotations

If you think I’m behind on my blogging, you’re right. There are about 9 drafts in the pipeline, but I just don’t have as much time as I used to to finish them.

Apart from the regular time-consumers that appear in the middle of a semester like tasks and projects for the university, I also have a job now. Since Monday March 10 I’m the new ICT-dude at the DSA (Dienst StudentenActiviteiten, the link between all the student organizations and the University of Ghent), replacing Dieter Adriaenssens, who got a job at the VUB.

I’m now in charge of keeping the DSA servers running, and troubleshooting some 20 client PC’s in De Therminal, which is the student house of our university. My job consists of some php programming, a lot of sysadminning, and regular hardware maintenance.

My office is a concrete cave underneath the Schelde. It’s filled with buzzing 19″ rackmount servers, discarded PC’s, and boxes full of cables. The IT-cave is the only room in the whole building with air conditioning, and I also have my very own fake-leather CEO-style chair.

Awesome? Very.

Could not create rewrite_log_lock

If you’ve rolled your own kernel and you’re getting this error when starting Apache:

[crit] (38)Function not implemented: mod_rewrite:
 could not create rewrite_log_lock
Configuration Failed

It’s probably because you’ve cut a vital library - System V IPC. Enable it under General Setup - System V IPC, and recompile.

Software Security

If you’re interested in code injections using buffer overflows in C/C++ and other software-related security holes, I can recommend the talk by Yves Younan next wednesday. It’s organized by Zeus and starts at 20h00 in the Sterre, S9, room A2.

For more info and an abstract, check the Zeus website.

Software Security poster