[Pdx-pm] File::Path rmtree modification
Michael G Schwern
schwern at pobox.com
Tue Feb 15 23:51:42 PST 2005
On Tue, Feb 15, 2005 at 09:23:06PM -0800, Keith Lofstrom wrote:
> Question Numero Uno: Why the heck the authors ( Tim Bunce and
> Charles Bailey ) felt it necessary to chmod the recalcitrant
> directory to 0777 !
Simple answer: its cross-platform. Some file/operating systems won't let
you delete a directory unless you have write permission so the simplest
thing to do is to give yourself write permission.
Keep in mind that the "authors" section in core Perl libraries is often
just "the original authors" and that the code has likely been patched
many hundreds of times by many other people. Often what happens is a patch
comes into p5p "Hi, I'm running ObscureOS 3.4 and found a bug in rmtree().
This patch fixes it" and p5p goes, "Uuuuuhhh... sure, looks harmless, ok".
> Newbie here thinks that if the directory
> has a different owner or group, the chmod fails anyway, and
> if the directory is mine, I can chmod it to 0700 and do my
> removal without setting the other permissions.
I believe using 0777 is an artifact of MacPerl's attempt to map chmod into
file lock/unlock where chmod 0444 meant "lock" and chmod 0666 meant "unlock"
though I could be wrong.
Or nobody was paying too much attention. Hypothetical microsecond security
holes weren't so much an issue Back Then.
> Question Roman Numeral II: If I *am* thinking correctly, and the
> authors say "go away kid, don't bother me" then I am faced with
> building a local version of rmtree(), and distributing that
> version with my app. I can rename it and put it in the app's
> library, but is that the best way?
rmtree() is currently in the process of being reworked on p5p. At the heart
of things is that File::Path is very old code and nobody has taken the time
to rework it. I'd give you a reference to the relevant thread but I ain't
got the Internet at the moment.
More information about the Pdx-pm-list