ProFTPD API

ProFTPD wrapped used to manage users of the FTP server.

This module controls the ftpd.passwd (LOGIN_FILE), creates/removes users directory and so on.

Warning

This API supposes, that it has permissions to read/write to ProFTPD configuration directory and to root directory for users.

Note

You don’t have to set the permissions and everything manually, there is script called initializer, which can do it for you automatically.

ftp.api.require_root(fn)[source]

Decorator to make sure, that user is root.

ftp.api.reload_configuration(*args, **kwargs)[source]

Send signal to the proftpd daemon to reload configuration.

ftp.api.recursive_chmod(path, mode=493)[source]

Recursively change mode for given path. Same as chmod -R mode.

Parameters:
  • path (str) – Path of the directory/file.
  • mode (octal int, default 0755) – New mode of the file.

Warning

Don’t forget to add 0 at the beginning of the numbers of mode, or Unspeakable hOrRoRs will be awaken from their unholy sleep outside of the reality and they WILL eat your soul (and your files).

ftp.api.create_lock_file(path)[source]

Create lock file filled with LOCK_FILE_CONTENT.

Parameters:path (str) – Path to the lock file. Made from users home directory and LOCK_FILENAME.
ftp.api.add_user(*args, **kwargs)[source]

Adds record to passwd-like file for ProFTPD, creates home directory and sets permissions for important files.

Parameters:
  • username (str) – User’s name.
  • password (str) – User’s password.
ftp.api.remove_user(*args, **kwargs)[source]

Remove user, his home directory and so on..

Parameters:username (str) – User’s name.
ftp.api.change_password(*args, **kwargs)[source]

Change password for given username.

Parameters:
  • username (str) – User’s name.
  • new_password (str) – User’s new password.
ftp.api.list_users(*args, **kwargs)[source]

List all registered users, which are stored in LOGIN_FILE.

Returns:of str usernames.
Return type:list