[debhelper-devel] [debhelper] 01/01: Dh_Getopt.pm: Validate package names passed to -p/-N
Niels Thykier
nthykier at moszumanska.debian.org
Tue Sep 19 18:32:28 UTC 2017
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch master
in repository debhelper.
commit 84f575c161f23d99a026a4fa6c89b2950cb398dc
Author: Niels Thykier <niels at thykier.net>
Date: Tue Sep 19 18:31:13 2017 +0000
Dh_Getopt.pm: Validate package names passed to -p/-N
Signed-off-by: Niels Thykier <niels at thykier.net>
---
debian/changelog | 3 +++
lib/Debian/Debhelper/Dh_Getopt.pm | 15 ++++++++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 7fb29db..61d5e99 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -27,6 +27,9 @@ debhelper (10.9) UNRELEASED; urgency=medium
(Closes: #840913)
* Dh_lib.pm: Expand *_doit and doit to also support a chdir in the
child process.
+ * Dh_Getopt.pm: Validate package names passed via -p and -N to ensure
+ they are present in d/control. Thanks to Matthias Klose for the
+ report. (Closes: #795432)
[ Felipe Sateler ]
* dh_systemd_enable: Refactor and add support for timer units.
diff --git a/lib/Debian/Debhelper/Dh_Getopt.pm b/lib/Debian/Debhelper/Dh_Getopt.pm
index a9518ed..10da2df 100644
--- a/lib/Debian/Debhelper/Dh_Getopt.pm
+++ b/lib/Debian/Debhelper/Dh_Getopt.pm
@@ -11,7 +11,7 @@ use warnings;
use Debian::Debhelper::Dh_Lib;
use Getopt::Long;
-my %exclude_package;
+my (%exclude_package, %known_packages);
sub showhelp {
my $prog=basename($0);
@@ -41,6 +41,10 @@ sub AddPackage { my($option,$value)=@_;
}
}
elsif ($option eq 'p' or $option eq 'package') {
+ %known_packages = map { $_ => 1 } getpackages() if not %known_packages;
+ if (not exists($known_packages{$value})) {
+ error("Requested unknown package ${value} via -p/--package, expected one of: " . join(' ', getpackages()));
+ }
push @{$dh{DOPACKAGES}}, $value;
}
else {
@@ -56,7 +60,12 @@ sub SetDebugPackage { my($option,$value)=@_;
}
# Add a package to a list of packages that should not be acted on.
-sub ExcludePackage { my($option,$value)=@_;
+sub ExcludePackage {
+ my($option, $value)=@_;
+ %known_packages = map { $_ => 1 } getpackages() if not %known_packages;
+ if (not exists($known_packages{$value})) {
+ error("Unknown package ${value} given via -N/--no-package, expected one of: " . join(' ', getpackages()));
+ }
$exclude_package{$value}=1;
}
@@ -230,7 +239,7 @@ sub parseopts {
my $ret=getoptions(\@ARGV, %params);
if (!$ret) {
if (! compat(7)) {
- error("unknown option; aborting");
+ error("unknown option or error during option parsing; aborting");
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git
More information about the debhelper-devel
mailing list