Skip to content

Commit ca22e81

Browse files
author
Lucas RAVAGNIER
committed
tests: add sshd_config.d include regression test
sshd on XCP-ng hosts has silently ignored /etc/ssh/sshd_config.d/*.conf drop-in files due to a missing Include directive in the packaged sshd_config. Add a quick host-only test that drops a harmless Banner directive in the directory and checks it shows up in `sshd -T`'s effective configuration. Signed-off-by: Lucas RAVAGNIER <lucas.ravagnier@vates.tech>
1 parent dada3a6 commit ca22e81

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from lib.common import Defer
2+
from lib.host import Host
3+
4+
# Regression test for sshd silently ignoring /etc/ssh/sshd_config.d/*.conf
5+
# drop-in files (missing "Include" directive in the packaged sshd_config).
6+
#
7+
# A drop-in file is created, setting a directive (a pre-auth Banner), that
8+
# isn't set anywhere else. `sshd -T` dumps the configuration as sshd itself
9+
# would apply it, so finding the directive there proves the drop-in directory
10+
# is actually included.
11+
#
12+
# Requirements:
13+
# - an XCP-ng host (--hosts) >= 8.2
14+
15+
SSHD_CONFIG_D = "/etc/ssh/sshd_config.d"
16+
17+
def test_sshd_config_d_is_included(host: Host, defer: Defer) -> None:
18+
marker = host.ssh('mktemp')
19+
dropin = f"{SSHD_CONFIG_D}/99-xcp-ng-tests-include-check.conf"
20+
21+
host.ssh(f"echo 'Banner {marker}' > {dropin}")
22+
defer(lambda: host.ssh(f"rm -f {dropin}"))
23+
24+
effective_config = host.ssh("/usr/sbin/sshd -T")
25+
assert f"banner {marker}" in effective_config, (
26+
f"drop-in {dropin} was not picked up by sshd -T: "
27+
f"{SSHD_CONFIG_D} seems to be ignored"
28+
)

0 commit comments

Comments
 (0)