your mail
X-RDate: Wed, 09 Jan 1980 11:42:12 +0500 (SSK)
Date: Tue, 2 Dec 1997 07:38:29 -0500
From: "Mordechai T. Abzug" <morty@MAIL.SANCTUARY.ARBUTUS.MD.US>
To: BUGTRAQ@NETSPACE.ORG
Subject: Re: your mail
Szekely-Benczedi Endre spake thusly:
> There is a nice small shell script at www.rootshell.com,
> longpath.sh, wich exploits some bug in Linux about long pathnames...
[snip]
> I heard that it is possible to erase it with mc (Midnight Commander).
> Well, I can tell you' this ISN'T true ;-)
> I tried the script on a RedHat Linux, and... well... I can't erase the
> directory now ;-)
> I wonder if anyone of you knows the problem, and can help me with
> that..
#!/usr/local/bin/perl5
# this basically does an rm -r, only on directories. Be careful. :)
$junk="junk.$$";
mkdir $junk, 0700 || die "$0: $!";
$seq=0;
sub newseq { return ($seq++);}
foreach (@ARGV) {
rename $_, $junk."/".&newseq || die "$0: $!";
}
chdir $junk || die "$0: $!";
$current=0;
while ($current<$seq) {
foreach (glob "$current/*") {
rename $_, "./".&newseq || die "$0: $!";
}
$current ++;
}
foreach (glob "*") {
rmdir ($_) || die "$0: $!";
}
chdir ".." || die "$0: $!";
rmdir $junk || die "$0: $!";
Just give it the name of the top-level evil directory (making sure to run
it in the same filesystem), and it'll clean things up. Next time, be more
careful. :)
--
Mordechai T. Abzug
"Grad school is the snooze button on the clock-radio of life."
- comedian John Rogers (who holds a graduate degree in physics)