oB]c@sddlZddlZddlZddlZddlZdadZdZde dZ dZ ej e dZ dZdZdS( iNs/run/cloud-init/tmps/var/tmp/cloud-initcCs|dk r|S|rRt}tjj|sNtj|tj|dn|Str\tStjdkrwt }ntj j dd}tjj|stj|tj|dn|a|S(s%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. iitTMPDIRs/tmpN( tNonet_EXE_ROOT_TMPDIRtostpathtisdirtmakedirstchmodt_TMPDIRtgetuidt _ROOT_TMPDIRtenvirontget(todirt needs_exettdir((s8/usr/lib/python2.7/site-packages/cloudinit/temp_utils.pyt_tempfile_dir_args$    c sot|jdd|jdt|ds csjjdS(N(Rtname((tfh(s8/usr/lib/python2.7/site-packages/cloudinit/temp_utils.pyt unlink_nowLsR(RtpopRtFalsettempfiletNamedTemporaryFileRtsetattr(tkwargsRR((Rs8/usr/lib/python2.7/site-packages/cloudinit/temp_utils.pytExtendedTemporaryFile6s(  cks0t|}z |VWdtj|d|XdS(Nt ignore_errors(tmkdtemptshutiltrmtree(trmtree_ignore_errorsR R((s8/usr/lib/python2.7/site-packages/cloudinit/temp_utils.pyttempdirSs  cKs8t|jdd|jdt|ds     (