-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async method call in MySFTPServer __init__ method #695
Comments
Yeah - this might be tricky at the moment, as both the One thing you might try is setting an A cleaner fix would be to add the ability in AsyncSSH to use awaitables for more of the factory calls, and I've been doing that a little at a time (most recently to auth and kex exchange calls), but that has its own challenges, and can introduce race conditions if not done very carefully. |
As an aside, I also noticed you are setting |
Hello Thank you very much for your answer I tried with CoPilot and Azure AI and ChatGPT and couldn't succeed. Can you please help me what am I missing here?
|
I see two things that look like problems. First, the call to set_extra_info needs to look something like: conn.set_extra_info(home_folder=home_folder) Second, your init() code in MySFTPServer should look more like the original chroot example. For instance: def __init__(self, chan: asyncssh.SSHServerChannel):
self._chan = chan
self._home_folder = chan.get_connection().get_extra_info('home_folder')
os.makedirs(self._home_folder, exist_ok=True)
super().__init__(chan, chroot=self._home_folder)
logger.info(f"Establishing root folder for SFTP at: {self._home_folder}") This is adding the chroot to the |
Thank you for your fast answer. Following your recommendations I could progress more but it still ground zero: os.PathLike object, not NoneType because basically the info is empty.
It's like there is no way to pass this information to MySFTPServer. |
I didn't run into that here, but that suggests to me that maybe the database lookup failed and returned |
Hello
I need to get the path of the chroot of the user from the database. This is how I use my sftp server to create server.
This is how I implemented sftp server. the problem is at the get account by username method. That method should be asynchronous. I couldn't make init method asynchronous.
Copilot suggested me to create a create factory method that returns the instance of mysftpserver. But in that case the code block above doesn't work.
How can I change chroot of the sftp user retrieved from the database during the initialization?
I see ssh classes has
connection_made
method but SFTP subclasses doesn't, so I cannot change the users chroot after initialization.thank you for your help.
The text was updated successfully, but these errors were encountered: