403Webshell
Server IP : 15.235.198.142  /  Your IP : 216.73.216.190
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ballsack 6.8.0-45-generic #45-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 30 12:02:04 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/cloudinit/sources/helpers/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/cloudinit/sources/helpers/__pycache__/netlink.cpython-312.pyc
�

�f�.���ddlZddlZddlZddlZddlZddlmZddlmZeje
�ZdZdZ
dZdZdZdZd	Zd
ZdZdZdZd
ZdZdZej4e�Zej4e�ZeezZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(edgd��Z)edddg�Z*edgd��Z+Gd�de,�Z-d�Z.d�Z/d%d�Z0d�Z1d �Z2d!�Z3d"�Z4d#�Z5d$�Z6y)&�N)�
namedtuple)�util�������i��� �<�IHHII�BHiII����RTAAttr)�length�rta_type�data�InterfaceOperstate�ifname�	operstate�
NetlinkHeader)r�type�flags�seq�pidc��eZdZdZy)�NetlinkCreateSocketErrorz5Raised if netlink socket fails during create or bind.N)�__name__�
__module__�__qualname__�__doc__���C/usr/lib/python3/dist-packages/cloudinit/sources/helpers/netlink.pyr r 9s��?r&r c��	tjtjtjtj�}|j	tj�tf�|jd�tjd�|S#tj$r}d|z}t|�|�d}~wwxYw)auCreates netlink socket and bind on netlink group to catch interface
    down/up events. The socket will bound only on RTMGRP_LINK (which only
    includes RTM_NEWLINK/RTM_DELLINK/RTM_GETLINK events). The socket is set to
    non-blocking mode since we're only receiving messages.

    :returns: netlink socket in non-blocking mode
    :raises: NetlinkCreateSocketError
    rz*Exception during netlink socket create: %sNzCreated netlink socket)
�socket�
AF_NETLINK�SOCK_RAW�
NETLINK_ROUTE�bind�os�getpid�RTMGRP_LINK�setblocking�errorr �LOG�debug)�netlink_socket�e�msgs   r'�create_bound_netlink_socketr8=s���3�������v����0D�0D�
��	���R�Y�Y�[�+�6�7��"�"�1�%��I�I�&�'����	�<�<�3�:�Q�>��&�s�+��2��3�s�A;B�B=�'B8�8B=c���|�Jd��t|�tk\sJd��tjt|dt
�\}}}}}tjd|�t|||||�S)aGets netlink message type and length

    :param: data read from netlink socket
    :returns: netlink message type
    :raises: AssertionError if data is None or data is not >= NLMSGHDR_SIZE
    struct nlmsghdr {
               __u32 nlmsg_len;    /* Length of message including header */
               __u16 nlmsg_type;   /* Type of message content */
               __u16 nlmsg_flags;  /* Additional flags */
               __u32 nlmsg_seq;    /* Sequence number */
               __u32 nlmsg_pid;    /* Sender port ID */
    };
    N�data is nonez+data is smaller than netlink message headerzGot netlink msg of type %d)	�len�
NLMSGHDR_SIZE�struct�unpack�NLMSGHDR_FMT�MSG_TYPE_OFFSETr3r4r)r�msg_len�msg_typerrrs      r'�get_netlink_msg_headerrCSs{����+�^�+���D�	�]�"�5�4�5�"�)/����d�+�O�,�*�&�G�X�u�c�3��I�I�*�H�5���(�E�3��<�<r&c���|�Jd��tj|ggg|�\}}}||vrytjd�|jt�}|�tjd�|S)a�Select and read from the netlink socket if ready.

    :param: netlink_socket: specify which socket object to read from
    :param: timeout: specify a timeout value (integer) to wait while reading,
            if none, it will block indefinitely until socket ready for read
    :returns: string of data read (max length = <MAX_SIZE>) from socket,
              if no data read, returns None
    :raises: AssertionError if netlink_socket is None
    N�netlink socket is noneznetlink socket ready for readz,Reading from Netlink socket returned no data)�selectr3r4�recv�MAX_SIZEr2)r5�timeout�read_set�_rs     r'�read_netlink_socketrLlst���%�?�'?�?�%��]�]�N�#3�R��W�E�N�H�a���X�%���I�I�-�.����x�(�D��|��	�	�@�A��Kr&c�L�|�Jd��t|t�sJd��|tk\sJd��dx}}d}	tjd||��d}tjd||dz��d}||tz||z}t|||�S#tj
