Archive for October, 2007

Wii Wand Where?

Wednesday, October 31st, 2007

Raymond’s Chen post about functional magic wands makes me wonder why there isn’t a game like that for the Wii?

rm -rf / isn’t funny

Wednesday, October 24th, 2007

Perlmonks discusses File::Remove, which until recently, seems to have a test that would effectively test rm -rf /:

my %links = (
  l_ex   => curdir(),
  l_ex_a => rootdir(),
  l_nex  => 'does_not_exist'
);
my $errs = 0;
foreach my $link (keys %links) {
  my $path = catdir( $testdir, $link );
  unless( symlink($links{$link}, $path )) {
    diag("Cannot create symlink $link -> $links{$link}: $!");
    $errs++;
  }
}
if ( $errs ) {
  die("Could not create test links");
}

ok( File::Remove::remove(1, map { catdir($testdir, $_) } keys %links),
                                            "remove \1: all links" );

If everything goes fine, nothing bad happens & the test passes.

Apparently in some cases when the test fails, the remove call — invoked recursively — transverses through l_ex_a — which is assigned rootdir() — and tries to delete everything.

Add to the fact most people install Perl modules as root and … oops. No more anything.

It’s fixed now & Bad Idea aside, there was some interesting discussion on installing Perl modules.

Old skool users will remember the days of perl Makefile.PL; make; make test; make install.

A longtime ago it became much simpler: cpan install Date::Calc. A lot of systems are set to install in /usr/lib/perl5, meaning sudo is needed — thus sudo cpan install Date::Calc. Hence the possibility of blowing away /.

schwern had what I thought was a really good suggestion: Setup CPAN.pm to do all its work as a normal user & only invoke sudo during the install phase. Just launch cpan and tweak your config:

  • o conf make_install_make_command ’sudo make’
  • o conf mbuild_install_build_command ’sudo ./Build’