Support SSH tunneling with keys that don't have a passphrase. Fixes #3468
parent
7f7feee8c1
commit
ce768c7f8a
|
@ -26,3 +26,4 @@ Bug fixes
|
|||
| `Bug #3446 <https://redmine.postgresql.org/issues/3446>`_ - Various procedure/function related fixes for EPAS/PG 11.
|
||||
| `Bug #3448 <https://redmine.postgresql.org/issues/3448>`_ - Exclude system columns in Import/Export.
|
||||
| `Bug #3457 <https://redmine.postgresql.org/issues/3457>`_ - Fix debugging of procedures in EPAS packages.
|
||||
| `Bug #3468 <https://redmine.postgresql.org/issues/3468>`_ - Support SSH tunneling with keys that don't have a passphrase.
|
|
@ -782,7 +782,7 @@ class ServerNode(PGChildNodeView):
|
|||
have_password = False
|
||||
password = None
|
||||
passfile = None
|
||||
tunnel_password = None
|
||||
tunnel_password = ''
|
||||
if 'password' in data and data["password"] != '':
|
||||
# login with password
|
||||
have_password = True
|
||||
|
@ -973,7 +973,7 @@ class ServerNode(PGChildNodeView):
|
|||
return self.get_response_for_password(server, 428)
|
||||
else:
|
||||
tunnel_password = data['tunnel_password'] if 'tunnel_password'\
|
||||
in data else None
|
||||
in data else ''
|
||||
# Encrypt the password before saving with user's login
|
||||
# password key.
|
||||
try:
|
||||
|
|
|
@ -224,10 +224,10 @@ class Connection(BaseConnection):
|
|||
encpass = kwargs['password'] if 'password' in kwargs else None
|
||||
passfile = kwargs['passfile'] if 'passfile' in kwargs else None
|
||||
tunnel_password = kwargs['tunnel_password'] if 'tunnel_password' in \
|
||||
kwargs else None
|
||||
kwargs else ''
|
||||
|
||||
# Check SSH Tunnel needs to be created
|
||||
if manager.use_ssh_tunnel == 1 and tunnel_password is not None:
|
||||
if manager.use_ssh_tunnel == 1 and not manager.tunnel_created:
|
||||
status, error = manager.create_ssh_tunnel(tunnel_password)
|
||||
if not status:
|
||||
return False, error
|
||||
|
|
|
@ -40,6 +40,7 @@ class ServerManager(object):
|
|||
self.local_bind_host = '127.0.0.1'
|
||||
self.local_bind_port = None
|
||||
self.tunnel_object = None
|
||||
self.tunnel_created = False
|
||||
|
||||
self.update(server)
|
||||
|
||||
|
@ -378,6 +379,7 @@ WHERE db.oid = {0}""".format(did))
|
|||
if user is None:
|
||||
return False, gettext("Unauthorized request.")
|
||||
|
||||
if tunnel_password is not None and tunnel_password != '':
|
||||
try:
|
||||
tunnel_password = decrypt(tunnel_password, user.password)
|
||||
# Handling of non ascii password (Python2)
|
||||
|
@ -413,6 +415,7 @@ WHERE db.oid = {0}""".format(did))
|
|||
)
|
||||
|
||||
self.tunnel_object.start()
|
||||
self.tunnel_created = True
|
||||
except BaseSSHTunnelForwarderError as e:
|
||||
current_app.logger.exception(e)
|
||||
return False, "Failed to create the SSH tunnel." \
|
||||
|
@ -427,6 +430,7 @@ WHERE db.oid = {0}""".format(did))
|
|||
# Check SSH Tunnel is alive or not. if it is not then
|
||||
# raise the ConnectionLost exception.
|
||||
if self.tunnel_object is None or not self.tunnel_object.is_active:
|
||||
self.tunnel_created = False
|
||||
raise SSHTunnelConnectionLost(self.tunnel_host)
|
||||
|
||||
def stop_ssh_tunnel(self):
|
||||
|
@ -435,3 +439,4 @@ WHERE db.oid = {0}""".format(did))
|
|||
self.tunnel_object.stop()
|
||||
self.local_bind_port = None
|
||||
self.tunnel_object = None
|
||||
self.tunnel_created = False
|
||||
|
|
Loading…
Reference in New Issue