$rYywxYw)	a(Unpack a single rta attribute.

    :param: data: string of data read from netlink socket
    :param: offset: starting offset of RTA Attribute
    :return: RTAAttr object with length, type and data. On error, return None.
    :raises: AssertionError if data is None or offset is not integer.
    Nr:zoffset is not integerz'rta offset is less than expected lengthr�H)�offsetr)�
isinstance�int�RTATTR_START_OFFSETr=�unpack_fromr2�RTA_DATA_START_OFFSETr)rrOrr�	attr_datas     r'�unpack_rta_attrrV�s�����+�^�+���f�c�"�;�$;�;�"��%�%�1�0�1�%���F�X��I���#�#�C��f�=�a�@���%�%�c�4���
�C�A�F��
�V�3�3�f�v�o�F�I��6�8�Y�/�/���<�<����s�9B
�
B#�"B#c�`�|�Jd��t|�tkDsJd��dx}}t}|t|�kr�t||�}|r|jdk(rn�t|jtzz
tz}||j|zz
}|j
tk(rt|j�}nD|j
tk(r1tj|jd�}|jd�}|t|�kr��|r|�ytjd||�t||�S)a�Reads Interface name and operational state from RTA Data.

    :param: data: string of data read from netlink socket
    :returns: InterfaceOperstate object containing if_name and oper_state.
              None if data does not contain valid IFLA_OPERSTATE and
              IFLA_IFNAME messages.
    :raises: AssertionError if data is None or length of data is
             smaller than RTATTR_START_OFFSET.
    Nr:z2length of data is smaller than RTATTR_START_OFFSETrzutf-8�z!rta attrs: ifname %s operstate %d)r;rRrVr�
PAD_ALIGNMENTr�IFLA_OPERSTATE�ordr�IFLA_IFNAMEr�
decode_binary�stripr3r4r)rrrrO�attr�padlen�interface_names       r'�read_rta_oper_staterb�s ����+�^�+���D�	�'�'�<�;�<�'���F�Y�
 �F�
�C��I�
��t�V�,���t�{�{�a�'��
�T�[�[�=�8�9����	�$�+�+��&�&���=�=�N�*��D�I�I��I�
�]�]�k�
)�!�/�/��	�	�7�C�N�#�)�)�$�/�F��C��I�
��Y�&���I�I�1�6�9�E��f�i�0�0r&c����tjd�d���fd�}t|dtgtt
g|��S)z�Block until a single nic is attached.

    :param: netlink_socket: netlink_socket to receive events
    :param: existing_nics: List of existing nics so that we can skip them.
    :raises: AssertionError if netlink_socket is none.
    z!Preparing to wait for nic attach.Nc���|�vry|�y)NTFr%)�iname�carrier�prevCarrier�
existing_nicsrs   ��r'�should_continue_cbz5wait_for_nic_attach_event.<locals>.should_continue_cb�s����M�!����r&)r3r4�read_netlink_messages�RTM_NEWLINK�OPER_UP�	OPER_DOWN)r5rhrirs ` @r'�wait_for_nic_attach_eventrn�sC����I�I�1�2�
�F�����	�
�	�)�����Mr&c�r��tjd�d��fd�}t|dtgtg|��S)z�Block until a single nic is detached and its operational state is down.

    :param: netlink_socket: netlink_socket to receive events.
    z!Preparing to wait for nic detach.Nc�
