From: Peter Palfrader Date: Thu, 5 Nov 2015 19:04:35 +0000 (+0100) Subject: Fix stomping of certfile X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=4f61b8e70efe97667851c2db0034339a33ae1c06;p=mirror%2Fdsa-puppet.git Fix stomping of certfile --- diff --git a/modules/puppetmaster/lib/puppet/parser/functions/gen_tlsa_entry.rb b/modules/puppetmaster/lib/puppet/parser/functions/gen_tlsa_entry.rb index 0bf6bbafa..53a4922bd 100644 --- a/modules/puppetmaster/lib/puppet/parser/functions/gen_tlsa_entry.rb +++ b/modules/puppetmaster/lib/puppet/parser/functions/gen_tlsa_entry.rb @@ -13,15 +13,16 @@ module Puppet::Parser::Functions res = [] res << "; cert #{certfile} for #{hostname}:#{port}." ports.each{ |port| - if File.exist?(certfile) - cmd = ['swede', 'create', '--usage=3', '--selector=1', '--mtype=1', '--certificate', certfile, '--port', port.to_s, hostname] + cf = certfile + if File.exist?(cf) + cmd = ['swede', 'create', '--usage=3', '--selector=1', '--mtype=1', '--certificate', cf, '--port', port.to_s, hostname] IO.popen(cmd, "r") {|i| res << i.read } else - res << "; certfile #{certfile} did not exist to create TLSA record for #{hostname}:#{port}." + res << "; certfile #{cf} did not exist to create TLSA record for #{hostname}:#{port}." end - if certfile.gsub!(/\.crt$/, '-new.crt') and File.exist?(certfile) - cmd = ['swede', 'create', '--usage=3', '--selector=1', '--mtype=1', '--certificate', certfile, '--port', port.to_s, hostname] + if cf.gsub!(/\.crt$/, '-new.crt') and File.exist?(cf) + cmd = ['swede', 'create', '--usage=3', '--selector=1', '--mtype=1', '--certificate', cf, '--port', port.to_s, hostname] new_entry = '' IO.popen(cmd, "r") {|i| new_entry = i.read } if not res.include?(new_entry)