From 2366100dd925213202e6fdad2f7c7cb4ed0abba3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andreas=20K=C3=B6nig?= Date: Mon, 29 Jun 1998 01:47:07 +0200 Subject: [PATCH] Permissions in MakeMaker (Was: patch to MM_Unix.pm) Message-ID: p4raw-id: //depot/perl@1255 --- lib/ExtUtils/MM_Unix.pm | 70 ++++++++++++++++++++++++++++++++++++++--------- lib/ExtUtils/MakeMaker.pm | 23 ++++++++++++---- 2 files changed, 74 insertions(+), 19 deletions(-) diff --git a/lib/ExtUtils/MM_Unix.pm b/lib/ExtUtils/MM_Unix.pm index d3184a2..daa477c 100644 --- a/lib/ExtUtils/MM_Unix.pm +++ b/lib/ExtUtils/MM_Unix.pm @@ -8,8 +8,8 @@ use strict; use vars qw($VERSION $Is_Mac $Is_OS2 $Is_VMS $Is_Win32 $Is_Dos $Verbose %pm %static $Xsubpp_Version); -$VERSION = substr q$Revision: 1.118 $, 10; -# $Id: MM_Unix.pm,v 1.118 1997/08/01 09:42:52 k Exp $ +$VERSION = substr q$Revision: 1.126 $, 10; +# $Id: MM_Unix.pm,v 1.126 1998/06/28 21:32:49 k Exp k $ Exporter::import('ExtUtils::MakeMaker', qw( $Verbose &neatvalue)); @@ -567,6 +567,15 @@ MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})." push @m, "$tmp = $self->{$tmp}\n"; } + for $tmp (qw( + PERM_RW PERM_RWX + ) + ) { + my $method = lc($tmp); + # warn "self[$self] method[$method]"; + push @m, "$tmp = ", $self->$method(), "\n"; + } + push @m, q{ .NO_CONFIG_REC: Makefile } if $ENV{CLEARCASE_ROOT}; @@ -691,8 +700,8 @@ $targ :: $src $self->{NOECHO}\$(MKPATH) $targdir $self->{NOECHO}\$(EQUALIZE_TIMESTAMP) $src $targ }; - push(@m,qq{ - -$self->{NOECHO}\$(CHMOD) 755 $targdir + push(@m, qq{ + -$self->{NOECHO}\$(CHMOD) \$(PERM_RWX) $targdir }) unless $Is_VMS; } join "", @m; @@ -968,12 +977,12 @@ $(BOOTSTRAP): '."$self->{MAKEFILE} $self->{BOOTDEP}".' $(INST_ARCHAUTODIR)/.exis -MExtUtils::Mkbootstrap \ -e "Mkbootstrap(\'$(BASEEXT)\',\'$(BSLOADLIBS)\');" '.$self->{NOECHO}.'$(TOUCH) $(BOOTSTRAP) - $(CHMOD) 644 $@ + $(CHMOD) $(PERM_RW) $@ $(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists '."$self->{NOECHO}$self->{RM_RF}".' $(INST_BOOT) -'.$self->{CP}.' $(BOOTSTRAP) $(INST_BOOT) - $(CHMOD) 644 $@ + $(CHMOD) $(PERM_RW) $@ '; } @@ -1024,7 +1033,7 @@ $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists push(@m,' LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) -o $@ '.$ldrun.' $(LDDLFLAGS) '.$ldfrom. ' $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) $(EXPORT_LIST)'); push @m, ' - $(CHMOD) 755 $@ + $(CHMOD) $(PERM_RWX) $@ '; push @m, $self->dir_target('$(INST_ARCHAUTODIR)'); @@ -1189,7 +1198,10 @@ eval 'exec $interpreter $arg -S \$0 \${1+"\$\@"}' next; } my($dev,$ino,$mode) = stat FIXIN; - $mode = 0755 unless $dev; + # If they override perm_rwx, we won't notice it during fixin, + # because fixin is run through a new instance of MakeMaker. + # That is why we must run another CHMOD later. + $mode = oct($self->perm_rwx) unless $dev; chmod $mode, $file; # Print out the new #! line (or equivalent). @@ -1213,7 +1225,8 @@ eval 'exec $interpreter $arg -S \$0 \${1+"\$\@"}' } unlink "$file.bak"; } continue { - chmod 0755, $file or die "Can't reset permissions for $file: $!\n"; + chmod oct($self->perm_rwx), $file or + die "Can't reset permissions for $file: $!\n"; system("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';; } } @@ -2044,6 +2057,7 @@ $to: $from $self->{MAKEFILE} " . $self->catdir($todir,'.exists') . " $self->{NOECHO}$self->{RM_F} $to $self->{CP} $from $to \$(FIXIN) $to + -$self->{NOECHO}\$(CHMOD) \$(PERM_RWX) $to "; } join "", @m; @@ -2432,11 +2446,12 @@ END my(@m); push @m, qq[POD2MAN_EXE = $pod2man_exe\n], -q[POD2MAN = $(PERL) -we '%m=@ARGV;for (keys %m){' \\ --e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "].$self->{MAKEFILE}.q[";' \\ +qq[POD2MAN = \$(PERL) -we '%m=\@ARGV;for (keys %m){' \\\n], +q[-e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "], + $self->{MAKEFILE}, q[";' \\ -e 'print "Manifying $$m{$$_}\n";' \\ -e 'system(qq[$$^X ].q["-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" $(POD2MAN_EXE) ].qq[$$_>$$m{$$_}])==0 or warn "Couldn\\047t install $$m{$$_}\n";' \\ --e 'chmod 0644, $$m{$$_} or warn "chmod 644 $$m{$$_}: $$!\n";}' +-e 'chmod(oct($(PERM_RW))), $$m{$$_} or warn "chmod $(PERM_RW) $$m{$$_}: $$!\n";}' ]; push @m, "\nmanifypods : "; push @m, join " \\\n\t", keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}}; @@ -2680,6 +2695,35 @@ $(OBJECT) : $(PERL_HDRS) join "\n", @m; } +=item perm_rw (o) + +Returns the attribute C or the string C<644>. +Used as the string that is passed +to the C command to set the permissions for read/writeable files. +MakeMaker chooses C<644> because it has turned out in the past that +relying on the umask provokes hard-to-track bugreports. +When the return value is used by the perl function C, it is +interpreted as an octal value. + +=cut + +sub perm_rw { + shift->{PERM_RW} || "644"; +} + +=item perm_rwx (o) + +Returns the attribute C or the string C<755>, +i.e. the string that is passed +to the C command to set the permissions for executable files. +See also perl_rw. + +=cut + +sub perm_rwx { + shift->{PERM_RWX} || "755"; +} + =item pm_to_blib Defines target that copies all files in the hash PM to their @@ -2863,7 +2907,7 @@ END push @m, q{ $(AR) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@ - $(CHMOD) 755 $@ + $(CHMOD) $(PERM_RWX) $@ }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld }; # Old mechanism - still available: diff --git a/lib/ExtUtils/MakeMaker.pm b/lib/ExtUtils/MakeMaker.pm index e640865..eac32ac 100644 --- a/lib/ExtUtils/MakeMaker.pm +++ b/lib/ExtUtils/MakeMaker.pm @@ -2,10 +2,10 @@ BEGIN {require 5.002;} # MakeMaker 5.17 was the last MakeMaker that was compatib package ExtUtils::MakeMaker; -$Version = $VERSION = "5.42"; +$Version = $VERSION = "5.43"; $Version_OK = "5.17"; # Makefiles older than $Version_OK will die # (Will be checked from MakeMaker version 4.13 onwards) -($Revision = substr(q$Revision: 1.216 $, 10)) =~ s/\s+$//; +($Revision = substr(q$Revision: 1.222 $, 10)) =~ s/\s+$//; @@ -244,7 +244,8 @@ sub full_setup { INST_MAN1DIR INST_MAN3DIR INST_SCRIPT LDFROM LIBPERL_A LIB LIBS LINKTYPE MAKEAPERL MAKEFILE MAN1PODS MAN3PODS MAP_TARGET MYEXTLIB NAME NEEDS_LINKING NOECHO NORECURS OBJECT OPTIMIZE PERL PERLMAINCC - PERL_ARCHLIB PERL_LIB PERL_SRC PL_FILES PM PMLIBDIRS PREFIX + PERL_ARCHLIB PERL_LIB PERL_SRC PERM_RW PERM_RWX + PL_FILES PM PMLIBDIRS PREFIX PREREQ_PM SKIP TYPEMAPS VERSION VERSION_FROM XS XSOPT XSPROTOARG XS_VERSION clean depend dist dynamic_lib linkext macro realclean tool_autosplit @@ -286,8 +287,8 @@ sub full_setup { @Overridable = @MM_Sections; push @Overridable, qw[ - dir_target libscan makeaperl needs_linking subdir_x test_via_harness - test_via_script + dir_target libscan makeaperl needs_linking perm_rw perm_rwx + subdir_x test_via_harness test_via_script ]; @@ -1522,6 +1523,16 @@ Directory containing the Perl library to use. Directory containing the Perl source code (use of this should be avoided, it may be undefined) +=item PERM_RW + +Desired Permission for read/writable files. Defaults to C<644>. +See also L. + +=item PERM_RWX + +Desired permission for executable files. Defaults to C<755>. +See also L. + =item PL_FILES Ref to hash of files to be processed as perl programs. MakeMaker @@ -1604,7 +1615,7 @@ MakeMaker object. The following lines will be parsed o.k.: $VERSION = '1.00'; *VERSION = \'1.01'; - ( $VERSION ) = '$Revision: 1.216 $ ' =~ /\$Revision:\s+([^\s]+)/; + ( $VERSION ) = '$Revision: 1.222 $ ' =~ /\$Revision:\s+([^\s]+)/; $FOO::VERSION = '1.10'; *FOO::VERSION = \'1.11'; -- 2.7.4