Passwd reader
API for reading/writing of the passwd file used by ProFTPD (and also unix).
API
-
ftp.passwd_reader.load_users(path='/etc/proftpd/ftpd.passwd')[source]
Read passwd file and return dict with users and all their settings.
Parameters: | path (str, default settings.LOGIN_FILE) –
path of the file,
which will be loaded (default ftp.settings.LOGIN_FILE). |
Returns: | (dict) –
username: {pass_hash, uid, gid, full_name, home, shell} |
Example of returned data:
{
"xex": {
"pass_hash": "$asd$aiosjdaiosjdásghwasdjo",
"uid": "2000",
"gid": "2000",
"full_name": "ftftf",
"home": "/home/ftp/xex",
"shell": "/bin/false"
}
}
-
ftp.passwd_reader.save_users(users, path='/etc/proftpd/ftpd.passwd')[source]
Save dictionary with user data to passwd file (default
ftp.settings.LOGIN_FILE).
Parameters: |
- users (dict) –
dictionary with user data. For details look at dict
returned from load_users().
- path (str, default settings.LOGIN_FILE) –
path of the file, where the
data will be stored (default ftp.settings.LOGIN_FILE).
|
-
ftp.passwd_reader.get_ftp_uid()[source]
Returns: | int –
UID of the proftpd/ftp user. |
Raises: | KeyError –
When proftpd and ftp user is not found. |
-
ftp.passwd_reader.set_permissions(filename, uid=None, gid=None, mode=509)[source]
Set pemissions for given filename.
Parameters: |
- filename (str) –
name of the file/directory
- uid (int, default proftpd) –
user ID - if not set, user ID of proftpd
is used
- gid (int) –
group ID, if not set, it is not changed
- mode (int, default 0775) –
unix access mode
|
-
ftp.passwd_reader.read_user_config(username, path='/etc/proftpd/ftpd.passwd')[source]
Read user’s configuration from otherwise unused field full_name in
passwd file.
Configuration is stored in string as list of t/f characters.
-
ftp.passwd_reader.save_user_config(username, conf_dict, path='/etc/proftpd/ftpd.passwd')[source]
Save user’s configuration to otherwise unused field full_name in passwd
file.