Skip to content

Commit

Permalink
initial commit for gpg version checking
Browse files Browse the repository at this point in the history
better attempt at gpg version checking

adding in key length warning

removing version check, adding key check
  • Loading branch information
tphoney committed Mar 11, 2015
1 parent b473af1 commit 453b4eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/puppet/provider/apt_key/apt_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ def tempfile(content)
file = Tempfile.new('apt_key')
file.write content
file.close
#we now need to confirm that the fingerprint in this file, matches the long key that the user has given in the manifest
if name.size == 40
if File.executable? "/usr/bin/gpg"
extractedKey = execute(["/usr/bin/gpg --with-fingerprint --with-colons #{file.path} | awk -F: '/^fpr:/ { print $10 }'"], :failonfail => false)
extractedKey = extractedKey.chomp
if extractedKey != name
fail ("The id in your manifest and the fingerprint from content/source do not match. Please check the content/source is legitimate.")
end
end
end
file.path
end

Expand Down
3 changes: 3 additions & 0 deletions lib/puppet/type/apt_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
if self[:content] and self[:source]
fail('The properties content and source are mutually exclusive.')
end
if self[:id].length < 40
warning('The key should be at least a full fingerprint.')
end
end

newparam(:id, :namevar => true) do
Expand Down

0 comments on commit 453b4eb

Please sign in to comment.