def set_permissions(filename, uid=None, gid=None, mode=0775):
    """
    Set pemissions for given `filename`.

    Args:
        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
    """
    if uid is None:
        uid = get_ftp_uid()

    if gid is None:
        gid = -1

    os.chown(filename, uid, gid)
    os.chmod(filename, mode)
Set pemissions for given `filename`.

    Args:
        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