Skip to content
This repository was archived by the owner on Jul 14, 2022. It is now read-only.

Commit f45d0cf

Browse files
authored
Merge pull request ghoneycutt#193 from boandersson/X11UseLocalhost
Add configurable param X11UseLocalhost to sshd_config
2 parents aacf3a7 + f41d796 commit f45d0cf

11 files changed

+29
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,13 @@ X11Forwarding in sshd_config. Specifies whether X11 forwarding is permitted.
376376

377377
- *Default*: 'yes'
378378

379+
sshd_x11_use_localhost
380+
----------------------
381+
X11UseLocalhost in sshd_config. Specifies if sshd should bind the X11 forwarding server
382+
to the loopback address or to the wildcard address.
383+
384+
- *Default*: 'yes'
385+
379386
sshd_use_pam
380387
------------
381388
UsePam in sshd_config.

manifests/init.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
$sshd_password_authentication = 'yes',
7373
$sshd_allow_tcp_forwarding = 'yes',
7474
$sshd_x11_forwarding = 'yes',
75+
$sshd_x11_use_localhost = 'yes',
7576
$sshd_use_pam = 'USE_DEFAULTS',
7677
$sshd_client_alive_count_max = '3',
7778
$sshd_client_alive_interval = '0',
@@ -502,6 +503,7 @@
502503
validate_re($sshd_password_authentication, '^(yes|no)$', "ssh::sshd_password_authentication may be either 'yes' or 'no' and is set to <${sshd_password_authentication}>.")
503504
validate_re($sshd_allow_tcp_forwarding, '^(yes|no)$', "ssh::sshd_allow_tcp_forwarding may be either 'yes' or 'no' and is set to <${sshd_allow_tcp_forwarding}>.")
504505
validate_re($sshd_x11_forwarding, '^(yes|no)$', "ssh::sshd_x11_forwarding may be either 'yes' or 'no' and is set to <${sshd_x11_forwarding}>.")
506+
validate_re($sshd_x11_use_localhost, '^(yes|no)$', "ssh::sshd_x11_use_localhost may be either 'yes' or 'no' and is set to <${sshd_x11_use_localhost}>.")
505507
if $sshd_use_pam_real != undef {
506508
validate_re($sshd_use_pam_real, '^(yes|no)$', "ssh::sshd_use_pam may be either 'yes' or 'no' and is set to <${sshd_use_pam_real}>.")
507509
}

spec/classes/init_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@
394394
:sshd_pubkeyauthentication => 'no',
395395
:sshd_allow_tcp_forwarding => 'no',
396396
:sshd_x11_forwarding => 'no',
397+
:sshd_x11_use_localhost => 'no',
397398
:sshd_use_pam => 'no',
398399
:sshd_client_alive_interval => '242',
399400
:sshd_config_serverkeybits => '1024',
@@ -461,6 +462,7 @@
461462
it { should contain_file('sshd_config').with_content(/^KerberosAuthentication no$/) }
462463
it { should contain_file('sshd_config').with_content(/^AllowTcpForwarding no$/) }
463464
it { should contain_file('sshd_config').with_content(/^X11Forwarding no$/) }
465+
it { should contain_file('sshd_config').with_content(/^X11UseLocalhost no$/) }
464466
it { should contain_file('sshd_config').with_content(/^UsePAM no$/) }
465467
it { should contain_file('sshd_config').with_content(/^ClientAliveInterval 242$/) }
466468
it { should contain_file('sshd_config').with_content(/^ServerKeyBits 1024$/) }
@@ -948,6 +950,16 @@
948950
end
949951
end
950952

953+
context 'with sshd_x11_use_localhost set to invalid value on valid osfamily' do
954+
let(:params) { { :sshd_x11_use_localhost => 'invalid' } }
955+
956+
it 'should fail' do
957+
expect {
958+
should contain_class('ssh')
959+
}.to raise_error(Puppet::Error,/ssh::sshd_x11_use_localhost may be either \'yes\' or \'no\' and is set to <invalid>\./)
960+
end
961+
end
962+
951963
context 'with sshd_use_pam set to invalid value on valid osfamily' do
952964
let(:params) { { :sshd_use_pam => 'invalid' } }
953965

spec/fixtures/sshd_config_debian

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ AllowTcpForwarding yes
107107
X11Forwarding yes
108108
#X11DisplayOffset 10
109109
#X11UseLocalhost yes
110+
X11UseLocalhost yes
110111
#PrintMotd yes
111112
PrintMotd yes
112113
#PrintLastLog yes

spec/fixtures/sshd_config_rhel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ AllowTcpForwarding yes
107107
X11Forwarding yes
108108
#X11DisplayOffset 10
109109
#X11UseLocalhost yes
110+
X11UseLocalhost yes
110111
#PrintMotd yes
111112
PrintMotd yes
112113
#PrintLastLog yes

spec/fixtures/sshd_config_sles_12_x86_64

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ AllowTcpForwarding yes
107107
X11Forwarding yes
108108
#X11DisplayOffset 10
109109
#X11UseLocalhost yes
110+
X11UseLocalhost yes
110111
#PrintMotd yes
111112
PrintMotd yes
112113
#PrintLastLog yes

spec/fixtures/sshd_config_solaris

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ AllowTcpForwarding yes
9696
X11Forwarding yes
9797
#X11DisplayOffset 10
9898
#X11UseLocalhost yes
99+
X11UseLocalhost yes
99100
#PrintMotd yes
100101
PrintMotd yes
101102
#PrintLastLog yes

spec/fixtures/sshd_config_suse_i386

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ AllowTcpForwarding yes
107107
X11Forwarding yes
108108
#X11DisplayOffset 10
109109
#X11UseLocalhost yes
110+
X11UseLocalhost yes
110111
#PrintMotd yes
111112
PrintMotd yes
112113
#PrintLastLog yes

spec/fixtures/sshd_config_suse_x86_64

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ AllowTcpForwarding yes
107107
X11Forwarding yes
108108
#X11DisplayOffset 10
109109
#X11UseLocalhost yes
110+
X11UseLocalhost yes
110111
#PrintMotd yes
111112
PrintMotd yes
112113
#PrintLastLog yes

spec/fixtures/sshd_config_ubuntu1604

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ AllowTcpForwarding yes
110110
X11Forwarding yes
111111
#X11DisplayOffset 10
112112
#X11UseLocalhost yes
113+
X11UseLocalhost yes
113114
#PrintMotd yes
114115
PrintMotd yes
115116
#PrintLastLog yes

templates/sshd_config.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ AllowTcpForwarding <%= @sshd_allow_tcp_forwarding %>
161161
X11Forwarding <%= @sshd_x11_forwarding %>
162162
#X11DisplayOffset 10
163163
#X11UseLocalhost yes
164+
X11UseLocalhost <%= @sshd_x11_use_localhost %>
164165
#PrintMotd yes
165166
PrintMotd <%= @sshd_config_print_motd %>
166167
#PrintLastLog yes

0 commit comments

Comments
 (0)