aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;
}