ExtUtils::Install handle symbolic and hard links
authorDavid Mitchell <davem@iabyn.com>
Sun, 6 Apr 2014 12:11:36 +0000 (13:11 +0100)
committerDavid Mitchell <davem@iabyn.com>
Mon, 14 Apr 2014 10:33:02 +0000 (11:33 +0100)
commit98656abe1a460777edc9c9dc6212d106fe843c60
tree59e3b9842fd420d267276db0cac0160db3b4d1c1
parent78beb4ca6d139a7188817b2d3f61702d5cfd5365
ExtUtils::Install handle symbolic and hard links

[perl #72028]

When upgrading an already-installed file, ExtUtils::Install could mess up
the permissions of files if the old versions of files were hard or
symbolic links. For example, if the Foo module had been installed as
lib/Foo.pm and for some reason (perhaps due to OS packaging) that file was
hard-linked to other/Foo.pm or replaced with a symbolic link to
other/Foo.pm, then when trying to install a newer release of Foo, the
permissions of the other/Foo.pm file could end up messed up.

This was due to ExtUtils::Install changing the permissions of the old file
before unlinking it; if the file was a link, then the linked file would
get the chmod instead. Since on POSIXy platforms it is the directory
permissions, not the file permissions, that affect whether a file can be
unlinked, the chmod was redundant anyway. So on these platforms, skip the
chmod.

I've also added tests for symlinked and hard-linked files.
dist/ExtUtils-Install/lib/ExtUtils/Install.pm
dist/ExtUtils-Install/t/Install.t