From d0ae7c7cf28ff1243e5db7b46210206cad331c88 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Wed, 6 Aug 2014 00:46:08 +0100 Subject: 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 --- lib/MGA/Advisories.pm | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) (limited to 'lib') 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; -- cgit v1.2.1