Skip to content

Commit 0f2fbe3

Browse files
committed
Use OpenSSH default for UseDNS. Fixes #81
1 parent 0bf7ae2 commit 0f2fbe3

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

attributes/default.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
default['ssh']['allow_groups'] = [] # sshd
6666
default['ssh']['print_motd'] = false # sshd
6767
default['ssh']['print_last_log'] = false # sshd
68-
default['ssh']['use_dns'] = true # sshd
68+
# set this to nil to let us use the default OpenSSH in case it's not set by the user
69+
default['ssh']['use_dns'] = nil # sshd
6970
# set this to nil to let us detect the attribute based on the node platform
7071
default['ssh']['use_privilege_separation'] = nil

spec/recipes/server_spec.rb

+16-3
Original file line numberDiff line numberDiff line change
@@ -473,13 +473,13 @@
473473
end
474474

475475
context 'without attribute use_dns' do
476-
it 'sets UseDNS to the default' do
476+
it 'leaves UseDNS commented' do
477477
expect(chef_run).to render_file('/etc/ssh/sshd_config')
478-
.with_content(/UseDNS yes/)
478+
.with_content(/#UseDNS no/)
479479
end
480480
end
481481

482-
context 'with attribute use_dns' do
482+
context 'with attribute use_dns set to false' do
483483
cached(:chef_run) do
484484
ChefSpec::ServerRunner.new do |node|
485485
node.set['ssh']['use_dns'] = false
@@ -491,4 +491,17 @@
491491
.with_content(/UseDNS no/)
492492
end
493493
end
494+
495+
context 'with attribute use_dns set to true' do
496+
cached(:chef_run) do
497+
ChefSpec::ServerRunner.new do |node|
498+
node.set['ssh']['use_dns'] = true
499+
end.converge(described_recipe)
500+
end
501+
502+
it 'sets UseDNS correctly' do
503+
expect(chef_run).to render_file('/etc/ssh/sshd_config')
504+
.with_content(/UseDNS yes/)
505+
end
506+
end
494507
end

templates/default/opensshd.conf.erb

+5
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,12 @@ X11UseLocalhost yes
185185
PrintMotd <%= ((@node['ssh']['print_motd']) ? 'yes' : 'no' ) %>
186186
PrintLastLog <%= ((@node['ssh']['print_last_log']) ? 'yes' : 'no' ) %>
187187
#Banner /etc/ssh/banner.txt
188+
<% if @node['ssh']['use_dns'].nil? %>
189+
# Since OpenSSH 6.8, this value defaults to 'no'
190+
#UseDNS no
191+
<% else %>
188192
UseDNS <%= ((@node['ssh']['use_dns']) ? 'yes' : 'no' ) %>
193+
<% end %>
189194
#PidFile /var/run/sshd.pid
190195
#MaxStartups 10
191196
#ChrootDirectory none

0 commit comments

Comments
 (0)