
    *h(1                         S r S/rSSKrSSKJrJrJrJrJr  SSK	J
r
Jr  SSKJrJrJr  SSKJr  SS	KJrJrJr  SS
KJrJrJrJr  SSKJrJr  SSKJr  SSK J!r!J"r"  SSK#J$r$   " S S\5      rg)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)lc_intread_lc_string_list   )MySQLSocket)MySQLAuthPluginget_auth_plugin)"MySQLCachingSHA2PasswordAuthPluginc                       \ rS rSrSr\   S S\S\S\S\S	\\   S
\	S\\
\\4      S\\\4   4S jj5       r\S\S\SSSSSS4
S\S\S\S\\   S\S\S\S\\   S	\\   S\\
\\4      S\	S
\	S\\
\\4      S\\\4   4S jj5       r   S!S\S\\   S\S\S\\   S\\\\S4      \\   4   4S jjr  S"S\S\\S4   S\S\\   S\\\\\   S4      \\   4   4
S jjrSrg)#r   4   zKImplements MySQL client/server protocol.

Create and parses MySQL packets.
NF	auth_datausernamepasswordauth_pluginauth_plugin_classssl_enabledplugin_configreturnc                 >   U(       d  US:X  a  S[        XUS94$ Uc  0 n [        X45      " XUS9nUR                  " U 40 UD6nUc  [	        SUR
                   35      e[        [        U5      5      U-   nX4$ ! [        [        4 a  n	[	        SU	 35      U	eSn	A	ff = f)a  Prepare 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$   NzFailed authentication: z8Got NULL auth response while authenticating with plugin )r   r   auth_response	TypeErrorr   namer   len)
r   r    r!   r"   r#   r$   r%   auth_strategyr*   errs
             T/var/www/auris/envauris/lib/python3.13/site-packages/mysql/connector/aio/protocol.pyauth_plugin_first_response(MySQLProtocol.auth_plugin_first_response:   s    D K2->    M	K+KKM *77	S]SM   ',,-/ 
 s=12]B++ >* 	K #:3%!@AsJ	Ks   #A8 8BBBr   	handshakedatabasecharsetclient_flagsmax_allowed_packet
conn_attrsis_change_user_requestc           
         UR                  5       n/ nU
(       a  [        R                  " S5        [        R                  " S5        U c  [        S5      SeU R	                  S5      c  [        S5      Se U=(       d    U S   n[        R                  " S
U5        U
(       aC  UR                  [        R                  " S[        U5       S3[        R                  U5      5        O:SnUR                  [        R                  " SU [        U5       S3UUUU5      5        [        R                  U S   UUUUUUS9u  nnUR                  U5        UR                  [        R                  XS5      5        U
(       a&  UR                  [        R                  " SU5      5        U[         R"                  -  (       a"  UR                  UR                  5       S-   5        U[         R$                  -  (       a'  U	b$  UR                  [        R'                  U	5      5        SR)                  U5      U4$ ! [
        [        4 a  n[        SU S	35      SeSnAff = f)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
zGot a `change user` requestzStarting authorization phaseNzGot a NULL handshaker   z$Handshake misses authentication infor"   z-Handshake misses authentication plugin info ()z#The provided initial strategy is %sz<Bsxxxxxxxxxxxxxxxxxxxxxxxxz<IIB)r   r    r!   r"   r#   r$   r%   z<Hr)       )encoder   debugr   getr+   KeyErrorappendstructpackr-   r   CHANGE_USERr   r1   connect_with_dbr
   PLUGIN_AUTHCONNECT_ARGSmake_conn_attrsjoin)r3   r    r!   r4   r5   r6   r7   r"   r#   r8   r9   r$   r%   
b_usernameresponse_payloadr/   fillerr*   r.   s                      r0   	make_authMySQLProtocol.make_authw   s*   f __&
!LL6734"#9:D==%-"#IJPTT	%A=)AK 	:KH!##Z),)) F##6(3z?"326 & (5'O'O,#/#' (P (
$} 	. 	 = =l UV "##FKKg$>? *000##K$6$6$87$BC :222
8N##M$A$A*$MNxx()=88m 8$ 	"?uAF	s   4H* *I:I

Isockcolumnscountread_timeout.c                 L  #    / nSnSnSn	 U(       d  X:X  a   Xg4$ UR                  U5      I Sh  vN n
U
S   S:X  a  U R                  U
5      nSnO U
S   S:X  a  SnU R                  X*SS U5      nUc  Ub  UR                  U5        OUc  Uc  [	        U
5      eU	S-  n	M   Nq7f)zhRead MySQL binary protocol result.

Reads all or given number of binary resultset rows from the socket.
Nr            r   )read	parse_eof_parse_binary_valuesrC   r   )selfrQ   rR   rS   r5   rT   rowseofvaluesipackets              r0   read_binary_result MySQLProtocol.read_binary_result   s      aj {  99\22FayCnnV,a22712JP{v1F##F++FA  3s   .B$B"A2B$versionc                   #    Un/ nSnSnSn	 U(       d  X:X  a   Xg4$ UR                  U5      I Sh  vN n
U
R                  S5      (       a  U
SS /nUR                  U5      I Sh  vN n
U
R                  S5      (       aE  UR                  U
SS 5        UR                  U5      I Sh  vN n
U
R                  S5      (       a  ME  UR                  U
SS 5        [        SR	                  U5      5      nO?U
S   S:X  a  U
S   S:  a  U R                  U
5      nSnOSn[        [        U
SS 5      5      nUc  Ub  UR                  U5        OUc  Uc  [        U
5      eU	S-  n	GMX   GN4 GN N7f)	zRead 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.
Nr   s   rV   r>   rW      r   )rY   
startswithrC   r   rK   rZ   bytesr   )r\   rQ   rd   rS   rT   _r]   r^   rowdatar`   ra   datass               r0   read_text_resultMySQLProtocol.read_text_result  sp    $ aj* y)  99\22F  11#yy66''88LL,#'99\#::F ''88 VABZ(-chhuo>c!fQi!mnnV,-eF12J.?@{w2G$#F++FA-  3 7 ;s;   0E.E&4E.'E)(AE.*E,+E.B E.)E.,E. )NFN)r   zutf-8N)r   N)__name__
__module____qualname____firstlineno____doc__staticmethodrh   strr   boolr   r   r   r   r1   r   r   r   intrO   r   r   r   r   r   rb   rl   __static_attributes__rn   r>   r0   r   r   4   sz   
  ,0!26:,:,:, :, 	:,
 $C=:, :,  S#X/:, 
uo%	&:, :,x 
 #')"<%)+//3',!26w9 w9w9 w9 3-	w9
 w9 w9  w9 c]w9 $C=w9 T#s(^,w9 !%w9 w9  S#X/w9 
uo%	&w9 w9| &*"" o&" 	"
 " sm" 
U%s*+,	!
"R &*.. sCx. 	.
 sm. 
U8E?C'()	!
. .r>   )%rs   __all__rD   typingr   r   r   r   r   	constantsr
   r   errorsr   r   r   r   protocolr   r   r   _MySQLProtocoltypesr   r   r   r   utilsr   r   networkr   pluginsr   r   plugins.caching_sha2_passwordr   rn   r>   r0   <module>r      sT   : 3
  3 3 - D D  
 V U /   5 MQN Qr>   