summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-07-02 19:33:46 -0500
committerLuke Kanies <luke@madstop.com>2008-07-02 19:33:46 -0500
commit00b7da39f79436950245f44ab1f7db71e81d3499 (patch)
treed8c63ae3b2f389327ef816bc6aa68c3fb0b11e99 /lib
parent3795654323dfdfe468f5dddfdc16787b883752db (diff)
Fixing the new-form version of #1382.
It only works when finding certificates, but that should be sufficient.
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/indirector/ssl_file.rb26
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/puppet/indirector/ssl_file.rb b/lib/puppet/indirector/ssl_file.rb
index 44a66fab2..d93298c8c 100644
--- a/lib/puppet/indirector/ssl_file.rb
+++ b/lib/puppet/indirector/ssl_file.rb
@@ -79,7 +79,7 @@ class Puppet::Indirector::SslFile < Puppet::Indirector::Terminus
def find(request)
path = path(request.key)
- return nil unless FileTest.exist?(path)
+ return nil unless FileTest.exist?(path) or rename_files_with_uppercase(path)
result = model.new(request.key)
result.read(path)
@@ -124,6 +124,30 @@ class Puppet::Indirector::SslFile < Puppet::Indirector::Terminus
self.class.ca_location
end
+ # A hack method to deal with files that exist with a different case.
+ # Just renames it; doesn't read it in or anything.
+ # LAK:NOTE This is a copy of the method in sslcertificates/support.rb,
+ # which we'll be EOL'ing at some point. This method was added at 20080702
+ # and should be removed at some point.
+ def rename_files_with_uppercase(file)
+ dir, short = File.split(file)
+ return nil unless FileTest.exist?(dir)
+
+ 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
+
# Yield a filehandle set up appropriately, either with our settings doing
# the work or opening a filehandle manually.
def write(name, path)