Perl-Toolchain-Gang / ExtUtils-MakeMaker

Perl module to make Makefiles and build modules (what backs Makefile.PL)
https://metacpan.org/release/ExtUtils-MakeMaker
64 stars 76 forks source link

ExtUtils::MM_Unix::pm_to_blib passes ignored perms to ExtUtils::Install::pm_to_blib #98

Open bulk88 opened 10 years ago

bulk88 commented 10 years ago

In https://rt.cpan.org/Public/Bug/Display.html?id=3927 there was a proposal to add a 4th param to ExtUtils::Install::pm_to_blib. The patch was applied in EUMM in https://github.com/Perl-Toolchain-Gang/ExtUtils-MakeMaker/commit/a21e4cbb03308d1927dcf5ce0a5845dccf28dc21 but has never been applied to ExtUtils::Install , see https://metacpan.org/source/BINGOS/ExtUtils-Install-1.64/lib/ExtUtils/Install.pm#L1172 . This makes changing blib's files from the default of "read only" on Win32 to read-write, impossible. Passing

PERM_DIR => '777'

to EUMM WriteMakefile, correctly results in make macro PERM_DIR in section # --- MakeMaker constants section: being 777, but it has no meaning when passed to ExtUtils::Install::pm_to_blib . From ExtUtils::Install::pm_to_blib

        my($mode,$atime,$mtime) = (stat $from)[2,8,9];
        utime($atime,$mtime+$Is_VMS,$to);
        _chmod(0444 | ( $mode & 0111 ? 0111 : 0 ),$to);

still creates a RO file on Win32. I am not sure what #3927 exactly did (so even if EU::I is fixed, there is still no way to prevent RO files from being made), but whatever #3927 did is broken since the patch to EU::I was never applied.

mohawk2 commented 9 years ago

Update: latest equivalent line to URL above is: https://metacpan.org/source/BINGOS/ExtUtils-Install-1.68/lib/ExtUtils/Install.pm#L1183

The canonical git HEAD for EU::I appears to be: http://perl5.git.perl.org/perl.git/blob/HEAD:/cpan/ExtUtils-Install/lib/ExtUtils/Install.pm

The currently-bundled version of ExtUtils::Install is 1.54, which will need to change once the suitable CPAN version has been released that contains this change.

@bulk88, massive point - you're talking about RO files, but the permission that gets passed to (and ignored by) EU::I::pm_to_blib is PERM_DIR - not a file permission?

mohawk2 commented 9 years ago

In any case, here is a patch to EU::I.

@bingos, you're the EU::I most recent releaser, so I'm pinging you here. I don't know the exact right way to submit a patch given EU::I's metacpan repo points at perl5's git, but it's located in cpan/.

diff --git a/bundled/ExtUtils-Install/ExtUtils/Install.pm b/bundled/ExtUtils-Install.pm
index 85fe1c9..4f98bf5 100644
--- a/bundled/ExtUtils-Install/ExtUtils/Install.pm
+++ b/bundled/ExtUtils-Install/ExtUtils/Install.pm
@@ -1178,9 +1178,9 @@ environment variable will silence this output.
 =cut

 sub pm_to_blib {
-    my($fromto,$autodir,$pm_filter) = @_;
+    my($fromto,$autodir,$pm_filter,$perm_dir) = @_;

-    _mkpath($autodir,0,0755);
+    _mkpath($autodir,0,$perm_dir);
     while(my($from, $to) = each %$fromto) {
         if( -f $to && -s $from == -s $to && -M $to < -M $from ) {
             print "Skip $to (unchanged)\n" unless $INSTALL_QUIET;
@@ -1203,7 +1203,7 @@ sub pm_to_blib {
             # we wont try hard here. its too likely to mess things up.
             forceunlink($to);
         } else {
-            _mkpath(dirname($to),0,0755);
+            _mkpath(dirname($to),0,$perm_dir);
         }
         if ($need_filtering) {
             run_filter($pm_filter, $from, $to);
bulk88 commented 9 years ago

Looks correct as a fix for ignoring PERM_DIR macro. This bug report was because I was trying to figure out how to programmatically stop the Win32 DLLs/.PMs in blib dir from being RO flag on FAT32/NTFS from a makefile.pl.

mohawk2 commented 9 years ago

Fix in PR https://github.com/Perl-Toolchain-Gang/ExtUtils-Install/pull/1.

bulk88 commented 9 years ago

closed, looks to me like PERM_DIR is now used, instead of ignored

bulk88 commented 8 years ago

Mohawk's patch was reverted https://github.com/Perl-Toolchain-Gang/ExtUtils-Install/commit/a78a53d21ec1e3537efdbbf13cd5ce5ca9c99494 a few weeks later, reopening since the problem has returned.