HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/cloudinit/__pycache__/temp_utils.cpython-38.pyc
U

Ӈg��@s�ddlZddlZddlZddlZddlZddlZddlmZe�e	�Z
dZdZde
d�dd�Zde
d�d	d
�Zdd�Zejdd
d��Zde
d�dd�Zde
d�dd�ZdS)�N)�utilz/run/cloud-init/tmpz/var/tmp/cloud-initF)�	needs_execCs2|dk	r|S|rtSt��dkr$tStj�dd�S)NrZTMPDIRz/tmp)�_EXE_ROOT_TMPDIR�os�getuid�_ROOT_TMPDIR�environ�get)�odirr�r�6/usr/lib/python3/dist-packages/cloudinit/temp_utils.py�get_tmp_ancestorsr
cCsLt||�}tj�|�s,t�|�t�|d�|rHt�|d�rHt�	d|�|S)a%Return the proper 'dir' argument for tempfile functions.

    When root, cloud-init will use /run/cloud-init/tmp to avoid
    any cleaning that a distro boot might do on /tmp (such as
    systemd-tmpfiles-clean).

    If the caller of this function (mkdtemp or mkstemp) was provided
    with a 'dir' argument, then that is respected.

    @param odir: original 'dir' arg to 'mkdtemp' or other.
    @param needs_exe: Boolean specifying whether or not exe permissions are
        needed for tempdir. This is needed because /run is mounted noexec.
    i�ZnoexeczDRequested temporal dir with exe permission `%s` is mounted as noexec)
r
r�path�isdir�makedirs�chmodrZ
has_mount_opt�LOGZwarning)r
r�tdirrrr�_tempfile_dir_args

�rcs@t�|d<tjf|��dd�}|�_�fdd�}t�d|��S)N�dirc
SsFzt�|�Wn2tk
r@}z|jtjkr0|�W5d}~XYnXdS�N)r�unlink�OSError�errnoZENOENT)r�errr�_unlink_if_exists?s
z0ExtendedTemporaryFile.<locals>._unlink_if_existscs���j�dSr)r�namer�Zfhrr�
unlink_nowMsz)ExtendedTemporaryFile.<locals>.unlink_nowr)r�tempfileZNamedTemporaryFiler�setattr)�kwargsrrrrr�ExtendedTemporaryFile8s
r"c
ks*tf|�}z
|VW5tj||d�XdS)N)�
ignore_errors)�mkdtemp�shutilZrmtree)Zrmtree_ignore_errorsr!rrrr�tempdirTs

r&cKst||�}tjfd|i|��S�Nr)rrr$�rrr!rrrr$`s
r$cKst||�}tjfd|i|��Sr')rr�mkstempr(rrrr)es
r))NF)NF)F)NF)NF)�
contextlibrZloggingrr%rZ	cloudinitrZ	getLogger�__name__rrr�boolr
rr"�contextmanagerr&r$r)rrrr�<module>s