summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-07-02 18:12:26 -0500
committerLuke Kanies <luke@madstop.com>2008-07-02 18:12:26 -0500
commite03c1be35c5f04ba0e3d301579e8493c00d2ecf9 (patch)
treef579d054beea5e59f42ef84bde7a5f1d281201dc /lib
parentd3a81255245eec19ac21902ae3b877e00e620628 (diff)
downloadpuppet-e03c1be35c5f04ba0e3d301579e8493c00d2ecf9.tar.gz
puppet-e03c1be35c5f04ba0e3d301579e8493c00d2ecf9.tar.xz
puppet-e03c1be35c5f04ba0e3d301579e8493c00d2ecf9.zip
Fixing #1382 - existing uppercase certs, keys, et al will be renamed.
This correctly renames the files and they still get read in.
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/sslcertificates/support.rb24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/puppet/sslcertificates/support.rb b/lib/puppet/sslcertificates/support.rb
index 1d692c994..95f15f0a8 100644
--- a/lib/puppet/sslcertificates/support.rb
+++ b/lib/puppet/sslcertificates/support.rb
@@ -28,7 +28,8 @@ module Puppet::SSLCertificates::Support
# Define the reading method.
define_method(reader) do
- return nil unless FileTest.exists?(Puppet[param])
+ return nil unless FileTest.exists?(Puppet[param]) or rename_files_with_uppercase(Puppet[param])
+
begin
instance_variable_set(var, klass.new(File.read(Puppet[param])))
rescue => detail
@@ -121,5 +122,24 @@ module Puppet::SSLCertificates::Support
end
return retrieved
end
-end
+ # A hack method to deal with files that exist with a different case.
+ # Just renames it; doesn't read it in or anything.
+ def rename_files_with_uppercase(file)
+ dir = File.dirname(file)
+ short = File.basename(file)
+ raise ArgumentError, "Tried to fix SSL files to a file containing uppercase" unless short.downcase == short
+ real_file = Dir.entries(dir).reject { |f| f =~ /^\./ }.find do |other|
+ other.downcase == short
+ end
+
+ return nil unless real_file
+
+ full_file = File.join(dir, real_file)
+
+ Puppet.notice "Fixing case in %s; renaming to %s" % [full_file, file]
+ File.rename(full_file, file)
+
+ return true
+ end
+end