Ë
    x[hÅ  ã                   óÐ   — d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ  ej                  e	«      Z
dZdZddefd„Zddefd„Zd„ Ze j"                  dd	„«       Zddefd
„Zddefd„Zy)é    N)Úutilz/run/cloud-init/tmpz/var/tmp/cloud-initÚ	needs_exec                 ó”   — | �| S |rt         S t        j                  «       dk(  rt        S t        j                  j                  dd«      S )Nr   ÚTMPDIRz/tmp)Ú_EXE_ROOT_TMPDIRÚosÚgetuidÚ_ROOT_TMPDIRÚenvironÚget)Úodirr   s     ú6/usr/lib/python3/dist-packages/cloudinit/temp_utils.pyÚget_tmp_ancestorr      s?   € ØÐØˆÙÜÐÜ	‡y�yƒ{�aÒÜÐÜ�:‰:�>‰>˜( FÓ+Ð+ó    c                 ó  — t        | |«      }t        j                  j                  |«      s+t        j                  |«       t        j
                  |d«       |r,t        j                  |d«      rt        j                  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ÿ  ÚnoexeczDRequested temporal dir with exe permission `%s` is mounted as noexec)
r   r   ÚpathÚisdirÚmakedirsÚchmodr   Úhas_mount_optÚLOGÚwarning)r   r   Útdirs      r   Ú_tempfile_dir_argr      sh   € ô ˜D )Ó,€DÜ�7‰7�=‰=˜ÔÜ
�‰�DÔÜ
�‰��vÔáÜ×Ñ˜d HÔ-Ü�K‰Kð%àôð
 €Kr   c                  ó„   ‡— t        «       | d<   t        j                  di | ¤ŽŠd„ }|‰_        ˆfd„}t	        ‰d|«       ‰S )NÚdirc                 óš   — 	 t        j                  | «       y # t        $ r)}|j                  t        j                  k7  r|‚Y d }~y d }~ww xY w©N)r   ÚunlinkÚOSErrorÚerrnoÚENOENT)r   Úes     r   Ú_unlink_if_existsz0ExtendedTemporaryFile.<locals>._unlink_if_exists?   s<   € ð	Ü�I‰I�d�OøÜò 	Ø�w‰wœ%Ÿ,™,Ò&Ø�ô 'ûð	ús   ‚ ˜	A
¡AÁA
c                  ó<   •— ‰ j                  ‰ j                  «       y r   )r    Úname)Úfhs   €r   Ú
unlink_nowz)ExtendedTemporaryFile.<locals>.unlink_nowM   s   ø€ Ø
�	‰	�"—'‘'Õr   r)   © )r   ÚtempfileÚNamedTemporaryFiler    Úsetattr)Úkwargsr%   r)   r(   s      @r   ÚExtendedTemporaryFiler/   8   sH   ø€ Ü%Ó'€Fˆ5�MÜ	×	$Ñ	$Ñ	. vÑ	.€Bò
ð "€B„Iôô ˆB�˜jÔ)Ø€Ir   c              +   ó’   K  — t        di |¤Ž}	 |–— t        j                  || ¬«       y # t        j                  || ¬«       w xY w­w)N)Úignore_errorsr*   )ÚmkdtempÚshutilÚrmtree)Úrmtree_ignore_errorsr.   r   s      r   Útempdirr6   T   s>   è ø€ ô
 Ñ�VÑ€Dð@ØŠ
ä�‰�dÐ*>Ö?øŒ�‰�dÐ*>Ö?üs   ‚A�+ “A«AÁAc                 óH   — t        | |«      } t        j                  dd| i|¤ŽS ©Nr   r*   )r   r+   r2   ©r   r   r.   s      r   r2   r2   `   ó'   € Ü
˜C Ó
+€CÜ×ÑÑ. Ð. vÑ.Ð.r   c                 óH   — t        | |«      } t        j                  dd| i|¤ŽS r8   )r   r+   Úmkstempr9   s      r   r<   r<   e   r:   r   )NF)F)Ú
contextlibr"   Úloggingr   r3   r+   Ú	cloudinitr   Ú	getLoggerÚ__name__r   r
   r   Úboolr   r   r/   Úcontextmanagerr6   r2   r<   r*   r   r   ú<module>rD      sŠ   ðó Û Û Û 	Û Û å à€g×Ñ˜Ó!€Ø$€Ø(Ð ñ,¨4ó ,ñ¨Dó ò:ð8 ×Ñò@ó ð@ñ/ ó /ñ
/ ô /r   