aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2014-11-24 22:01:20 +0000
committerColin Guthrie <colin@mageia.org>2014-11-25 10:30:51 +0000
commit926b9c61e34b804ec46b869c218ba828636a9c4e (patch)
treeefadd84896071e0f7bfa8c684cd6e18f2be7a9f3
parent4b023b7cfb13b03134ddb3b660863c76af6d1139 (diff)
downloadmgaadvisories-926b9c61e34b804ec46b869c218ba828636a9c4e.tar
mgaadvisories-926b9c61e34b804ec46b869c218ba828636a9c4e.tar.gz
mgaadvisories-926b9c61e34b804ec46b869c218ba828636a9c4e.tar.bz2
mgaadvisories-926b9c61e34b804ec46b869c218ba828636a9c4e.tar.xz
mgaadvisories-926b9c61e34b804ec46b869c218ba828636a9c4e.zip
Add support for authenticated bugzilla in QA mode.
This will allow QA team to post automated messages to BZ when trying to assign IDs and the cross check fails for whatever reason (typically deependent bugs or SRPM check failures).
-rw-r--r--config_default1
-rw-r--r--lib/MGA/Advisories.pm37
2 files changed, 34 insertions, 4 deletions
diff --git a/config_default b/config_default
index fbcd072..9e2ef03 100644
--- a/config_default
+++ b/config_default
@@ -23,3 +23,4 @@ advisory_types:
bugzilla_url: https://bugs.mageia.org/
bugzilla_login:
bugzilla_password:
+bugzilla_tokenfile: ~/.mga-advisories/bugzilla.token
diff --git a/lib/MGA/Advisories.pm b/lib/MGA/Advisories.pm
index 482bf43..0cf72d3 100644
--- a/lib/MGA/Advisories.pm
+++ b/lib/MGA/Advisories.pm
@@ -70,6 +70,16 @@ sub init_bz {
$bz{proxy} = XMLRPC::Lite->proxy(
$config->{bugzilla_url} . "xmlrpc.cgi"
);
+ if ($config->{bugzilla_tokenfile} && -f glob($config->{bugzilla_tokenfile})) {
+ if (open(my $fh, '<', glob($config->{bugzilla_tokenfile}))) {
+ while (my $row = <$fh>) {
+ chomp($bz{token} = $row);
+ last;
+ }
+ close $fh;
+ }
+ }
+
#$bz{proxy}->import(+trace => 'debug');
return 1;
@@ -106,13 +116,25 @@ sub call_bz {
}
sub login_bz {
+ my ($login, $password);
if ($config->{bugzilla_login} && $config->{bugzilla_password}) {
- my $password = $config->{bugzilla_password};
+ $login = $config->{bugzilla_login};
+ $password = $config->{bugzilla_password};
+ } elsif ($config->{mode} eq 'qa') {
+ print "Please enter your bugzilla user name (email address): ";
+ chomp($login = <STDIN>);
+ print "Please now enter your bugzilla password: ";
+ ReadMode('noecho');
+ chomp($password = <STDIN>);
+ ReadMode(0); # back to normal
+ print "\n";
+ }
+
+ if ($login && $password) {
if ( $password =~ /^file:\/\// ) {
if (open(my $fh, '<:encoding(UTF-8)', substr $password, 7)) {
while (my $row = <$fh>) {
- chomp $row;
- $password = $row;
+ chomp($password = $row);
last;
}
close $fh;
@@ -124,13 +146,20 @@ sub login_bz {
my $soapresult = $bz{proxy}->call(
'User.login',
{
- login => $config->{bugzilla_login},
+ login => $login,
password => $password,
remember => 1
}
);
if ($soapresult->result && $soapresult->result->{token}) {
$bz{token} = $soapresult->result->{token};
+ if ($config->{bugzilla_tokenfile}) {
+ if (open(my $fh, '>', glob($config->{bugzilla_tokenfile}))) {
+ print $fh $bz{token};
+ close $fh;
+ chmod 0600, glob($config->{bugzilla_tokenfile});
+ }
+ }
}
return 1 unless $soapresult->fault;
}