��|�y)NFr%)rerfrgrs   �r'riz5wait_for_nic_detach_event.<locals>.should_continue_cb�s�����r&)r3r4rj�RTM_DELLINKrm)r5rirs  @r'�wait_for_nic_detach_eventrr�s=���
�I�I�1�2�
�F��
���{�m�i�[�:L���Mr&c����|�Jd����Jd��t��dkDsJd���fd�}tjd�t|�tt
gttg|�y)a�Block until media disconnect and connect has happened on an interface.
    Listens on netlink socket to receive netlink events and when the carrier
    changes from 0 to 1, it considers event has happened and
    return from this function

    :param: netlink_socket: netlink_socket to receive events
    :param: ifname: Interface name to lookout for netlink events
    :raises: AssertionError if netlink_socket is None or ifname is None.
    NrEzinterface name is nonerzinterface name cannot be emptyc�`��|tk(xr	|tk(}|rtjd��yy)NzMedia switch happened on %s.FT)rmrlr3r4)rerfrg�isVnetSwitchrs    �r'riz=wait_for_media_disconnect_connect.<locals>.should_continue_cbs/���#�y�0�J�w�'�7I����I�I�4�f�=��r&z1Wait for media disconnect and reconnect to happen)r;r3r4rjrkrqrlrm)r5rris ` r'�!wait_for_media_disconnect_connectrv�st����%�?�'?�?�%���7�7�7���v�;��?�<�<�<�?���I�I�A�B����	�k�"�	�)���r&c��|�td��t�}t}t}	t|t�}|��t
j
dt|��||z
}t
j
dt|��d}	t|�}
|	|
k�rD||	d}t|�tkrt
j
d��nt|�}t|�|jkrt
j
d�n�|jtzdz
tdz
z}
|	|
z}	t
j
d	|	�|j|vr��t|�}|�t
j
d
|���|�2|j|k7r#t
j
d|j|���|j|vr�� |}|j}||j||�sy|	|
kr��D||	d}���)a�Reads from the netlink socket until the condition specified by
    the continuation callback is met.

    :param: netlink_socket: netlink_socket to receive events.
    :param: ifname_filter: if not None, will only listen for this interface.
    :param: rtm_types: Type of netlink events to listen for.
    :param: operstates: Operational states to listen.
    :param: should_continue_callback: Specifies when to stop listening.
    NzNetlink socket is nonezread %d bytes from socketzLength of data after concat %drz#Data is smaller than netlink headerz*Partial data. Smaller than netlink messagerz"offset to next netlink message: %dz!Failed to read rta attributes: %sz6Ignored netlink event on interface %s. Waiting for %s.)�RuntimeError�bytesrlrL�SELECT_TIMEOUTr3r4r;r<rCrrYrrbrr)r5�
ifname_filter�	rtm_types�
operstates�should_continue_callbackrrfrg�	recv_datarO�datalen�nl_msg�nlheaderr`�interface_states               r'rjrjs��� ���3�4�4��7�D��G��K�
�'���G�	�����	�	�-�s�9�~�>��	����	�	�2�C��I�>����d�)���w���&�'�]�F��6�{�]�*��	�	�?�@��-�f�5�H��6�{�X�_�_�,��	�	�F�G���o�o�
�5��9���!�>��F��f�_�F��I�I�:�F�C��}�}�I�-��1�&�9�O��&��	�	�=��O���)�#�*�*�m�;��	�	�L�#�*�*�!��
��(�(�
�:��!�K�%�/�/�G�+��&�&�����M�w��N�F�G�}��ar&)N)7�loggingr.rFr)r=�collectionsr�	cloudinitr�	getLoggerr!r3r0�
NLMSG_NOOP�NLMSG_ERROR�
NLMSG_DONErkrq�RTM_GETLINK�RTM_SETLINKrH�RTA_DATA_OFFSETr@rzr?�
IFINFOMSG_FMT�calcsizer<�IFINFOMSG_SIZErRrTrYr\rZ�OPER_UNKNOWN�OPER_NOTPRESENTrm�OPER_LOWERLAYERDOWN�OPER_TESTING�OPER_DORMANTrlrrrrxr r8rCrLrVrbrnrrrvrjr%r&r'�<module>r�sJ��
�	�
�
�
�"���g����!����
�
���
�
��������������������
������-�
� �����/��#�n�4�����
���������
�	�������
��
�Y� >�
?��� 4�x��6M�N����>��
�
@�|�@��,=�2�.0�4"1�J�:�&�@Er&

Youez - 2016 - github.com/yon3zu
LinuXploit