mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-13 05:05:29 +03:00
sshd: fix startWhenNeeded and listenAddresses combination
Previously, if startWhenNeeded was set, listenAddresses option was ignored and daemon was listening on all interfaces. Fixes #56325.
This commit is contained in:
parent
8a791f0b83
commit
131e31cd1b
2 changed files with 27 additions and 1 deletions
|
@ -400,7 +400,10 @@ in
|
||||||
sockets.sshd =
|
sockets.sshd =
|
||||||
{ description = "SSH Socket";
|
{ description = "SSH Socket";
|
||||||
wantedBy = [ "sockets.target" ];
|
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;
|
socketConfig.Accept = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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 =
|
client =
|
||||||
{ ... }: { };
|
{ ... }: { };
|
||||||
|
|
||||||
|
@ -77,5 +95,10 @@ in {
|
||||||
" server_lazy true");
|
" 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'");
|
||||||
|
}
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue