[interchange-cvs] interchange - heins modified 2 files

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Thu Jan 29 17:13:26 UTC 2009


User:      heins
Date:      2009-01-29 17:13:26 GMT
Modified:  lib/Vend Config.pm Interpolate.pm
Log:
* Allow catalogs to be set to have Perl always global by default.

	AllowGlobal        catname
	PerlAlwaysGlobal   catname

  This is a global directive (i.e. interchange.cfg).

  [perl global=0] will still be honored, i.e. that will be interpreted
  by Safe.

* Allow catalogs to turn off "strict" in global mode by default:

	PerlNoStrict       catname

  This is a global directive (i.e. interchange.cfg).

This is intended as an easy way to allow catalogs to work all right
with Vend::Charset. Sad, but can't think of any better way short of
maintaining our own version of the UTF8 modules. It is really sad,
because the Perl powers that be have totally abandoned Opcode and
Safe.

NOT RECOMMENDED FOR USE BY NON-SOPHISTICATED INTERCHANGE USERS.
But I bet that will be ignored....

Revision  Changes    Path
2.241                interchange/lib/Vend/Config.pm


rev 2.241, prev_rev 2.240
Index: Config.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Config.pm,v
retrieving revision 2.240
retrieving revision 2.241
diff -u -r2.240 -r2.241
--- Config.pm	15 Jan 2009 02:08:04 -0000	2.240
+++ Config.pm	29 Jan 2009 17:13:26 -0000	2.241
@@ -1,6 +1,6 @@
 # Vend::Config - Configure Interchange
 #
-# $Id: Config.pm,v 2.240 2009-01-15 02:08:04 jon Exp $
+# $Id: Config.pm,v 2.241 2009-01-29 17:13:26 mheins Exp $
 #
 # Copyright (C) 2002-2009 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -54,7 +54,7 @@
 use Vend::Data;
 use Vend::Cron;
 
-$VERSION = substr(q$Revision: 2.240 $, 10);
+$VERSION = substr(q$Revision: 2.241 $, 10);
 
 my %CDname;
 my %CPname;
@@ -493,6 +493,8 @@
 	['SafeTrap',         'array',            ':base_io'],
 	['NoAbsolute',		 'yesno',			 'No'],
 	['AllowGlobal',		 'boolean',			 ''],
+	['PerlNoStrict',	 'boolean',			 ''],
+	['PerlAlwaysGlobal', 'boolean',			 ''],
 	['AddDirective',	 'directive',		 ''],
 	['UserTag',			 'tag',				 ''],
 	['CodeDef',			 'mapped_code',		 ''],
@@ -2158,6 +2160,16 @@
 	}
 	my ($name, $sub) = split /\s+/, $value, 2;
 
+	## Determine if we are in a catalog config, and if 
+	## perl should be global and/or strict
+	my $nostrict;
+	my $perlglobal = 1;
+
+	if($C) {
+		$nostrict = $Global::PerlNoStrict->{$C->{CatalogName}};
+		$perlglobal = $Global::AllowGlobal->{$C->{CatalogName}};
+	}
+
 	# Untaint and strip this pup
 	$sub =~ s/^\s*([\000-\377]*\S)\s*//;
 	$sub = $1;
@@ -2198,9 +2210,15 @@
 			$c->{$name} = eval $code;
 		}
 	}
-	elsif (! $C or $Global::AllowGlobal->{$C->{CatalogName}}) {
+	elsif ($perlglobal) {
 		package Vend::Interpolate;
-		$c->{$name} = eval $sub;
+		if($nostrict) {
+			no strict;
+			$c->{$name} = eval $sub;
+		}
+		else {
+			$c->{$name} = eval $sub;
+		}
 	}
 	else {
 		package Vend::Interpolate;
@@ -2675,6 +2693,14 @@
 			unless $error_message;
 	}
 
+	my $nostrict;
+	my $perlglobal = 1;
+
+	if($C) {
+		$nostrict = $Global::PerlNoStrict->{$C->{CatalogName}};
+		$perlglobal = $Global::AllowGlobal->{$C->{CatalogName}};
+	}
+
 	my $vref = $C ? $C->{Variable} : $Global::Variable;
 	my $require;
 	my $testsub = sub { 0 };
@@ -2729,7 +2755,7 @@
 				$oldtype = '.pl';
 			}
 			$module =~ /[^\w:]/ and return undef;
-			if(! $C or $Global::AllowGlobal->{$C->{CatalogName}}) {
+			if($perlglobal) {
 				if ($pathinfo) {
 					unshift(@INC, $pathinfo);
 				}
@@ -5214,6 +5240,16 @@
 		);
 	}
 
+	## Determine if we are in a catalog config, and if 
+	## perl should be global and/or strict
+	my $nostrict;
+	my $perlglobal = 1;
+
+	if($C) {
+		$nostrict = $Global::PerlNoStrict->{$C->{CatalogName}};
+		$perlglobal = $Global::AllowGlobal->{$C->{CatalogName}};
+	}
+
 	$name =~ s/\s+//g;
 
 	# Untainting
@@ -5223,9 +5259,15 @@
 	if(! defined $C) {
 		$c->{$name} = eval $value;
 	}
-	elsif($Global::AllowGlobal->{$C->{CatalogName}}) {
+	elsif($perlglobal) {
 		package Vend::Interpolate;
-		$c->{$name} = eval $value;
+		if($nostrict) {
+			no strict;
+			$c->{$name} = eval $value;
+		}
+		else {
+			$c->{$name} = eval $value;
+		}
 	}
 	else {
 		package Vend::Interpolate;



2.311                interchange/lib/Vend/Interpolate.pm


rev 2.311, prev_rev 2.310
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.310
retrieving revision 2.311
diff -u -r2.310 -r2.311
--- Interpolate.pm	5 Dec 2008 16:43:40 -0000	2.310
+++ Interpolate.pm	29 Jan 2009 17:13:26 -0000	2.311
@@ -1,6 +1,6 @@
 # Vend::Interpolate - Interpret Interchange tags
 # 
-# $Id: Interpolate.pm,v 2.310 2008-12-05 16:43:40 mheins Exp $
+# $Id: Interpolate.pm,v 2.311 2009-01-29 17:13:26 mheins Exp $
 #
 # Copyright (C) 2002-2008 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -28,7 +28,7 @@
 require Exporter;
 @ISA = qw(Exporter);
 
-$VERSION = substr(q$Revision: 2.310 $, 10);
+$VERSION = substr(q$Revision: 2.311 $, 10);
 
 @EXPORT = qw (
 
@@ -1671,7 +1671,7 @@
 
 	$MVSAFE::Safe = 1;
 	if (
-		$opt->{global}
+		( $opt->{global} or (! defined $opt->{global} and $Global::PerlAlwaysGlobal->{$Vend::Cat} ) )
 			and
 		$Global::AllowGlobal->{$Vend::Cat}
 		)
@@ -1680,7 +1680,13 @@
 	}
 
 	if(! $MVSAFE::Safe) {
-		$result = eval($body);
+		if ($Global::PerlNoStrict->{$Vend::Cat} || $opt->{no_strict}) {
+			no strict;
+			$result = eval($body);
+		}
+		else {
+			$result = eval($body);
+		}
 	}
 	else {
 		$result = $ready_safe->reval($body);







More information about the interchange-cvs mailing list