]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - modules/puppetmaster/lib/puppet/parser/functions/gen_tlsa_entry.rb
variable assignment does not clone string...
[dsa-puppet.git] / modules / puppetmaster / lib / puppet / parser / functions / gen_tlsa_entry.rb
index 0bf6bbafadfc12d5bc6fbff616bd587259724796..1257ae81c9731d5889e9f698b64403bae39bdc5e 100644 (file)
@@ -7,12 +7,12 @@ module Puppet::Parser::Functions
     if port.kind_of?(Array)
       ports = port
     else
-      ports = [ port ]
+      ports = [port]
     end
 
     res = []
-    res << "; cert #{certfile} for #{hostname}:#{port}."
-    ports.each{ |port|
+    res << "; cert #{certfile} for #{hostname}:#{ports}."
+    ports.each do |port|
       if File.exist?(certfile)
         cmd = ['swede', 'create', '--usage=3', '--selector=1', '--mtype=1', '--certificate', certfile, '--port', port.to_s, hostname]
         IO.popen(cmd, "r") {|i| res << i.read }
@@ -20,15 +20,16 @@ module Puppet::Parser::Functions
         res << "; certfile #{certfile} 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]
+      cfnew = certfile.gsub(/\.crt$/, '-new.crt')
+      if cfnew != certfile and File.exist?(cfnew)
+        cmd = ['swede', 'create', '--usage=3', '--selector=1', '--mtype=1', '--certificate', cfnew, '--port', port.to_s, hostname]
         new_entry = ''
         IO.popen(cmd, "r") {|i| new_entry = i.read }
         if not res.include?(new_entry)
           res << new_entry
         end
       end
-    }
+    end
 
     return res.join("\n")
   end