Commit 11dae336 authored by BaiJiangJie's avatar BaiJiangJie

[Update] 解决sftp登录,绕过校验系统用户手动登录的情况3

parent e1eaaf8c
......@@ -4,6 +4,7 @@
import threading
import time
import copy
from .session import Session
from .models import Server, TelnetServer
......@@ -27,7 +28,7 @@ class ProxyServer:
def __init__(self, client, asset, system_user):
self.client = client
self.asset = asset
self.system_user = system_user
self.system_user = copy.deepcopy(system_user)
self.server = None
self.connecting = True
......
......@@ -120,7 +120,9 @@ class SFTPServer(paramiko.SFTPServerInterface):
raise PermissionError("No asset or system user explicit")
cache_key = '{}@{}'.format(su, host)
if cache_key not in self._sftp:
if cache_key in self._sftp:
return self._sftp[cache_key]
conn = SSHConnection.new_connection(self.server.connection.user,
asset, system_user)
__sftp = conn.get_sftp()
......@@ -138,8 +140,6 @@ class SFTPServer(paramiko.SFTPServerInterface):
)
else:
raise OSError("Can not connect asset sftp server: {}".format(conn.error))
else:
return self._sftp[cache_key]
def host_has_unique_su(self, host):
host_sus = self.get_host_system_users(host, only_name=True)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment