Skip to content

Commit f88929f

Browse files
committed
Merge remote-tracking branch 'upstream/5.5.x' into 6.4.x
* upstream/5.5.x: (PUP-10238) Change default value of strict_hostname_checking to true
2 parents 8ec5747 + c08b9fd commit f88929f

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
@@ -1257,13 +1257,23 @@ def self.initialize_default_settings!(settings)
12571257
overridden by more specific settings (see `ca_port`, `report_port`).",
12581258
},
12591259
:node_name => {
1260-
:default => "cert",
1260+
:default => 'cert',
1261+
:type => :enum,
1262+
:values => ['cert', 'facter'],
1263+
:deprecated => :completely,
1264+
:hook => proc { |val|
1265+
if val != 'cert'
1266+
Puppet.deprecation_warning("The node_name setting is deprecated and will be removed in a future release.")
1267+
end
1268+
},
12611269
:desc => "How the puppet master determines the client's identity
12621270
and sets the 'hostname', 'fqdn' and 'domain' facts for use in the manifest,
12631271
in particular for determining which 'node' statement applies to the client.
12641272
Possible values are 'cert' (use the subject's CN in the client's
12651273
certificate) and 'facter' (use the hostname that the client
1266-
reported in its facts)",
1274+
reported in its facts).
1275+
1276+
This setting is deprecated, please use explicit fact matching for classification.",
12671277
},
12681278
:bucketdir => {
12691279
:default => "$vardir/bucket",
@@ -1386,10 +1396,19 @@ def self.initialize_default_settings!(settings)
13861396
:desc => "Where the fileserver configuration is stored.",
13871397
},
13881398
:strict_hostname_checking => {
1389-
:default => false,
1399+
:default => true,
1400+
:type => :boolean,
13901401
:desc => "Whether to only search for the complete
1391-
hostname as it is in the certificate when searching for node information
1392-
in the catalogs.",
1402+
hostname as it is in the certificate when searching for node information
1403+
in the catalogs or to match dot delimited segments of the cert's certname
1404+
and the hostname, fqdn, and/or domain facts.
1405+
1406+
This setting is deprecated and will be removed in a future release.",
1407+
:hook => proc { |val|
1408+
if val != true
1409+
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).")
1410+
end
1411+
}
13931412
}
13941413
)
13951414

spec/unit/node_spec.rb

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

418418
describe Puppet::Node, "when generating the list of names to search through" do
419419
before do
420-
@node = Puppet::Node.new("foo.domain.com", :parameters => {"hostname" => "yay", "domain" => "domain.com"})
420+
Puppet[:strict_hostname_checking] = false
421+
@node = Puppet::Node.new("foo.domain.com",
422+
:parameters => {"hostname" => "yay", "domain" => "domain.com"})
421423
end
422424

423425
it "returns an array of names" do
@@ -448,7 +450,6 @@ def from_json(json)
448450

449451
describe "and :node_name is set to 'cert'" do
450452
before do
451-
Puppet[:strict_hostname_checking] = false
452453
Puppet[:node_name] = "cert"
453454
end
454455

@@ -457,16 +458,18 @@ def from_json(json)
457458
end
458459

459460
describe "and strict hostname checking is enabled" do
460-
it "only uses the passed-in key" do
461+
before do
461462
Puppet[:strict_hostname_checking] = true
463+
end
464+
465+
it "only uses the passed-in key" do
462466
expect(@node.names).to eq(["foo.domain.com"])
463467
end
464468
end
465469
end
466470

467471
describe "and :node_name is set to 'facter'" do
468472
before do
469-
Puppet[:strict_hostname_checking] = false
470473
Puppet[:node_name] = "facter"
471474
end
472475

0 commit comments

Comments
 (0)