Please review pull request #500: (#1168) Use implicit lower case value of certname opened by (jeffmccune)
Description:
Without this patch we explicitly fail hard when the certname setting is
configured to something that is mixed case or upper case.
This is a problem on Windows where the ComputerName defaults to an upper
case NETBIOS name. We cannot work around the problem in the MSI
installer effectively because we have virtually no string manipulation
capabilities and embedding _javascript_ into an MSI is ill advised for
long term supportability and compatibility with antivirus software.
This patch fixes the problem by always using the implied value of the
certname converted to lower case. We log an info message for the user
when we're not using the explicit value they've specified. Info should
only display when using verbose mode to prevent log spam.
- Opened: Wed Feb 15 04:45:11 UTC 2012
- Based on: puppetlabs:2.7.x (b9655fea47c5eefaa6f4768b750e634aeb063aca)
- Requested merge: jeffmccune:ticket/2.7.x/1168_downcase_certname_value (47af08944cb82c95ca92cf808bbd30e777bf7a27)
Diff follows:
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index 71d04df..730cc3c 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -226,7 +226,16 @@ module Puppet
:certname => {:default => fqdn.downcase, :desc => "The name to use when handling certificates. Defaults
to the fully qualified domain name.",
:call_on_define => true, # Call our hook with the default value, so we're always downcased
- :hook => proc { |value| raise(ArgumentError, "Certificate names must be lower case; see #1168") unless value == value.downcase }},
+ :hook => proc do |value|
+ lowercase_value = value.downcase
+ if value != lowercase_value then
+ Puppet.info "Using the implicit certname value of #{lowercase_value} instead of the explicit #{value} value"
+ end
+ # I have no idea why I need to modify the value in place, but I
+ # do to get the settings system to honor it in the spec test.
+ value.downcase!
+ end
+ },
:certdnsnames => {
:default => '',
:hook => proc do |value|
diff --git a/spec/integration/defaults_spec.rb b/spec/integration/defaults_spec.rb
index b641b20..1dae319 100755
--- a/spec/integration/defaults_spec.rb
+++ b/spec/integration/defaults_spec.rb
@@ -1,4 +1,4 @@
-#!/usr/bin/env rspec
+#!/usr/bin/env ruby -S rspec
require 'spec_helper'
require 'puppet/defaults'
@@ -17,8 +17,16 @@
end
describe "when setting the :certname" do
- it "should fail if the certname is not downcased" do
- lambda { Puppet.settings[:certname] = "Host.Domain.Com" }.should raise_error(ArgumentError)
+ it "should implicitly downcase the :certname (#1168)" do
+ Puppet.settings[:certname] = "Host.Domain.Baz"
+ Puppet.settings[:certname].should == "host.domain.baz"
+ end
+ it "should not modify a lower case :certname (#1168)" do
+ Puppet.settings[:certname] = "jeff.foo.yay"
+ Puppet.settings[:certname].should == "jeff.foo.yay"
+ end
+ it "should not fail if the certname is uppercase (#1168)" do
+ lambda { Puppet.settings[:certname] = "Host.Domain.Com" }.should_not raise_error
end
end
-- You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
