INN commit: trunk/scripts (innupgrade.in)
INN Commit
Russ_Allbery at isc.org
Sat Jan 31 11:26:09 UTC 2009
Date: Saturday, January 31, 2009 @ 03:26:09
Author: iulius
Revision: 8308
Make innupgrade taint-safe; otherwise, it is not run on a few systems
like BSD/OS during "make update".
Modified:
trunk/scripts/innupgrade.in
---------------+
innupgrade.in | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
Modified: innupgrade.in
===================================================================
--- innupgrade.in 2009-01-31 08:30:38 UTC (rev 8307)
+++ innupgrade.in 2009-01-31 11:26:09 UTC (rev 8308)
@@ -1,4 +1,4 @@
-#! /usr/bin/perl -w
+#! /usr/bin/perl -w -T
## $Id$
##
@@ -12,6 +12,10 @@
## requires innconfval be able to parse inn.conf, and until this script runs,
## inn.conf may not be valid.
##
+## Tainting ("-T" flag to perl) is on because innupgrade can be run in that
+## mode on a few systems ("make update" does that on BSD/OS for instance).
+## Therefore, we have to be sure innupgrade is taint-safe.
+##
## Currently handles the following conversions:
##
## * Clean up inn.conf for the new parser in INN 2.4.
@@ -176,12 +180,19 @@
# defined and for each one of those, try running the upgrade rule.
sub upgrade_directory {
my $directory = shift;
+ my $file;
+ if ($directory =~ /^(.*)\/?$/) {
+ $directory = $1;
+ }
chdir $directory or die "Can't chdir to $directory: $!\n";
opendir (DIR, ".") or die "Can't opendir $directory: $!\n";
for (readdir DIR) {
- if ($FIXES{$_}) {
- upgrade_file ($_, $FIXES{$_});
+ if ($_ =~ /^([^\/]+)$/) {
+ $file = $1;
}
+ if ($FIXES{$file}) {
+ upgrade_file ($file, $FIXES{$file});
+ }
}
closedir DIR;
}
@@ -194,11 +205,12 @@
GetOptions ('file|f=s' => \$file,
'type|t=s' => \$type) or exit 1;
if ($file) {
- my $dirname = $file;
- $dirname =~ s%/[^/]+$%%;
+ my ($dirname, $basename);
+ if ($file =~ /^(.*)\/([^\/]+)$/) {
+ $dirname = $1;
+ $basename = $2;
+ }
chdir $dirname or die "Can't chdir to $dirname: $!\n";
- my $basename = $file;
- $basename =~ s%.*/%%;
$type ||= $basename;
if (!$FIXES{$type}) { die "No upgrade rules defined for $basename\n" }
upgrade_file ($basename, $FIXES{$type});
More information about the inn-committers
mailing list