From e3f742cb4dec1c6fd033b2c9425ea598c24253db Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Mon, 25 Sep 2017 10:16:47 +0100 Subject: [PATCH] Handle multiple gpg keys in the content attribute --- lib/puppet/provider/apt_key2/apt_key2.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/puppet/provider/apt_key2/apt_key2.rb b/lib/puppet/provider/apt_key2/apt_key2.rb index 8e145ae..ad5d762 100644 --- a/lib/puppet/provider/apt_key2/apt_key2.rb +++ b/lib/puppet/provider/apt_key2/apt_key2.rb @@ -186,15 +186,14 @@ class Puppet::Provider::AptKey2::AptKey2 file.write content file.close if File.executable? '/usr/bin/gpg' - extracted_key = `/usr/bin/gpg --with-fingerprint --with-colons #{file.path}`.each_line.find { |line| line =~ %r{^fpr:} }.split(':')[9] + extracted_keys = `/usr/bin/gpg --with-fingerprint --with-colons #{file.path}`.each_line.select { |line| line =~ %r{^fpr:} }.map { |fpr| fpr.split(':')[9] } - case extracted_key - when title + if extracted_keys.include? title context.debug('Fingerprint verified against extracted key') - when %r{#{title}$} + elsif extracted_keys.any? { |k| k =~ %r{#{title}$} } context.debug('Fingerprint matches the extracted key') else - raise ArgumentError, "The fingerprint in your manifest (#{title}) and the fingerprint from content/source (#{extracted_key}) do not match. "\ + raise ArgumentError, "The fingerprint in your manifest (#{title}) and the fingerprint from content/source (#{extracted_keys.inspect}) do not match. "\ ' Please check there is not an error in the name or check the content/source is legitimate.' end else -- 2.45.2