shell bypass 403

Cubjrnet7 Shell


name : socket.cpython-39.pyc
a

'�Dg��@srdZddlZddlZddlZddlZddlmZddlmZddl	m
Z
e�e�Z
ed�dd�ZGd	d
�d
�ZdS)z#A module for common socket helpers.�N)�suppress)�performance)�DEFAULT_RUN_DIR)�messagecCs�tj�dd�}|sdS|ddkr2|�ddd�n|ddkrFtd	��t�tjtjtjB��:}t	�
d
t|��|�|�|�
|�d��Wd�n1s�0YdS)z[Send a sd_notify message.

    :param message: sd-notify message (must be valid ascii)
    Z
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�4/usr/lib/python3.9/site-packages/cloudinit/socket.py�	sd_notifys�
rc@s<eZdZdZed�dd�Zed�dd�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\}}t�d
|�d�}t
t��t�|�Wd�n1s�0Y|�
|�qNd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�removeZbind)�selfr!r#rrrrr�__init__-s�
(zSocketSync.__init__)r(cCs"||jvrtd|����||_|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()r2r(rrr�__call__Ms
zSocketSync.__call__cCst�tj���rt�d�dSd|_td|j	�d��|j
|j	}t�d|j	���� |�
d�\}|_Wd�n1sz0Yd|kr�|�ddd�td	t|��d
���n:t�d|j	�d�t|j�kr�|�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+rr(r-rZTimedZrecvfromr)�__exit__r4rr)r2r�chunkrrr�	__enter__as0���	.�zSocketSync.__enter__cCs�d|j��}|rXd|_d|_t|��d|j��}d}|js@||_t�|�td|���|jpft	|j�|_|j
|j}|�|j�|�
d|�d|j�d	����|��dS)
z.Notify the socket that this stage is complete.z,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,�repr�tb_framer*rZfatalr�boolr-rr)rr�close)r2�exc_typeZexc_valZexc_tbr�statusrrrrr<�s*�
��zSocketSync.__exit__N)	�__name__�
__module__�__qualname__�__doc__rr3r5r>r<rrrrr *s
 'r )rIZloggingrrr9�
contextlibrZ	cloudinitrZcloudinit.settingsrZ	getLoggerrFrrrr rrrr�<module>s


© 2025 Cubjrnet7