%PDF- %PDF-
Direktori : /lib/python3/dist-packages/duplicity/__pycache__/ |
Current File : //lib/python3/dist-packages/duplicity/__pycache__/tempdir.cpython-312.pyc |
� �2e�) � � � d Z ddlZddlZddlZddlZddlZddlmZ ddlmZ ddlm Z ej � ada ej � ad� Z G d� de� Zy) z� Provides temporary file handling cenetered around a single top-level securely created temporary directory. The public interface of this module is thread-safe. � N)�config)�log)�utilc �4 � t j � t �t j � �7t t j �� at j � t _ t t j � S # t j � w xY w)am Obtain the global default instance of TemporaryDirectory, creating it first if necessary. Failures are propagated to caller. Most callers are expected to use this function rather than instantiating TemporaryDirectory directly, unless they explicitly desdire to have their "own" directory for some reason. This function is thread-safe. )�temproot) �_defaultLock�acquire�_defaultInstance�dir�TemporaryDirectoryr r �tempfile�tempdir�release� � �3/usr/lib/python3/dist-packages/duplicity/tempdir.py�defaultr 0 sf � � ������#�'7�';�';�'=�'E�1�6�?�?�K��/�3�3�5�H������������s �AB �Bc �B � e Zd ZdZdd�Zd� Zd� Zd� Zd� Zd� Z d � Z d � Zy)r a5 A temporary directory. An instance of this class is backed by a directory in the file system created securely by the use of tempfile.mkdtemp(). Said instance can be used to obtain unique filenames inside of this directory for cases where mktemp()-like semantics is desired, or (recommended) an fd,filename pair for mkstemp()-like semantics. See further below for the security implications of using it. Each instance will keep a list of all files ever created by it, to faciliate deletion of such files and rmdir() of the directory itself. It does this in order to be able to clean out the directory without resorting to a recursive delete (ala rm -rf), which would be risky. Calling code can optionally (recommended) notify an instance of the fact that a tempfile was deleted, and thus need not be kept track of anymore. This class serves two primary purposes: Firstly, it provides a convenient single top-level directory in which all the clutter ends up, rather than cluttering up the root of the system temp directory itself with many files. Secondly, it provides a way to get mktemp() style semantics for temporary file creation, with most of the risks gone. Specifically, since the directory itself is created securely, files in this directory can be (mostly) safely created non-atomically without the usual mktemp() security implications. However, in the presence of tmpwatch, tmpreaper, or similar mechanisms that will cause files in the system tempdir to expire, a security risk is still present because the removal of the TemporaryDirectory managed directory removes all protection it offers. For this reason, use of mkstemp() is greatly preferred above use of mktemp(). In addition, since cleanup is in the form of deletion based on a list of filenames, completely independently of whether someone else already deleted the file, there exists a race here as well. The impact should however be limited to the removal of an 'attackers' file. Nc �X � d� }|�'t j rt j }nt }t |dj � rt j |� }t j � j d� rB ||� r:t j ddg� }t j |� j � }t j dd|� | _ t! j"