Sun, 19 Mar 2006

Atom feed and Planet Debian

I upgraded my atom feed to atom 1.0 during the week. This appears to have broken my entries on Planet Debian. If anyone has any ideas on what I can do to make planet like me with a valid atom 1.0 feed, please let me know.

Update: I've changed my feed from having html content to xhtml, which isn't encoded. Hopefully Planet will like this. If not I'll have to fix it in the morning.

[] | # Read Comments (6) |

Comments

PostgreSQL User Administration

Over the weekend, I managed to revive my main desktop machine, which as spent the last 15 months turned off under a desk because it was showing some odd behaviour and didn't have time to fix it. I've upgraded it to the latest sid and given it to my girlfriend to use instead of the Windows machine she had been using. She appears to have fallen in love with tuxpaint. :)

In the process of setting it up I discovered printconf, which automatically sets up parallel and USB printers under cups. Plugged in my printer, went to print in firefox and there was the printer. These things just get easier and easier. Gone are the days when you spent hours writing a printcap entry for your printer. One thing I would like is for DBus support in CUPS so I know when the print job has finished.

Just finished writing an article on PostgreSQL user administration. Go read it.

[article,PostgreSQL,user adminitration,database,tuxpaint,printconf] | # Read Comments (2) |

Comments

Wed, 15 Mar 2006

Comment Form Attack

Came back from a nice walk on the seafront, including a 30 minute professional firework display from a boat 20 meters offshore and about 50 people watching, to find that someone had attempted to attack my blog comment to send spam. Fortunately according to my mail logs, nothing went out, but it did make me go through and read the comment plugin code. I did wonder if every suitable field had been cleaned and have now made sure that it is. Looks like it came from several IP addresses over a 5 minute period and got past my (admittedly very) simple turing test, so I don't think it was an automated script. For an example of the attacks, check out this old posting.

[] | # Read Comments (2) |

Comments

Tue, 14 Mar 2006

Notice Periods in UK

Clint, I don't know about Belgium, but in the UK, the norm is a month for most people and 3 months for senior members of staff. Of course, you may or may not be given work to do during that period. Usually your employers will want you to document and help hand over to a new person. However if you have a bad relationship with your employers, they may put you on garden leave where you arent in the office, but are being paid. Presumably this is to stop you stealing their data or doing some other malicious act. All this stuff is normally written into your employment contract. Without one it is possible to leave your employer within a week.

[] | # Read Comments (0) |

Comments

(In)sane

Opening XSane results in:

[sane,user-friendly,UI,HCI] | # Read Comments (3) |

Comments

Mon, 13 Mar 2006

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.

[article,LDAP,bash] | # Read Comments (0) |

Comments

Thu, 09 Mar 2006

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.

[article,bash,shell,terminal,prompt,xterm title] | # Read Comments (3) |

Comments

Wed, 08 Mar 2006

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.

[article,shell,bash,prompts,programming] | # Read Comments (4) |

Comments

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.

[privoxy,wtf] | # Read Comments (2) |

Comments

Perl open()

Dear perl programmers,

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

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

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.

[perl,wtf] | # Read Comments (9) |

Comments

Fri, 03 Mar 2006

Writing Robust Shell Scripts Article

I've just finished writing an article on tips for making your shell scripts more robust. Comments welcome.

[article,bash,shell] | # Read Comments (6) |

Comments

Wed, 01 Mar 2006

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 %d\n", 0755, "0755");'
493 755
[perl,IO::File,gotchas] | # Read Comments (1) |

Comments