From d6be829bf56e699d27d388026d4af7ab710ba328 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 25 Jul 2015 16:30:09 +0100 Subject: [PATCH] Work around #793471 (madness with $SIG{__WARN__} and Perl's system builtin): move $SIG{} setting into setup_sigwarn in Dgit.pm, and check getppid. We also need to fix up the expectation for an error message in one of the tests, where the message changes as a side effect. --- Debian/Dgit.pm | 10 +++++++++- debian/changelog | 3 +++ dgit | 4 +++- infra/dgit-repos-policy-debian | 5 +++-- infra/dgit-repos-server | 6 +++--- tests/tests/trustingpolicy-replay | 2 +- 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm index edb338ca..d66b712b 100644 --- a/Debian/Dgit.pm +++ b/Debian/Dgit.pm @@ -15,7 +15,8 @@ BEGIN { $VERSION = 1.00; @ISA = qw(Exporter); - @EXPORT = qw(debiantag server_branch server_ref + @EXPORT = qw(setup_sigwarn + debiantag server_branch server_ref stat_exists fail ensuredir waitstatusmsg failedcmd cmdoutput cmdoutput_errok git_rev_parse git_get_ref git_for_each_ref @@ -48,6 +49,13 @@ sub FRESHREPO () { return 0x4; } our $debugprefix; our $debuglevel = 0; +sub setup_sigwarn () { + our $sigwarn_mainprocess = $$; + $SIG{__WARN__} = sub { + die $_[0] unless getppid == $sigwarn_mainprocess; + }; +} + sub initdebug ($) { ($debugprefix) = @_; open DEBUG, ">/dev/null" or die $!; diff --git a/debian/changelog b/debian/changelog index 4a0765a3..2e6e7447 100644 --- a/debian/changelog +++ b/debian/changelog @@ -25,6 +25,9 @@ dgit (1.1) unstable; urgency=low packages (!) * --new is needed for read access to packages in NEW, too. Document this, and make it work properly. + * Work around #793471 (madness with $SIG{__WARN__} and Perl's system + builtin): move $SIG{} setting into setup_sigwarn in Dgit.pm, and + check getppid. -- diff --git a/dgit b/dgit index 1e389088..9dadc8cc 100755 --- a/dgit +++ b/dgit @@ -18,7 +18,9 @@ # along with this program. If not, see . use strict; -$SIG{__WARN__} = sub { die $_[0]; }; + +use Debian::Dgit; +setup_sigwarn(); use IO::Handle; use Data::Dumper; diff --git a/infra/dgit-repos-policy-debian b/infra/dgit-repos-policy-debian index b6310d95..fbf2d516 100755 --- a/infra/dgit-repos-policy-debian +++ b/infra/dgit-repos-policy-debian @@ -2,7 +2,9 @@ # dgit repos policy hook script for Debian use strict; -$SIG{__WARN__} = sub { die $_[0]; }; + +use Debian::Dgit qw(:DEFAULT :policyflags); +setup_sigwarn(); use POSIX; use JSON; @@ -11,7 +13,6 @@ use DBI; use IPC::Open2; use Data::Dumper; -use Debian::Dgit qw(:DEFAULT :policyflags); use Debian::Dgit::Policy::Debian; initdebug('%'); diff --git a/infra/dgit-repos-server b/infra/dgit-repos-server index 92f197b0..9705a642 100755 --- a/infra/dgit-repos-server +++ b/infra/dgit-repos-server @@ -33,7 +33,9 @@ # (With --cron AUTH-SPEC is not used and may be the empty string.) use strict; -$SIG{__WARN__} = sub { die $_[0]; }; + +use Debian::Dgit qw(:DEFAULT :policyflags); +setup_sigwarn(); # DGIT-REPOS-DIR contains: # git tree (or other object) lock (in acquisition order, outer first) @@ -189,8 +191,6 @@ use Fcntl qw(:flock); use File::Path qw(rmtree); use File::Temp qw(tempfile); -use Debian::Dgit qw(:DEFAULT :policyflags); - initdebug(''); our $func; diff --git a/tests/tests/trustingpolicy-replay b/tests/tests/trustingpolicy-replay index b779f64b..517f98a0 100755 --- a/tests/tests/trustingpolicy-replay +++ b/tests/tests/trustingpolicy-replay @@ -47,7 +47,7 @@ prepare-replay () { t-commit "request with $delib that we will replay" t-dgit build - t-expect-push-fail E:'policy-hook.*No such file or directory' \ + t-expect-push-fail 'system: No such file or directory' \ t-dgit push $delib t-policy dgit-repos-policy-trusting -- 2.30.2