Skip to content

Commit

Permalink
Merge pull request dev-sec#80 from aried3r/ar/use_dns
Browse files Browse the repository at this point in the history
Make UseDNS configurable
  • Loading branch information
arlimus committed Apr 27, 2015
2 parents 0bbbff6 + 1126326 commit 1d90833
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@
default['ssh']['allow_groups'] = [] # sshd
default['ssh']['print_motd'] = false # sshd
default['ssh']['print_last_log'] = false # sshd
default['ssh']['use_dns'] = true # sshd
# set this to nil to let us detect the attribute based on the node platform
default['ssh']['use_privilege_separation'] = nil
20 changes: 20 additions & 0 deletions spec/recipes/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -471,4 +471,24 @@
.with_content(/DenyUsers [^#]*\bsomeuser otheruser\b/)
end
end

context 'without attribute use_dns' do
it 'sets UseDNS to the default' do
expect(chef_run).to render_file('/etc/ssh/sshd_config')
.with_content(/UseDNS yes/)
end
end

context 'with attribute use_dns' do
cached(:chef_run) do
ChefSpec::ServerRunner.new do |node|
node.set['ssh']['use_dns'] = false
end.converge(described_recipe)
end

it 'sets UseDNS correctly' do
expect(chef_run).to render_file('/etc/ssh/sshd_config')
.with_content(/UseDNS no/)
end
end
end
4 changes: 1 addition & 3 deletions templates/default/opensshd.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ X11UseLocalhost yes
PrintMotd <%= ((@node['ssh']['print_motd']) ? 'yes' : 'no' ) %>
PrintLastLog <%= ((@node['ssh']['print_last_log']) ? 'yes' : 'no' ) %>
#Banner /etc/ssh/banner.txt
#UseDNS yes
UseDNS <%= ((@node['ssh']['use_dns']) ? 'yes' : 'no' ) %>
#PidFile /var/run/sshd.pid
#MaxStartups 10
#ChrootDirectory none
Expand All @@ -205,5 +205,3 @@ PrintLastLog <%= ((@node['ssh']['print_last_log']) ? 'yes' : 'no' ) %>
#PasswordAuthentication no
#PermitRootLogin no
#X11Forwarding no


0 comments on commit 1d90833

Please sign in to comment.