aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MGA/Advisories.pm
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2014-08-06 00:46:08 +0100
committerColin Guthrie <colin@mageia.org>2014-08-06 00:59:07 +0100
commitd0ae7c7cf28ff1243e5db7b46210206cad331c88 (patch)
treeb47386548dd5a420c74fff4645774f39e1f8d757 /lib/MGA/Advisories.pm
parent182f015efa0f7a21b7a824fe34b65c9a6a182cae (diff)
downloadmgaadvisories-d0ae7c7cf28ff1243e5db7b46210206cad331c88.tar
mgaadvisories-d0ae7c7cf28ff1243e5db7b46210206cad331c88.tar.gz
mgaadvisories-d0ae7c7cf28ff1243e5db7b46210206cad331c88.tar.bz2
mgaadvisories-d0ae7c7cf28ff1243e5db7b46210206cad331c88.tar.xz
mgaadvisories-d0ae7c7cf28ff1243e5db7b46210206cad331c88.zip
Drop cookie support for bugzilla.
Apparently this no longer works with BZ 4.4 and it now relies on a token to authenticate future requests. We now maintain this token and ensure we pass it in with future requests. Also strip of the xmlrpc.cgi part of the BZ URL so we can use it to validate bug URLs in the future. mga#13859
Diffstat (limited to 'lib/MGA/Advisories.pm')
-rw-r--r--lib/MGA/Advisories.pm31
1 files changed, 9 insertions, 22 deletions
diff --git a/lib/MGA/Advisories.pm b/lib/MGA/Advisories.pm
index aaba0f7..e56770d 100644
--- a/lib/MGA/Advisories.pm
+++ b/lib/MGA/Advisories.pm
@@ -10,7 +10,6 @@ use Email::Simple;
use Email::Simple::Creator;
use LWP::UserAgent;
use File::Basename;
-use HTTP::Cookies;
use XMLRPC::Lite;
#use Data::Dump qw(dd);
@@ -37,7 +36,7 @@ my %tools = (
my %bz = (
proxy => undef,
- cookies => undef,
+ token => undef
);
my @report_logs;
@@ -66,22 +65,8 @@ sub init_bz {
return 1 if ($bz{proxy});
return 0 if (!$config->{bugzilla_url});
- my $cookiefile = $ENV{HOME} . '/.mga-advisories/bugzilla-cookies.txt';
- if (!-d dirname($cookiefile)) {
- return 0 unless mkdir dirname($cookiefile);
- }
-
- $bz{cookies} = new HTTP::Cookies(
- file => $cookiefile,
- ignore_discard => 1,
- autosave => 1
- );
-
- # Q. Do I need to load the cookies or does this happen magically?
-
$bz{proxy} = XMLRPC::Lite->proxy(
- $config->{bugzilla_url},
- cookie_jar => $bz{cookies}
+ $config->{bugzilla_url} . "xmlrpc.cgi"
);
#$bz{proxy}->import(+trace => 'debug');
@@ -93,16 +78,15 @@ sub call_bz {
return 0 if (!init_bz());
+ $args[0]->{token} = $bz{token} if ($bz{token});
+
my $soapresult = $bz{proxy}->call($method, @args);
if ($soapresult->fault) {
if ($soapresult->faultcode == 410) {
# We need to login
-
- # Q. Do we need to save manually?
- $bz{cookies}->save();
- # TODO: chmod the jar... to 600
-
if (login_bz()) {
+ $args[0]->{token} = $bz{token};
+
# Try the call again now we're logged in.
$soapresult = $bz{proxy}->call($method, @args);
return $soapresult->result unless $soapresult->fault;
@@ -143,6 +127,9 @@ sub login_bz {
remember => 1
}
);
+ if ($soapresult->result && $soapresult->result->{token}) {
+ $bz{token} = $soapresult->result->{token};
+ }
return 1 unless $soapresult->fault;
}
return 0;