Merge pull request #56326 from uvNikita/openssh/fix-socket

sshd: fix startWhenNeeded and listenAddresses combination
This commit is contained in:
Linus Heckemann 2019-02-25 12:06:11 +01:00 committed by GitHub
commit dd25140305
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View File

@ -400,7 +400,10 @@ in
sockets.sshd =
{ description = "SSH Socket";
wantedBy = [ "sockets.target" ];
socketConfig.ListenStream = cfg.ports;
socketConfig.ListenStream = if cfg.listenAddresses != [] then
map (l: "${l.addr}:${toString (if l.port != null then l.port else 22)}") cfg.listenAddresses
else
cfg.ports;
socketConfig.Accept = true;
};

View File

@ -34,6 +34,24 @@ in {
];
};
server_localhost_only =
{ ... }:
{
services.openssh = {
enable = true; listenAddresses = [ { addr = "127.0.0.1"; port = 22; } ];
};
};
server_localhost_only_lazy =
{ ... }:
{
services.openssh = {
enable = true; startWhenNeeded = true; listenAddresses = [ { addr = "127.0.0.1"; port = 22; } ];
};
};
client =
{ ... }: { };
@ -77,5 +95,10 @@ in {
" server_lazy true");
};
subtest "localhost-only", sub {
$server_localhost_only->succeed("ss -nlt | grep '127.0.0.1:22'");
$server_localhost_only_lazy->succeed("ss -nlt | grep '127.0.0.1:22'");
}
'';
})