관리-도구
편집 파일: temp_utils.cpython-39.pyc
a ����'�Dg�����������������������@���s����d�dl�Z�d�dlZd�dlZd�dlZd�dlZd�dlZd�dlmZ�e�e �Z dZdZde d�dd�Zde d�d d �Zdd��Ze�jdd d��Zde d�dd�Zde d�dd�ZdS�)�����N)�utilz/run/cloud-init/tmpz/var/tmp/cloud-initF)� needs_exec�����������������C���s2���|�d�ur|�S�|rt�S�t���dkr$tS�tj�dd�S�)Nr���ZTMPDIRz/tmp)�_EXE_ROOT_TMPDIR�os�getuid�_ROOT_TMPDIR�environ�get)�odirr�����r����8/usr/lib/python3.9/site-packages/cloudinit/temp_utils.py�get_tmp_ancestor���s����r ���c�����������������C���sL���t�|�|�}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�chmodr���Z has_mount_opt�LOGZwarning)r ���r����tdirr���r���r����_tempfile_dir_arg���s���� �r���c���������������������sD���t���|�d<�tjf�i�|�����dd��}|��_��fdd�}t��d|����S�)N�dirc�������������� ���S���sH���zt��|���W�n4�tyB�}�z|jtjkr.|�W�Y�d�}~n d�}~0�0�d�S��N)r����unlink�OSError�errno�ENOENT)r����er���r���r����_unlink_if_exists?���s ����z0ExtendedTemporaryFile.<locals>._unlink_if_existsc����������������������s���������j��d�S�r���)r����namer����Zfhr���r���� unlink_nowM���s����z)ExtendedTemporaryFile.<locals>.unlink_nowr���)r����tempfileZNamedTemporaryFiler����setattr)�kwargsr���r���r���r���r����ExtendedTemporaryFile8���s���� r#���c�������������� ���k���s<���t�f�i�|��}z|V��W�tj||�d��ntj||�d��0�d�S�)N)� ignore_errors)�mkdtemp�shutil�rmtree)Zrmtree_ignore_errorsr"���r���r���r���r����tempdirT���s����r(���c�����������������K���s���t�|�|�}�tjf�d|�i|��S��Nr���)r���r ���r%����r���r���r"���r���r���r���r%���`���s���� r%���c�����������������K���s���t�|�|�}�tjf�d|�i|��S�r)���)r���r ����mkstempr*���r���r���r���r+���e���s���� r+���)NF)NF)F)NF)NF)� contextlibr���Zloggingr���r&���r ���Z cloudinitr���Z getLogger�__name__r���r���r����boolr ���r���r#����contextmanagerr(���r%���r+���r���r���r���r����<module>���s ���