HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-10-0-8-47 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:31:58 UTC 2024 aarch64
User: ubuntu (1000)
PHP: 8.1.2-1ubuntu2.22
Disabled: NONE
Upload Files
File: //proc/self/root/lib/python3/dist-packages/cloudinit/__pycache__/temp_utils.cpython-310.pyc
o

�Ad��@s�ddlZddlZddlZddlZddlZddlmZddlmZe�	e
�ZdadZ
dZddefdd	�Zddefd
d�Zdd
�Zejddd��Zddefdd�Zddefdd�ZdS)�N)�log)�utilz/run/cloud-init/tmpz/var/tmp/cloud-initF�	needs_execCs:|dur|S|r
tStrtSt��dkrtStj�dd�S)Nr�TMPDIRz/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�|�st�|�t�|d�|r$t�|d�r$t�	d|�|dur,|s,|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��noexeczDRequested temporal dir with exe permission `%s` is mounted as noexecN)rr�path�isdir�makedirs�chmodr�
has_mount_opt�LOG�warningr)r
r�tdirrrr�_tempfile_dir_args

�rcsXt|�dd�|�dd��|d<tjd	i|���dd�}|�_�fdd�}t�d|��S)
N�dirrFc
SsHzt�|�WdSty#}z|jtjkr|�WYd}~dSd}~ww�N)r�unlink�OSError�errno�ENOENT)r�errr�_unlink_if_existsIs���z0ExtendedTemporaryFile.<locals>._unlink_if_existscs���j�dSr)r�namer��fhrr�
unlink_nowWsz)ExtendedTemporaryFile.<locals>.unlink_nowr&r)r�pop�tempfile�NamedTemporaryFiler�setattr)�kwargsr"r&rr$r�ExtendedTemporaryFile@s�r,c
ks<�tdi|��}z
|VWtj||d�dStj||d�w)N)�
ignore_errorsr)�mkdtemp�shutil�rmtree)�rmtree_ignore_errorsr+rrrr�tempdir^s
�"r2cK�t||�}tjdd|i|��S�Nrr)rr(r.�rrr+rrrr.j�
r.cKr3r4)rr(�mkstempr5rrrr7or6r7)NF)F)�
contextlibrrr/r(�	cloudinitr�loggingr�	getLogger�__name__rrr
r�boolrrr,�contextmanagerr2r.r7rrrr�<module>s$
"