Allow sshd.listenAddress = off to disable the daemon
We might not want to run the internal SSHD, ever, on this system. In such cases permit off for listenAddress so that we don't initialize a server key, or even try to load it at startup. Change-Id: Ia57c3aa24413d64e10e0440f758b3b18f881ddd9 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -216,7 +216,7 @@ public class SshDaemon extends SshServer implements SshInfo, LifecycleListener {
|
||||
|
||||
@Override
|
||||
public synchronized void start() {
|
||||
if (acceptor == null) {
|
||||
if (acceptor == null && !listen.isEmpty()) {
|
||||
checkConfig();
|
||||
|
||||
acceptor = createAcceptor();
|
||||
@@ -257,6 +257,10 @@ public class SshDaemon extends SshServer implements SshInfo, LifecycleListener {
|
||||
}
|
||||
|
||||
private List<HostKey> computeHostKeys() {
|
||||
if (listen.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
final List<PublicKey> keys = myHostKeys();
|
||||
final ArrayList<HostKey> r = new ArrayList<HostKey>();
|
||||
for (final PublicKey pub : keys) {
|
||||
@@ -348,6 +352,10 @@ public class SshDaemon extends SshServer implements SshInfo, LifecycleListener {
|
||||
return bind;
|
||||
}
|
||||
|
||||
if (want.length == 1 && isOff(want[0])) {
|
||||
return bind;
|
||||
}
|
||||
|
||||
for (final String desc : want) {
|
||||
try {
|
||||
bind.add(SocketUtil.resolve(desc, DEFAULT_PORT));
|
||||
@@ -358,6 +366,12 @@ public class SshDaemon extends SshServer implements SshInfo, LifecycleListener {
|
||||
return bind;
|
||||
}
|
||||
|
||||
private static boolean isOff(String listenHostname) {
|
||||
return "off".equalsIgnoreCase(listenHostname)
|
||||
|| "none".equalsIgnoreCase(listenHostname)
|
||||
|| "no".equalsIgnoreCase(listenHostname);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void initProviderBouncyCastle() {
|
||||
setKeyExchangeFactories(Arrays.<NamedFactory<KeyExchange>> asList(
|
||||
|
||||
Reference in New Issue
Block a user