403Webshell
Server IP : 23.254.227.96  /  Your IP : 216.73.216.7
Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k
System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64
User : viralblo ( 1001)
PHP Version : 8.1.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3.6/site-packages/cloudinit/handlers/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.6/site-packages/cloudinit/handlers/__pycache__/jinja_template.cpython-36.pyc
3

��b��@s"ddlZddlZddlZddlmZddlmZyddlmZ	ddl
mZWn"ek
rne
Z	ejd�ZYnXddlmZddlmZdd	lmZdd
lmZddlmZmZddlmZmZmZmZeje �Z!Gd
d�dej"�Z#ddd�Z$ddd�Z%e&ee&d�dd�Z'ddfdfdd�Z(dS)�N)�EACCES)�Optional)�UndefinedError)�operator_rez[-.])�handlers)�log)�
PER_ALWAYS)�INSTANCE_JSON_SENSITIVE_FILE)�MISSING_JINJA_PREFIX�
render_string)�b64d�
json_dumps�	load_file�	load_jsonc@s"eZdZdgZdd�Zdd�ZdS)�JinjaTemplatePartHandlerz## template: jinjacKsTtjj|tdd�||_i|_x0|jdg�D] }x|j�D]}||j|<q:Wq,WdS)N�)�version�sub_handlers)r�Handler�__init__r�pathsr�getZ
list_types)�selfrZ_kwargsZhandler�ctype�r�$/usr/lib/python3.6/jinja_template.pyrsz!JinjaTemplatePartHandler.__init__cCs�|tjkrdStjj|jjt�}t|||�}|s4dStj	|�}	|j
j|	�}
|
s`tj
d||	�dS|
jdkr�|
j||||||�n|
jdkr�|
j|||||�dS)NzPIgnoring jinja template for %s. Could not find supported sub-handler for type %sr�)rZCONTENT_SIGNALS�os�path�joinrZrun_dirr	�render_jinja_payload_from_fileZtype_from_starts_withrr�LOG�warningZhandler_version�handle_part)r�datar�filename�payloadZ	frequencyZheadersZjinja_json_file�rendered_payload�subtypeZsub_handlerrrrr#'s,




z$JinjaTemplatePartHandler.handle_partN)�__name__�
__module__�__qualname__�prefixesrr#rrrrrsrFcCs�i}d}tjj|�s td|��ytt|��}Wn>ttfk
rn}z|jt	kr^td|�|�WYdd}~XnXt
||||�}|s�dS|S)aRRender a jinja template payload sourcing variables from jinja_vars_path.

    @param payload: String of jinja template content. Should begin with
        ## template: jinja
.
    @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.
    NzFCannot render jinja template vars. Instance data not yet present at %szGCannot render jinja template vars. No read permission on '%s'. Try sudo)rr�exists�RuntimeErrorrr�IOError�OSError�errnor�render_jinja_payload)r&�
payload_fnZinstance_data_file�debug�
instance_datar'�errrr Fs&
r cCs�t||jdg�dd�}|r*tjdt|��yt||�}Wn6ttfk
rn}ztjd|t	|��dSd}~XnXdd�t
jdt|�D�}|r�tjd	|d
j
|��|S)Nzbase64-encoded-keysT)�decode_paths�include_key_aliaseszConverted jinja variables
%sz"Ignoring jinja template for %s: %scSsg|]}d|jtd��qS)z'%s'�)�replacer
)�.0�varrrr�
<listcomp>~sz(render_jinja_payload.<locals>.<listcomp>z%s[^\s]+z:Could not render jinja template variables in file '%s': %sz, )�convert_jinja_instance_datarr!r4r
r�	TypeError�JUndefinedErrorr"�str�re�findallr
r)r&r3r5r4Zinstance_jinja_varsr'r6�warningsrrrr2ns*
r2)�	orig_name�returncCstjtd|�}||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)rB�subr)rE�
alias_namerrr�get_jinja_variable_alias�srJr9�/cCs�i}dd�|D�}x�t|j��D]�\}}|r:dj|||�n|}||krNt|�}t|t�r�t|||||d�||<tjd|�r�x0||j�D]\}	}
t	j
|
�||	<q�Wn|||<|r t|�}|r t	j
||�||<q W|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|]}|jdd��qS)�-rG)r:)r;rrrrr=�sz/convert_jinja_instance_data.<locals>.<listcomp>z	{0}{1}{2})�sepr7r8zv\d+$)�sorted�items�formatr�
isinstance�dictr>rB�match�copy�deepcopyrJ)r$�prefixrMr7r8�result�key�valueZkey_pathZsubkeyZsubvaluerIrrrr>�s,
r>)F)F))rTrrBr1rZtypingrZjinja2.exceptionsrr@Zjinja2.lexerr�ImportError�	Exception�compileZ	cloudinitrrZloggingZcloudinit.settingsrZcloudinit.sourcesr	Zcloudinit.templaterr
rZcloudinit.utilrr
rrZ	getLoggerr)r!rrr r2rArJr>rrrr�<module>s,
,
'


Youez - 2016 - github.com/yon3zu
LinuXploit