CasperSecurity

Current Path : /lib/python3/dist-packages/cloudinit/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/cloudinit/__pycache__/socket.cpython-310.pyc

o

쑛h%�@srdZddlZddlZddlZddlZddlmZddlmZddl	m
Z
e�e�Z
defdd�ZGd	d
�d
�ZdS)z#A module for common socket helpers.�N)�suppress)�performance)�DEFAULT_RUN_DIR�messagecCs�tj�dd�}|sdS|ddkr|�ddd�n
|ddkr#td	��t�tjtjtjB��}t	�
d
t|��|�|�|�
|�d��Wd�dS1sOwYdS)z[Send a sd_notify message.

    :param message: sd-notify message (must be valid ascii)
    �
NOTIFY_SOCKET�Nr�@���/zUnsupported socket typezSending sd_notify(%s)�ascii)�os�environ�get�replace�OSError�socket�AF_UNIX�
SOCK_DGRAM�SOCK_CLOEXEC�LOG�info�str�connect�sendall�encode)r�socket_path�sock�r�2/usr/lib/python3/dist-packages/cloudinit/socket.py�	sd_notifys�
"�r c@s<eZdZdZdefdd�Zdefdd�Zdd	�Zd
d�ZdS)
�
SocketSyncz<A two way synchronization protocol over Unix domain sockets.�namesc	Gs�d|_d|_d|_d|_d|_dd�|D�|_tjt�d�ddd	�|j�	�D]*\}}t�d
|�d�}t
t��
t�|�Wd�n1sGwY|�
|�q'dS)
anInitialize a synchronization context.

        1) Ensure that the socket directory exists.
        2) Bind a socket for each stage.

        Binding the sockets on initialization allows receipt of stage
        "start" notifications prior to the cloud-init stage being ready to
        start.

        :param names: stage names, used as a unique identifiers
        rrFcSs$i|]}|t�tjtjtjB��qSr)rrrr)�.0�namerrr�
<dictcomp>>s���z'SocketSync.__init__.<locals>.<dictcomp>z/sharei�T)�mode�exist_ok�/share/z.sockN)�stage�remote�first_exception�systemd_exit_code�experienced_any_error�socketsr
�makedirsr�itemsr�FileNotFoundError�remove�bind)�selfr"r$rrrrr�__init__-s �
��zSocketSync.__init__r)cCs"||jvrtd|����||_|S)a�Set the stage before entering context.

        This enables the context manager to be initialized separately from
        each stage synchronization.

        :param stage: the name of a stage to synchronize

        Example:
            sync = SocketSync("stage 1", "stage 2"):
            with sync("stage 1"):
                pass
            with sync("stage 2"):
                pass
        zInvalid stage name: )r.�
ValueErrorr))r4r)rrr�__call__Ms
zSocketSync.__call__cCs�t�tj���rt�d�dSd|_td|j	�d��|j
|j	}t�d|j	����|�
d�\}|_Wd�n1s=wYd|krW|�ddd�td	t|��d
���t�d|j	�d�t|j�krt|�ddd�td
|j����td|j	�d��|S)z�Wait until a message has been received on this stage's socket.

        Once the message has been received, enter the context.
        z:Stdin is a tty, so skipping stage synchronization protocolNrzDSTATUS=Waiting on external services to complete before starting the z stage.zWaiting to start stage �sstartzReceived invalid message: [�]r(z-return.sockz Unexpected path to unix socket: zSTATUS=Running (z stage))r
�isatty�sys�stdin�filenorrr,r r)r.r�Timed�recvfromr*�__exit__r6rr)r4r�chunkrrr�	__enter__as2���	��zSocketSync.__enter__cCs�t�tj���r
dSd|j��}|r6d|_d|_t|��d|j	��}d}|j
s*||_
t�|�t
d|���|jp=t|j�|_|j|j}|�|j�|�d|�d	|j�d
����|��dS)z.Notify the socket that this stage is complete.Nz,Completed socket interaction for boot stage r
Tz in zkfatal error, run "systemctl status cloud-init-main.service" and "cloud-init status --long" for more detailszSTATUS=zecho 'z'; exit �;)r
r:r;r<r=r)r,r-�repr�tb_framer+r�fatalr �boolr.rr*rr�close)r4�exc_type�exc_val�exc_tbr�statusrrrrr@�s.�
��zSocketSync.__exit__N)	�__name__�
__module__�__qualname__�__doc__rr5r7rBr@rrrrr!*s 'r!)rP�loggingr
rr;�
contextlibr�	cloudinitr�cloudinit.settingsr�	getLoggerrMrrr r!rrrr�<module>s

Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY