Your IP : 216.73.216.31


Current Path : /lib/python3/dist-packages/cloudinit/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/cloudinit/__pycache__/temp_utils.cpython-38.pyc

U

�Ad��@s�ddlZddlZddlZddlZddlZddlmZddlmZe�	e
�ZdadZ
dZded�dd	�Zded�d
d�Zdd
�Zejddd��Zded�dd�Zded�dd�ZdS)�N)�log)�utilz/run/cloud-init/tmpz/var/tmp/cloud-initF)�	needs_execCs:|dk	r|S|rtStrtSt��dkr,tStj�dd�S)NrZTMPDIRz/tmp)�_EXE_ROOT_TMPDIR�_TMPDIR�os�getuid�_ROOT_TMPDIR�environ�get)�odirr�r
�6/usr/lib/python3/dist-packages/cloudinit/temp_utils.py�get_tmp_ancestorsrcCs\t||�}tj�|�s,t�|�t�|d�|rHt�|d�rHt�	d|�|dkrX|sX|a
|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 noexecN)rr�path�isdir�makedirs�chmodrZ
has_mount_opt�LOGZwarningr)rr�tdirr
r
r�_tempfile_dir_args

�rcsTt|�dd�|�dd��|d<tjf|��dd�}|�_�fdd�}t�d|��S)	N�dirrFc
SsFzt�|�Wn2tk
r@}z|jtjkr0|�W5d}~XYnXdS�N)r�unlink�OSError�errnoZENOENT)r�er
r
r�_unlink_if_existsIs
z0ExtendedTemporaryFile.<locals>._unlink_if_existscs���j�dSr)r�namer
�Zfhr
r�
unlink_nowWsz)ExtendedTemporaryFile.<locals>.unlink_nowr )r�pop�tempfileZNamedTemporaryFiler�setattr)�kwargsrr r
rr�ExtendedTemporaryFile@s

�r%c
ks*tf|�}z
|VW5tj||d�XdS)N)�
ignore_errors)�mkdtemp�shutilZrmtree)Zrmtree_ignore_errorsr$rr
r
r�tempdir^s

r)cKst||�}tjfd|i|��S�Nr)rr"r'�rrr$r
r
rr'js
r'cKst||�}tjfd|i|��Sr*)rr"�mkstempr+r
r
rr,os
r,)NF)NF)F)NF)NF)�
contextlibrrr(r"Z	cloudinitrZloggingrZ	getLogger�__name__rrr	r�boolrrr%�contextmanagerr)r'r,r
r
r
r�<module>s"
"