Ignore subkeys in apt-key's output
[puppet-modules/puppetlabs-apt.git] / lib / puppet / provider / apt_key / apt_key.rb
index a6d68b1732dd4c0be547c0ce3bfe604aeae5ed04..5895b3162d4ddf3d996e92518560b81731959462 100644 (file)
@@ -31,6 +31,8 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do
     key_array = key_output.split("\n").collect do |line|
       if line.start_with?('pub')
           pub_line = line
+          # reset fpr_line, to skip any previous subkeys which were collected
+          fpr_line = nil
       elsif line.start_with?('fpr')
           fpr_line = line
       end
@@ -127,7 +129,9 @@ Puppet::Type.type(:apt_key).provide(:apt_key) do
       f
     else
       begin
-        key = parsedValue.read
+        user_pass = parsedValue.userinfo.nil? ? nil : parsedValue.userinfo.split(':')
+        parsedValue.userinfo = ''
+        key = open(parsedValue, :http_basic_authentication => user_pass).read
       rescue OpenURI::HTTPError, Net::FTPPermError => e
         fail("#{e.message} for #{resource[:source]}")
       rescue SocketError