svn commit: r532057 - head/Tools/scripts
Matthias Andree
mandree at FreeBSD.org
Sun Apr 19 00:36:05 UTC 2020
Author: mandree
Date: Sun Apr 19 00:36:04 2020
New Revision: 532057
URL: https://svnweb.freebsd.org/changeset/ports/532057
Log:
bump_revision.pl: minor usability improvements
- use env -S to split the shebang line (RhToad@#bsdports)
- launder -p PORTSDIR argument and chdir to it so it doesn't matter
which cwd bump_revision.pl is executed from
- if INDEX not found, hint the user that also his -p option might be off,
because the -i INDEX option defaults to a file relative to -p PORTSDIR.
Modified:
head/Tools/scripts/bump_revision.pl
Modified: head/Tools/scripts/bump_revision.pl
==============================================================================
--- head/Tools/scripts/bump_revision.pl Sun Apr 19 00:22:44 2020 (r532056)
+++ head/Tools/scripts/bump_revision.pl Sun Apr 19 00:36:04 2020 (r532057)
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl -wT
+#!/usr/bin/env -S perl -wT
# $FreeBSD$
@@ -7,15 +7,13 @@
# set of ports, for instance, when in the latter set one of the ports bumped the
# .so library version.
#
-# It is best executed with the working directory set to the base of a
-# ports tree, such as /usr/ports.
-#
# The shebang line above includes -T (taint) to be more distrustful
# about the environment, for security reasons, and is considered
# good Perl practice.
#
-# You can use either the -l (shaLlow, avoid grandparent dependencies,
-# slower) or -g option (include grandparent dependencies) option.
+# You can use either the
+# -l (shaLlow, avoid grandparent dependencies, slower) or
+# -g option (include grandparent dependencies) option.
#
# MAINTAINER= mandree at FreeBSD.org
#
@@ -126,7 +124,8 @@ my ($portsdir, $INDEX);
$INDEX = $opt_i if ($opt_i);
if (!-f $INDEX) { $INDEX = "$portsdir/INDEX"; }
- die "$INDEX doesn't seem to exist. Please check the value supplied with -i, or use -i /path/to/INDEX." unless(-f $INDEX);
+ die "$INDEX doesn't seem to exist. Please check the value supplied with -i,\n" .
+ "or use -i /path/to/INDEX, or check your -p PORTSDIR." unless(-f $INDEX);
}
usage() unless(@ARGV);
@@ -138,6 +137,16 @@ my $TMPDIR = File::Basename::dirname($INDEX);
if (-d "$TMPDIR/.svn" and not $opt_n and not $opt_c) {
die "$TMPDIR/.svn exists, cowardly refusing to proceed.\n";
}
+
+
+# must launder $portsdir (from command line => tainted) first
+if ($portsdir =~ /^([-\@\w.\/]+)$/) {
+ $portsdir = $1; }
+else {
+ die "Portsdir \"$portsdir\" contains unsafe characters. Aborting";
+}
+
+chdir "$portsdir" or die "cannot cd to $portsdir: $!\nAborting";
#
# Read the index, save some interesting keys
More information about the svn-ports-head
mailing list