aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--config_default2
-rw-r--r--lib/MGA/Advisories.pm31
2 files changed, 10 insertions, 23 deletions
diff --git a/config_default b/config_default
index f44561d..fbcd072 100644
--- a/config_default
+++ b/config_default
@@ -20,6 +20,6 @@ advisory_types:
prefix: MGAA
security:
prefix: MGASA
-bugzilla_url: https://bugs.mageia.org/xmlrpc.cgi
+bugzilla_url: https://bugs.mageia.org/
bugzilla_login:
bugzilla_password:
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;