diff --git a/paramiko/transport.py b/paramiko/transport.py index f72eebaf..ec7a1445 100644 --- a/paramiko/transport.py +++ b/paramiko/transport.py @@ -110,6 +110,8 @@ from paramiko.ssh_exception import ( from paramiko.util import retry_on_signal, ClosingContextManager, clamp_value +SERVER_DISABLED_BY_GENTOO = True + # for thread cleanup _active_threads = [] @@ -633,6 +635,8 @@ class Transport(threading.Thread, ClosingContextManager): `.SSHException` -- if negotiation fails (and no ``event`` was passed in) """ + if SERVER_DISABLED_BY_GENTOO: + raise Exception("Disabled by Gentoo for security reasons. Enable with 'server' USE flag") if server is None: server = ServerInterface() self.server_mode = True diff --git a/tests/conftest.py b/tests/conftest.py index 2b509c5c..bb23ac74 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,7 +4,7 @@ import shutil import threading import pytest -from paramiko import RSAKey, SFTPServer, SFTP, Transport +from paramiko import RSAKey, SFTPServer, SFTP, Transport, transport from .loop import LoopSocket from .stub_sftp import StubServer, StubSFTPServer @@ -15,6 +15,10 @@ from .util import _support # 'nicer'. +# We need the server component for testing +transport.SERVER_DISABLED_BY_GENTOO = False + + # Perform logging by default; pytest will capture and thus hide it normally, # presenting it on error/failure. (But also allow turning it off when doing # very pinpoint debugging - e.g. using breakpoints, so you don't want output