![]() Server : Apache/2.4.62 (Unix) OpenSSL/1.0.2k-fips System : Linux server1.richineiserver.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : fdshops ( 1003) PHP Version : 8.2.21 Disable Function : NONE Directory : /lib/python2.7/site-packages/certbot/_internal/ |
� ���_c @ s d Z d d l Z d d l Z d d l m Z d d l m Z d d l m Z d d l m Z y d d l Z Wn# e k r� d d l Z e Z n Xe Z e j e � Z d � Z d e f d � � YZ d e f d � � YZ d e f d � � YZ d e f d � � YZ d S( sZ Implements file locks compatible with Linux and Windows for locking files and directories.i����N( t Optional( t errors( t filesystem( t osc C s t t j j | d � � S( s3 Place a lock file on the directory at dir_path. The lock file is placed in the root of dir_path with the name .certbot.lock. :param str dir_path: path to directory :returns: the locked LockFile object :rtype: LockFile :raises errors.LockError: if unable to acquire the lock s .certbot.lock( t LockFileR t patht join( t dir_path( ( s: /usr/lib/python2.7/site-packages/certbot/_internal/lock.pyt lock_dir s R c B s; e Z d Z d � Z d � Z d � Z d � Z d � Z RS( s� Platform independent file lock system. LockFile accepts a parameter, the path to a file acting as a lock. Once the LockFile, instance is created, the associated file is 'locked from the point of view of the OS, meaning that if another instance of Certbot try at the same time to acquire the same lock, it will raise an Exception. Calling release method will release the lock, and make it available to every other instance. Upon exit, Certbot will also release all the locks. This allows us to protect a file or directory from being concurrently accessed or modified by two Certbot instances. LockFile is platform independent: it will proceed to the appropriate OS lock mechanism depending on Linux or Windows. c C s8 | | _ t r t n t } | | � | _ | j � d S( s� Create a LockFile instance on the given file path, and acquire lock. :param str path: the path to the file that will hold a lock N( t _patht POSIX_MODEt _UnixLockMechanismt _WindowsLockMechanismt _lock_mechanismt acquire( t selfR t mechanism( ( s: /usr/lib/python2.7/site-packages/certbot/_internal/lock.pyt __init__7 s c C sB d j | j j | j � } | j � r4 | d 7} n | d 7} | S( Ns {0}({1}) <s acquired>s released>( t formatt __class__t __name__R t is_locked( R t repr_str( ( s: /usr/lib/python2.7/site-packages/certbot/_internal/lock.pyt __repr__C s c C s | j j � d S( s� Acquire the lock on the file, forbidding any other Certbot instance to acquire it. :raises errors.LockError: if unable to acquire the lock N( R R ( R ( ( s: /usr/lib/python2.7/site-packages/certbot/_internal/lock.pyR L s c C s | j j � d S( sb Release the lock on the file, allowing any other Certbot instance to acquire it. N( R t release( R ( ( s: /usr/lib/python2.7/site-packages/certbot/_internal/lock.pyR T s c C s | j j � S( su Check if the file is currently locked. :return: True if the file is locked, False otherwise ( R R ( R ( ( s: /usr/lib/python2.7/site-packages/certbot/_internal/lock.pyR [ s ( R t __module__t __doc__R R R R R ( ( ( s: /usr/lib/python2.7/site-packages/certbot/_internal/lock.pyR ) s t _BaseLockMechanismc B s, e Z d � Z d � Z d � Z d � Z RS( c C s | | _ d | _ d S( sk Create a lock file mechanism for Unix. :param str path: the path to the lock file N( R t Nonet _fd( R R ( ( s: /usr/lib/python2.7/site-packages/certbot/_internal/lock.pyR e s c C s | j d k S( sv Check if lock file is currently locked. :return: True if the lock file is locked :rtype: bool N( R R ( R ( ( s: /usr/lib/python2.7/site-packages/certbot/_internal/lock.pyR n s c C s d S( N( ( R ( ( s: /usr/lib/python2.7/site-packages/certbot/_internal/lock.pyR v s c C s d S( N( ( R ( ( s: /usr/lib/python2.7/site-packages/certbot/_internal/lock.pyR y s ( R R R R R R ( ( ( s: /usr/lib/python2.7/site-packages/certbot/_internal/lock.pyR d s R c B s2 e Z d Z d � Z d � Z d � Z d � Z RS( s� A UNIX lock file mechanism. This lock file is released when the locked file is closed or the process exits. It cannot be used to provide synchronization between threads. It is based on the lock_file package by Martin Horcicka. c C s� x� | j d k r� t j | j t j t j Bd � } z, | j | � | j | � r_ | | _ n Wd | j d k r� t j | � n Xq Wd S( s Acquire the lock.i� N( R R R t openR R t O_CREATt O_WRONLYt _try_lockt _lock_successt close( R t fd( ( s: /usr/lib/python2.7/site-packages/certbot/_internal/lock.pyR � s " c C s{ y t j | t j t j B� WnV t k rv } | j t j t j f k rp t j d | j � t j d � � n � n Xd S( s� Try to acquire the lock file without blocking. :param int fd: file descriptor of the opened file to lock s( A lock on %s is held by another process.s/ Another instance of Certbot is already running.N( t fcntlt lockft LOCK_EXt LOCK_NBt IOErrort errnot EACCESt EAGAINt loggert debugR R t LockError( R R$ t err( ( s: /usr/lib/python2.7/site-packages/certbot/_internal/lock.pyR! � s c C s� d d l m } m } y | | j � } Wn, t k rW } | j t j k rQ t S� n X| | � } | j | j k o� | j | j k S( s� Did we successfully grab the lock? Because this class deletes the locked file when the lock is released, it is possible another process removed and recreated the file between us opening the file and acquiring the lock. :param int fd: file descriptor of the opened file to lock :returns: True if the lock was successfully acquired :rtype: bool i����( t statt fstat( R R1 R2 R t OSErrorR* t ENOENTt Falset st_devt st_ino( R R$ R1 R2 t stat1R0 t stat2( ( s: /usr/lib/python2.7/site-packages/certbot/_internal/lock.pyR"