I am using pyftpdlib to provide an FTP frontend to files indexed in a database using a class inherited from AbstractFS that retrieves the information from the database's API.
The API is accessed using the credentials provided by the FTP-Client (set by a custom DummyAuthorizer).
When implementing stat, I first used some static values and everything worked fine.
The database's API also provides information like size etc. and I updated filesystem's stat-method to retrieve this information.
Now, listing of a directory fails, as the API rejects the request.
Looking into the code, I found that in handler.py / ftp_MLSD only listdir is called within run_as_current_user.
So the stat call later within format_mlsx is not called as current user (and therefore the credentials in the API-call are not set).
I am not sure, why format_mlsx is not enclosed within run_as_current_user, as I would have assumed that any call on the filesystem should be run as the current user.
TLDR; AbstractFS.format_mlsx is called by FTPHandler without run_as_current_user, thereby filesystem has no user credentials available (for stat).
I am using pyftpdlib to provide an FTP frontend to files indexed in a database using a class inherited from
AbstractFS
that retrieves the information from the database's API. The API is accessed using the credentials provided by the FTP-Client (set by a customDummyAuthorizer
). When implementing stat, I first used some static values and everything worked fine. The database's API also provides information like size etc. and I updated filesystem's stat-method to retrieve this information. Now, listing of a directory fails, as the API rejects the request.Looking into the code, I found that in
handler.py
/ftp_MLSD
onlylistdir
is called withinrun_as_current_user
. So thestat
call later withinformat_mlsx
is not called as current user (and therefore the credentials in the API-call are not set). I am not sure, whyformat_mlsx
is not enclosed withinrun_as_current_user
, as I would have assumed that any call on the filesystem should be run as the current user.TLDR;
AbstractFS.format_mlsx
is called byFTPHandler
withoutrun_as_current_user
, thereby filesystem has no user credentials available (forstat
).