HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //proc/thread-self/root/var/opt/nydus/ops/mysql/connector/aio/__pycache__/protocol.cpython-39.pyc
a

�,�h51�@s�dZdgZddlZddlmZmZmZmZmZddl	m
Z
mZddlm
Z
mZmZddlmZdd	lmZmZmZdd
lmZmZmZmZddlmZmZdd
lmZddl m!Z!m"Z"ddl#m$Z$Gdd�de�ZdS)z,Implements the MySQL Client/Server protocol.�
MySQLProtocol�N)�Any�Dict�List�Optional�Tuple�)�
ClientFlag�	ServerCmd)�InterfaceError�ProgrammingError�
get_exception)�logger)�DEFAULT_CHARSET_ID�DEFAULT_MAX_ALLOWED_PACKETr)�BinaryProtocolType�DescriptionType�
EofPacketType�
HandShakeType)�	int1store�read_lc_string_list�)�MySQLSocket)�MySQLAuthPlugin�get_auth_plugin)�"MySQLCachingSHA2PasswordAuthPluginc@s(eZdZdZedeeeeeeee	ee
eefeee
fd�	dd��Zedededdddddf
eeeeeeeeeeeeee
eefe	e	ee
eefeee
fd�d	d
��Zdeeeeeeeeed
feefd�dd�Zdeeed
feeeeeed
feefd�dd�ZdS)rzSImplements MySQL client/server protocol.

    Create and parses MySQL packets.
    NF)	�	auth_data�username�password�client_flags�auth_plugin�auth_plugin_class�ssl_enabled�
plugin_config�returnc
Cs�|sdt|||d�fS|dur"i}z*t||�|||d�}|j|fi|��}	Wn8ttfy�}
ztd|
���|
�WYd}
~
n
d}
~
00|	dur�td|j����|tj@r�tt	|	��|	n|	d}	|	|fS)aPrepare the first authentication response.

        Args:
            auth_data: Authorization data from initial handshake.
            username: Account's username.
            password: Account's password.
            client_flags: Integer representing client capabilities flags.
            auth_plugin: Authorization plugin name.
            auth_plugin_class: Authorization plugin class (has higher precedence
                               than the authorization plugin name).
            ssl_enabled: Whether SSL is enabled or not.
            plugin_config: Custom configuration to be passed to the auth plugin
                           when invoked. The parameters defined here will override
                           the ones defined in the auth plugin itself.

        Returns:
            auth_response: Authorization plugin response.
            auth_strategy: Authorization plugin instance created based
                           on the provided `auth_plugin` and `auth_plugin_class`
                           parameters.

        Raises:
            InterfaceError: If authentication fails or when got a NULL auth response.
        �)r"NzFailed authentication: z8Got NULL auth response while authenticating with plugin )
rr�
auth_response�	TypeErrorr�namer	ZSECURE_CONNECTIONr�len)rrrrr r!r"r#�
auth_strategyr&�err�r,�O/opt/nydus/tmp/pip-target-wkfpz8uv/lib64/python/mysql/connector/aio/protocol.py�auth_plugin_first_response:s0#��&����z(MySQLProtocol.auth_plugin_first_responser)�	handshakerr�database�charsetr�max_allowed_packetr r!�
conn_attrs�is_change_user_requestr"r#r$c

