LDAP Basics

Been stuck at home ill all day, so I took the opportunity to type up an article on LDAP basics, which is hopefully an easy to understand introduction to LDAP. Given the complicated subject matter, I probably failed in a couple of places. If you find something you don’t understand, I’d love to know so I can rewrite that section to make it clearer.

I also updated my robust shell scripting article to include a small section on (almost) race-free locking in bash, using IO redirection and bash’s noclobber option. Thanks to Ralf Wildenhues for the suggestion.

Setting your terminal title in bash

I didn’t really want to write three articles about bash in a row, but after my last article about Bash prompts Ralph Aichinger emailed me asking about a feature he had in zsh, where his xterms show him the current process and whether it was possible to do that in Bash. Never one to refuse a challenge, I had a go and my latest article is the result.

Bash Prompt

I managed to add two more sections to my article on writing robust shell scripts including using trap and making more atomic changes. Had some useful feedback including making the fact that a few small tweaks made it apply to more than just bash. Following from that I’ve added an article about changing your bash prompt and how mine has been built up over the years to something useful to me. Hopefully it’ll give other people some ideas.

Privoxy Crack

When you develop a anonymising, ad-removing, popup-blocking proxy server, don’t do what Privoxy appear to do, which is s/open((.*))/privoxyWindowOpen(1)/g because then you’ll convert any instances of “open()” in the text, confusing people.

Update: Bug reported, but nothing has happened to it since 2004-06-25.

Perl open()

Dear perl programmers,

When using open(), please don’t use:

open FILE, "$file" or die "couldn't open filen";

It really helps if you tell us what file you’re trying to open and what went wrong. The correct error message is:

open FILE, "$file" or die "could not open $file: $!n";

Thank you.

IO::File->open() is broken

So you read the documentation for IO::File and see:

open( FILENAME [,MODE [,PERMS]] )
open( FILENAME, IOLAYERS )

so you write:

my $rules = new IO::File('debian/rules','w', 0755);

and wonder why it hasn’t changed the permissions from 0666. Stracing confirms it is opened 0666:

open("./debian/rules", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 4

A bit further reading of the documentation you discover:

If IO::File::open receives a Perl mode string (“>”, “+<”, etc.) or an ANSI C fopen() mode string (“w”, “r+”, etc.), it uses the basic Perl open operator (but protects any special characters).

If IO::File::open is given a numeric mode, it passes that mode and the optional permissions value to the Perl sysopen operator. The permissions default to 0666.

If IO::File::open is given a mode that includes the : character, it passes all the three arguments to the three-argument open operator.

For convenience, IO::File exports the O_XXX constants from the Fcntl module, if this module is available.

and the correct way to write this is

my $rules = new IO::File('debian/rules',O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0755)

Thank you very much perl for ignoring the permission parameter when you feel like it.

Update: Steinar, yes sorry, I did have 0755 rather than “0755” originally, but changed it just to check that didn’t make a difference and copied the wrong version. I’ve changed the post to have the right thing.

% strace -eopen perl -MIO::File
   -e 'my $rules = new IO::File("foo","w", 0755);' 2>&1 | grep foo
open("./foo", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
% strace -eopen perl -MIO::File
   -e 'my $rules = new IO::File("foo","w", "0755");' 2>&1 | grep foo
open("./foo", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3

Incidentally, 0755 and “0755” are different:

 perl -e 'printf("%d %dn", 0755, "0755");'
493 755

Marmaduke Duke

I logged into Last.fm this morning to look at my recommendations and among the more obscurer suggestions was Marmaduke Duke, who apparently are similar to Biffy Clyro, Hell Is For Heroes, Reuben and Million Dead, who are some of my favourite bands. So I decided to log into Amazon to look to see how much it was, and guess what was the music recommendation on the front page:

I think someone is trying to tell me something. I’m now looking for some samples to listen to.

Geek Girl

22:07 <@Laura-> no, there is another

Not only does my girlfriend use irc, she quotes Star Wars. squee

Slef-Harming

Slef Did it ever occur to you that the comma rather than period in the email address might possibly have been a genuine mistake rather than an attempt to target you. Your excessively and increasingly paranoid and biased blog postings are starting to piss me off. You managed to suggest that Madduck thought that cookies should never be used. Reading his post you see he referenced Sesse who only said that people shouldn’t use cookies if they didn’t need to. As for your assertion that wikipeda has a “extreme right-wing viewpoint”, I sat and read both the blog entry you posted to and the discussion page in question. You conviently failed to mention that wikipedia’s problem with the FAQ is that it is the collective work of anonymous contributors and edited by a person that google ranks below the profile of some games player. (Oh sorry, forgot google is in on the anti-mjray conspiracy). Wikipedia’s policy on sources clearly states that primary sources should be “made available by a credible publication”.

When you’ve finished complaining, you might want to fix the link element in your rdf to not point to itself.