def set_file_permissions(self, filename: str) -> None:
        """Set permissions of file *filename* according to the expected permissions.

        .. note::
            Use original umask if the file is not under PGDATA, use PGDATA
            permissions otherwise.

        :param filename: path to a file which permissions might need to be adjusted.
        """
        if is_subpath(self._postgresql.data_dir, filename):
            pg_perm.set_permissions_from_data_directory(self._postgresql.data_dir)
            os.chmod(filename, pg_perm.file_create_mode)
        else:
            os.chmod(filename, 0o666 & ~pg_perm.orig_umask)
Set permissions of file *filename* according to the expected permissions.

        .. note::
            Use original umask if the file is not under PGDATA, use PGDATA
            permissions otherwise.

        :param filename: path to a file which permissions might need to be adjusted.
        
patroni/postgresql/config.py