summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bugzilla/Arecibo.pm33
-rw-r--r--Bugzilla/Install/Filesystem.pm1
-rw-r--r--arecibo.pl55
3 files changed, 68 insertions, 21 deletions
diff --git a/Bugzilla/Arecibo.pm b/Bugzilla/Arecibo.pm
index 760c60c59..8c3282ab7 100644
--- a/Bugzilla/Arecibo.pm
+++ b/Bugzilla/Arecibo.pm
@@ -20,9 +20,10 @@ our @EXPORT = qw(
use Apache2::Log;
use Apache2::SubProcess;
use Carp;
+use Data::Dumper;
use Email::Date::Format qw(email_gmdate);
+use File::Temp;
use LWP::UserAgent;
-use POSIX qw(setsid nice);
use Sys::Hostname;
use Bugzilla::Constants;
@@ -205,27 +206,17 @@ sub arecibo_handle_error {
username => $username,
];
- # fork then post
- local $SIG{CHLD} = 'IGNORE';
- my $pid = fork();
- if (defined($pid) && $pid == 0) {
- # detach
- chdir('/');
- open(STDIN, '</dev/null');
- open(STDOUT, '>/dev/null');
- open(STDERR, '>/dev/null');
- setsid();
- nice(19);
-
- # post to arecibo (ignore any errors)
- my $agent = LWP::UserAgent->new(
- agent => 'bugzilla.mozilla.org',
- timeout => 10, # seconds
- );
- $agent->post($arecibo_server, $data);
-
- CORE::exit(0);
+ my $fh = File::Temp->new( UNLINK => 0 );
+ if (!$fh) {
+ warn "Failed to create temp file: $!\n";
+ return;
}
+ print $fh Dumper($data);
+ close($fh) or die $!;
+ my $filename = $fh->filename;
+
+ my $command = bz_locations()->{'cgi_path'} . "/arecibo.pl '$filename' &";
+ system($command);
return 1;
}
diff --git a/Bugzilla/Install/Filesystem.pm b/Bugzilla/Install/Filesystem.pm
index c3f103aaa..6297428af 100644
--- a/Bugzilla/Install/Filesystem.pm
+++ b/Bugzilla/Install/Filesystem.pm
@@ -159,6 +159,7 @@ sub FILESYSTEM {
'runtests.pl' => { perms => OWNER_EXECUTE },
'jobqueue.pl' => { perms => OWNER_EXECUTE },
'migrate.pl' => { perms => OWNER_EXECUTE },
+ 'arecibo.pl' => { perms => OWNER_EXECUTE },
'install-module.pl' => { perms => OWNER_EXECUTE },
'Bugzilla.pm' => { perms => CGI_READ },
diff --git a/arecibo.pl b/arecibo.pl
new file mode 100644
index 000000000..a6199a194
--- /dev/null
+++ b/arecibo.pl
@@ -0,0 +1,55 @@
+#!/usr/bin/perl -w
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+#
+# report errors to arecibo
+# expects a filename with a Data::Dumper serialised parameters
+# called by Bugzilla::Arecibo
+#
+
+use strict;
+use warnings;
+
+use FindBin qw($Bin);
+use lib $Bin;
+use lib "$Bin/lib";
+
+use Bugzilla;
+use File::Slurp;
+use POSIX qw(setsid nice);
+use Safe;
+
+nice(19);
+
+# detach
+open(STDIN, '</dev/null');
+open(STDOUT, '>/dev/null');
+open(STDERR, '>/dev/null');
+setsid();
+
+# grab arecibo server url
+my $arecibo_server = Bugzilla->params->{arecibo_server} || '';
+exit(1) unless $arecibo_server;
+
+# read data dump
+exit(1) unless my $filename = shift;
+my $dump = read_file($filename);
+unlink($filename);
+
+# deserialise
+my $cpt = new Safe;
+$cpt->reval($dump) || exit(1);
+my $data = ${$cpt->varglob('VAR1')};
+
+# and post to arecibo
+my $agent = LWP::UserAgent->new(
+ agent => 'bugzilla.mozilla.org',
+ timeout => 10, # seconds
+);
+$agent->post($arecibo_server, $data);