summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-09-02 01:51:19 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-09-02 01:51:19 (GMT)
commit20a676c8700c222e0397af6bc4f62adcaa5a0184 (patch)
tree2d2e7b5d16f0e7f0fa6a1b08b802f55d73c76655
parentff963ab2c8b05c5f7eb198fdef1a252915d9c5ef (diff)
get CBA api key from .netrc file
-rw-r--r--rhautoimport.pm9
1 files changed, 4 insertions, 5 deletions
diff --git a/rhautoimport.pm b/rhautoimport.pm
index 1af005f..06a0acc 100644
--- a/rhautoimport.pm
+++ b/rhautoimport.pm
@@ -34,13 +34,13 @@ use RHRD::rddb;
use RHRD::utils;
use JSON::MaybeXS;
use URI::QueryParam;
+use Net::Netrc;
use constant {
RD_USER => 'autoimport',
RHIMPORTD_WATCH_DIR => '/run/rhimportd/watch',
RHIMPORTD_TIMEOUT => 10,
- CBA_API_KEY => '/etc/cba-api.key'
};
sub report_title_and_last
@@ -105,12 +105,11 @@ sub fetch_parse_rss_cba
my ($url, $ua_str, $headers, $queries) = @_;
my $api_key = undef;
- if (open my $api_key_file, '<', CBA_API_KEY) {
- $api_key = <$api_key_file>;
- close $api_key_file;
+ my $machine = Net::Netrc->lookup('cba');
+ if (defined $machine) {
+ $api_key = $machine->password();
}
if (defined $api_key) {
- chomp $api_key;
if (defined $queries) {
$queries->{'c'} = $api_key;
} else {