3 \me @ s d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ eje Z dadZdZ dedddZdedd d Zdd Ze jdd dZdedddZdedddZdS ) N)utilz/run/cloud-init/tmpz/var/tmp/cloud-initF) needs_exec C s: | d k r| S |rt S trtS tj dkr,tS tjjddS )Nr ZTMPDIRz/tmp)_EXE_ROOT_TMPDIR_TMPDIRosgetuid_ROOT_TMPDIRenvironget)odirr r /usr/lib/python3.6/temp_utils.pyget_tmp_ancestor s r c C s^ t | |}tjj|s,tj| tj|d |rHtj|drHtj d| | dkrZ| rZ|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)r r pathisdirmakedirschmodr Z has_mount_optLOGZwarningr )r r tdirr r r _tempfile_dir_arg s r c sT t | jdd | jdd| d<