Skip to content

Commit f00a4b2

Browse files
committed
(PUP-10238) Change default value of strict_hostname_checking to true
Previously our default value of strict_hostname_checking was false which allowed matching dotted segments of a nodes certname (its CN in its certificate) as well as the segments of its fqdn fact, or hostname + domain fact. This was for compatibility when fact based classification within a site.pp was a more common pattern and node declarations were much less powerful than they are now. With the ability to use regular expressions in a node declaration the auto segmenting is no longer needed and with the ability to use facts directly, to use fact interpetation in hiera lookups, or create a custom external node classifier the injecting of facts into the nodes "name" is unneeded. The desire is to remove the setting completely in Puppet 7, while leaving it in 6 so those that depend on this behavior have time to re-write their site.pps to the newer styles. strict_hostname_checking setting is not marked deprecated completely because it will cause deprecation notices on setting access, which happens as part of normal compilation for now. However it does mark "node_name" setting as deprecated completely because it is now only referenced in code that by default will not run (and will only run if users change strict_hostname_checking back to false).
1 parent 8e9ab0c commit f00a4b2

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

lib/puppet/defaults.rb

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,13 +1297,23 @@ def self.initialize_default_settings!(settings)
12971297
overridden by more specific settings (see `ca_port`, `report_port`).",
12981298
},
12991299
:node_name => {
1300-
:default => "cert",
1300+
:default => 'cert',
1301+
:type => :enum,
1302+
:values => ['cert', 'facter'],
1303+
:deprecated => :completely,
1304+
:hook => proc { |val|
1305+
if val != 'cert'
1306+
Puppet.deprecation_warning("The node_name setting is deprecated and will be removed in a future release.")
1307+
end
1308+
},
13011309
:desc => "How the puppet master determines the client's identity
13021310
and sets the 'hostname', 'fqdn' and 'domain' facts for use in the manifest,
13031311
in particular for determining which 'node' statement applies to the client.
13041312
Possible values are 'cert' (use the subject's CN in the client's
13051313
certificate) and 'facter' (use the hostname that the client
1306-
reported in its facts)",
1314+
reported in its facts).
1315+
1316+
This setting is deprecated, please use explicit fact matching for classification.",
13071317
},
13081318
:bucketdir => {
13091319
:default => "$vardir/bucket",
@@ -1432,10 +1442,19 @@ def self.initialize_default_settings!(settings)
14321442
:desc => "Where the fileserver configuration is stored.",
14331443
},
14341444
:strict_hostname_checking => {
1435-
:default => false,
1445+
:default => true,
1446+
:type => :boolean,
14361447
:desc => "Whether to only search for the complete
1437-
hostname as it is in the certificate when searching for node information
1438-
in the catalogs.",
1448+
hostname as it is in the certificate when searching for node information
1449+
in the catalogs or to match dot delimited segments of the cert's certname
1450+
and the hostname, fqdn, and/or domain facts.
1451+
1452+
This setting is deprecated and will be removed in a future release.",
1453+
:hook => proc { |val|
1454+
if val != true
1455+
Puppet.deprecation_warning("Setting strict_hostname_checking to false is deprecated and will be removed in a future release. Please use regular expressions in your node declarations or explicit fact matching for classification (though be warned that fact based classification may be considered insecure).")
1456+
end
1457+
}
14391458
}
14401459
)
14411460

spec/unit/node_spec.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,9 @@ def from_json(json)
414414

415415
describe Puppet::Node, "when generating the list of names to search through" do
416416
before do
417-
@node = Puppet::Node.new("foo.domain.com", :parameters => {"hostname" => "yay", "domain" => "domain.com"})
417+
Puppet[:strict_hostname_checking] = false
418+
@node = Puppet::Node.new("foo.domain.com",
419+
:parameters => {"hostname" => "yay", "domain" => "domain.com"})
418420
end
419421

420422
it "returns an array of names" do
@@ -445,7 +447,6 @@ def from_json(json)
445447

446448
describe "and :node_name is set to 'cert'" do
447449
before do
448-
Puppet[:strict_hostname_checking] = false
449450
Puppet[:node_name] = "cert"
450451
end
451452

@@ -454,16 +455,18 @@ def from_json(json)
454455
end
455456

456457
describe "and strict hostname checking is enabled" do
457-
it "only uses the passed-in key" do
458+
before do
458459
Puppet[:strict_hostname_checking] = true
460+
end
461+
462+
it "only uses the passed-in key" do
459463
expect(@node.names).to eq(["foo.domain.com"])
460464
end
461465
end
462466
end
463467

464468
describe "and :node_name is set to 'facter'" do
465469
before do
466-
Puppet[:strict_hostname_checking] = false
467470
Puppet[:node_name] = "facter"
468471
end
469472

0 commit comments

Comments
 (0)