Cs�|��}
g}|
rt�d�t�d�|dur6td�d�|�d�durNtd�d�z|pZ|d}Wn:ttfy�}ztd|�d	��d�WYd}~n
d}~00t�d
|�|
r�|�t�	dt
|
��d�tj|
��n,d
}|�t�	d|�t
|
��d�||||
��t
j|d|||||||d�\}}|�|�|�t
�||��|
�rP|�t�	d|��|tj@�rn|�|��d�|tj@�r�|	du�r�|�t
�|	��d�|�|fS)a�Make a MySQL Authentication packet.

        Args:
            handshake: Initial handshake.
            username: Account's username.
            password: Account's password.
            database: Initial database name for the connection
            charset: Client charset (see [2]), only the lower 8-bits.
            client_flags: Integer representing client capabilities flags.
            max_allowed_packet: Maximum packet size.
            auth_plugin: Authorization plugin name.
            auth_plugin_class: Authorization plugin class (has higher precedence
                               than the authorization plugin name).
            conn_attrs: Connection attributes.
            is_change_user_request: Whether is a `change user request` operation or not.
            ssl_enabled: Whether SSL is enabled or not.
            plugin_config: Custom configuration to be passed to the auth plugin
                           when invoked. The parameters defined here will override
                           the one defined in the auth plugin itself.

        Returns:
            handshake_response: Handshake response as per [1].
            auth_strategy: Authorization plugin instance created based
                           on the provided `auth_plugin` and `auth_plugin_class`.

        Raises:
            ProgrammingError: Handshake misses authentication info.

        References:
            [1]: https://dev.mysql.com/doc/dev/mysql-server/latest/                page_protocol_connection_phase_packets_protocol_handshake_response.html

            [2]: https://dev.mysql.com/doc/dev/mysql-server/latest/                page_protocol_basic_character_set.html#a_protocol_character_set
        zGot a `change user` requestzStarting authorization phaseNzGot a NULL handshakerz$Handshake misses authentication infor z-Handshake misses authentication plugin info (�)z#The provided initial strategy is %sz<BZsxZxxxxxxxxxxxxxxxxxxxxxxz<IIH)rrrrr r!r"r#z<Hr%�)�encoder�debugr�getr'�KeyError�append�struct�packr)r
ZCHANGE_USERrr.Zconnect_with_dbr	ZPLUGIN_AUTHZCONNECT_ARGSZmake_conn_attrs�join)r/rrr0r1rr2r r!r3r4r"r#Z
b_usernameZresponse_payloadr+�fillerr&r*r,r,r-�	make_auth|sn3




�������


zMySQLProtocol.make_authr�utf-8.)�sock�columns�countr1r$c
�s�g}d}d}d}|s�||krq�|��IdH}	|	ddkrH|�|	�}d}n&|	ddkrnd}|�||	dd�|�}|dur�|dur�|�|�n|dur�|dur�t|	��|d7}q||fS)zxRead MySQL binary protocol result.

        Reads all or given number of binary resultset rows from the socket.
        Nr���r)�read�	parse_eofZ_parse_binary_valuesr;r
)
�selfrBrCrDr1�rows�eof�values�i�packetr,r,r-�read_binary_result�s&

z MySQLProtocol.read_binary_result)rB�versionrDr$c�s4|}g}d}d}d}|s ||kr$�q,|��IdH}	|	�d�r�|	dd�g}
|��IdH}	|	�d�r�|
�|	dd��|��IdH}	qX|
�|	dd��td�|
��}n@|	ddkr�|	ddkr�|�|	�}d}nd}tt|	dd���}|du�r|du�r|�|�n|du�r"|du�r"t|	��|d7}q||fS)	z�Read MySQL text result.

        Reads all or given number of rows from the socket.

        Returns a tuple with 2 elements: a list with all rows and
        the EOF packet.
        Nrs���rEr6rF�r)rH�
startswithr;rr>rI�bytesr
)rJrBrQrD�_rKrLZrowdatarNrOZdatasr,r,r-�read_text_results6



zMySQLProtocol.read_text_result)NFN)rrA)r)�__name__�
__module__�__qualname__�__doc__�staticmethodrT�str�intr�boolrrrrr.rrrr@rrrrrrPrVr,r,r,r-r4s��
�A�
�����%����)%rZ�__all__r<�typingrrrrr�	constantsr	r
�errorsrrr
r�protocolrrrZ_MySQLProtocol�typesrrrr�utilsrr�networkrZpluginsrrZplugins.caching_sha2_passwordrr,r,r,r-�<module>s