Skip to content

Commit 6902474

Browse files
authored
use proper sshd binary location in config validate command (#435)
1 parent cdc4275 commit 6902474

5 files changed

Lines changed: 32 additions & 5 deletions

File tree

manifests/server/config.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
case $ssh::server::validate_sshd_file {
1313
true: {
14-
$sshd_validate_cmd = '/usr/sbin/sshd -tf %'
14+
$sshd_validate_cmd = "${ssh::server::sshd_binary} -tf %"
1515
}
1616
default: {
1717
$sshd_validate_cmd = undef

manifests/server/config_file.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
case $ssh::server::validate_sshd_file {
2424
true: {
25-
$sshd_validate_cmd = '/usr/sbin/sshd -tf %'
25+
$sshd_validate_cmd = "${ssh::server::sshd_binary} -tf %"
2626
}
2727
default: {
2828
$sshd_validate_cmd = undef

manifests/server/instances.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
if $facts['kernel'] == 'Linux' {
4747
case $validate_config_file {
4848
true: {
49-
$validate_cmd = '/usr/sbin/sshd -tf %'
49+
$validate_cmd = "${ssh::server::sshd_binary} -tf %"
5050
}
5151
default: {
5252
$validate_cmd = undef

spec/classes/init_spec.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,15 @@
134134
}
135135
end
136136

137-
it { is_expected.to contain_concat('/etc/ssh/sshd_config').with_validate_cmd('/usr/sbin/sshd -tf %') }
137+
sshd_binary = case os_facts[:os]['family']
138+
when 'FreeBSD'
139+
'/usr/local/sbin/sshd'
140+
when 'Archlinux'
141+
'/usr/bin/sshd'
142+
else
143+
'/usr/sbin/sshd'
144+
end
145+
it { is_expected.to contain_concat('/etc/ssh/sshd_config').with_validate_cmd("#{sshd_binary} -tf %") }
138146
end
139147

140148
context 'without resource purging' do

spec/classes/server_spec.rb

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,26 @@
8686
}
8787
end
8888

89-
it { is_expected.to contain_concat('/etc/ssh/sshd_config').with_validate_cmd('/usr/sbin/sshd -tf %') }
89+
sshd_binary = case os_facts[:os]['family']
90+
when 'FreeBSD'
91+
'/usr/local/sbin/sshd'
92+
when 'Archlinux'
93+
'/usr/bin/sshd'
94+
else
95+
'/usr/sbin/sshd'
96+
end
97+
it { is_expected.to contain_concat('/etc/ssh/sshd_config').with_validate_cmd("#{sshd_binary} -tf %") }
98+
end
99+
100+
context 'with a different sshd_binary location' do
101+
let :params do
102+
{
103+
validate_sshd_file: true,
104+
sshd_binary: '/usr/another_bin/sshd'
105+
}
106+
end
107+
108+
it { is_expected.to contain_concat('/etc/ssh/sshd_config').with_validate_cmd('/usr/another_bin/sshd -tf %') }
90109
end
91110

92111
context 'with a different sshd_config location' do

0 commit comments

Comments
 (0)