⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.166
Server IP:
97.74.87.16
Server:
Linux 16.87.74.97.host.secureserver.net 5.14.0-503.38.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 18 08:52:10 EDT 2025 x86_64
Server Software:
Apache
PHP Version:
8.2.28
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
var
/
opt
/
nydus
/
ops
/
mysql
/
connector
/
__pycache__
/
View File Name :
connection.cpython-39.pyc
a ��Rht� � @ s d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl Z ddl mZ ddlm Z ddlmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZ dd lmZ dd lm Z m!Z! ddl"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z( ddl)m*Z* dd l+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8 ddl9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZA ddlBmBZB ddlCmDZDmEZEmFZF ddlGmHZH ddlImJZJ ddlKmLZL ddlMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZUmVZV ddlWmXZXmYZYmZZZm[Z[m\Z\m]Z] e�r�ddlm^Z^ eH�rddl_m`Z`maZa G dd� de�ZbdS )z.Implementing communication with MySQL servers.� )�annotationsN)�Decimal)�IOBase)� TYPE_CHECKING�Any�BinaryIO�Dict� Generator�List�Mapping�Optional�Sequence�Tuple�Type�Union� )�version)�MySQLConnectionAbstract)�MySQLAuthenticator�get_auth_plugin)� ClientFlag� FieldType� RefreshOption� ServerCmd� ServerFlag�flag_is_set)�MySQLConverter) � CursorBase�MySQLCursor�MySQLCursorBuffered�MySQLCursorBufferedDict�MySQLCursorBufferedNamedTuple�MySQLCursorBufferedRaw�MySQLCursorDict�MySQLCursorNamedTuple�MySQLCursorPrepared�MySQLCursorPreparedDict�MySQLCursorPreparedNamedTuple�MySQLCursorPreparedRaw�MySQLCursorRaw)� DatabaseError�Error�InterfaceError� InternalError�NotSupportedError�OperationalError�ProgrammingError� get_exception)�logger)�MySQLSocket�MySQLTCPSocket�MySQLUnixSocket)�OTEL_ENABLED)�with_context_propagation)� MySQLProtocol) �BinaryProtocolType�DescriptionType� EofPacketType� HandShakeType�OkPacketType� ResultType�RowType�StatsPacketType� StrOrBytes)�get_platform� int1store� int4store�lc_int�warn_ciphersuites_deprecated�warn_tls_version_deprecated)�CMySQLPrepStmt)�end_span�record_exception_eventc s� e Zd ZdZddd�� fdd�Zdd�dd �Zdd�d d�Zd�ddddddddd�dd�Zdd�dd�Zdd�dd�Z dd�dd�Z dd�dd�ZeZd�dd!dd!ddd"d#�d$d%�Z d�d'dd(d)�d*d+�Zddd,�d-d.�Zedd�d/d0��Zd1d2d3�d4d5�Zd1d6d3�d7d8�Zd9d2d:�d;d<�Zd1d=d3�d>d?�Zd�dd@dAdBdCdD�dEdF�Zd�dGdd@dAdBdHdI�dJdK�Zdd�dLdM�Zd9d2dN�dOdP�Zed�dQdddd=dR�dSdT��ZdQdUdV�dWdX�Zdd2dY�dZd[�Zd1d�d\d]�Zd�dGdd^�d_d`�Zdad�dbdc�Z dd2dd�dedf�Z!d6d�dgdh�Z"d2d�didj�Z#d�d9d9d9dd9d9d9d9d9dldm� dndo�Z$ed9d�dpdq��Z%e%j&d9ddr�dsdq��Z%dd�dtdu�Z'd9ddv�dwdx�Z(d�dydyddz�d{d|�Z)d�ddddd~�dd��Z*edGd�d�d���Z+d�dAdAdAd�dAdAd�d��d�d��Z,dd�d�d��Z-dd�d�d��Z.d9dd��d�d��Z/d9d�d��d�d��Z0d1d�d3�d�d��Z1d1d�d3�d�d��Z2d�dddd��d�d��Z3d1d�d��d�d��Z4ed�dd�d�dd�d��d�d���Z5ddd��d�d��Z6ddd'dd��d�d��Z7ddd��d�d��Z8dd�d�d��Z9dd�d�d��Z:� Z;S )��MySQLConnectionzConnection to a MySQL Serverr �None)�kwargs�returnc s, d | _ d | _d | _t� �� t| _t�� | _ d| _ d | _d | _d| _ d| _d| _d| _d| _d| _d | _d| _d| _i | _d| _d| _d| _d| _d| _d| _d| _d| _d| _d | _ d| _!d | _"d | _#d | _$d| _%g | _&d| _'t(� | _)|�r(z| j*f i |�� W n$ t+�y& | �,� d | _� Y n0 d S ) N�- F� z 127.0.0.1i� r Tr )-� _protocol�_socket� _handshake�super�__init__r �_converter_classr �get_default� _client_flags�_charset_idZ _sql_modeZ _time_zoneZ_autocommit�_user� _password� _databaseZ_hostZ_port�_unix_socketZ_client_hostZ_client_port�_ssl�_force_ipv6Z_use_unicodeZ _get_warningsZ_raise_on_warnings� _bufferedZ_unread_result�_have_next_result�_raw�_in_transactionZ_prepared_statements�_ssl_active�_auth_plugin�_krb_service_principalZ_pool_config_version�_query_attrs_supported� _columns_desc�_mfa_nfactorr �_authenticator�connect� Exception�close)�selfrM �� __class__� �M/opt/nydus/tmp/pip-target-o2llkf2b/lib64/python/mysql/connector/connection.pyrU � sX zMySQLConnection.__init__)rN c C sz t � }tj�d�}|d dkr$d}nd}tt�� �|d t�� d|d� d d � tj dd� D ��|d d �}| j�|� dS )z&Add the default connection attributes.� r ZGPLv2zGPL-2.0Z Commercial�archzmysql-connector-python�.c S s g | ]}t |��qS rq )�str)�.0�xrq rq rr � <listcomp>� � z;MySQLConnection._add_default_conn_attrs.<locals>.<listcomp>� r )�_pid� _platformZ_source_hostZ_client_nameZ_client_licenseZ_client_version�_osN) rB r ZLICENSE�splitrv �os�getpid�socket�gethostname�join�VERSION�_conn_attrs�update)rn �platformZlicense_chunksZclient_licenseZdefault_conn_attrsrq rq rr �_add_default_conn_attrs� s � z'MySQLConnection._add_default_conn_attrsc C s: t | j�� �}|d dkr"t|��d| _| j�|�}|d }| �t|t t t f�rT|nd�| _| j� | j� |d tj@ s�| jdkr�| js�td��| j�d �r�td dd��| jtj M _n| js�| jtjO _|d tj@ r�| �tjg� |d tj@ �rd | _| �tjg� |d tj@ �r0| �tjg� || _dS )z'Get the handshake from the MySQL server� � NZserver_version_original�UnknownZcapabilitiesZmysql_clear_passwordzEClear password authentication is not supported over insecure channelsZverify_certz1SSL is required but the server doesn't support iti� )�errnoT)�bytesrR �recvr1 rS rQ Zparse_handshakeZ_check_server_version� isinstancerv � bytearray�_server_versionZ_character_setZset_mysql_versionr �SSLre Z is_securer, r^ �getrX � _ssl_disabledZPLUGIN_AUTHZset_client_flags�CLIENT_QUERY_ATTRIBUTESrg ZMULTI_FACTOR_AUTHENTICATION)rn �packet� handshakeZserver_versionrq rq rr � _do_handshake� sB ����zMySQLConnection._do_handshakeNr rO z Optional[str]�intz:Optional[Dict[str, Optional[Union[str, bool, List[str]]]]]zOptional[Dict[str, str]]�bool)�username�password�database�client_flags�charset�ssl_options� conn_attrsrN c C s� | j �d�s"| j �d�r>tjdkr>|s>t�� }t�d|| j � | jrT|| jkrT| j}d| _ | j s�|tj@ r�| j j| j| j|||d� d| _ | j j| j| j||| j| j|||| j | j|| j| j| j| jd�}| �|� |tj@ s�|r�| �|� dS ) ae Authenticate with the MySQL server Authentication happens in two parts. We first send a response to the handshake. The MySQL server will then send either an AuthSwitchRequest or an error packet. Raises NotSupportedError when we get the old, insecure password reply back. Raises any error coming from MySQL. Zauthentication_ociZauthentication_kerberos�ntz4MySQL user is empty, OS user: %s will be used for %sF)r� r� T)�sockr� r� � password1� password2� password3r� r� r� �auth_plugin�auth_plugin_classr� �krb_service_principal�oci_config_file�oci_config_profile�webauthn_callback)re � startswithr� �name�getpass�getuserr2 �debug� _password1rd r� r r� rj Z setup_sslrR �server_host�authenticaterS � _password2� _password3�_auth_plugin_classrf �_oci_config_file�_oci_config_profile�_webauthn_callback� _handle_ok�CONNECT_WITH_DB�cmd_init_db) rn r� r� r� r� r� r� r� �ok_pktrq rq rr �_do_auth� s` � ������ zMySQLConnection._do_authr3 c C sF d}| j r"tjdkr"t| jd�}nt| j| j| jd�}|� | j � |S )z�Get connection based on configuration This method will return the appropriated connection object using the connection parameters. Returns subclass of MySQLBaseSocket. N�posix)�unix_socket)�host�portZ force_ipv6)r] r� r� r5 r� r4 r� Zserver_portr_ �set_connection_timeoutZ_connection_timeout)rn �connrq rq rr �_get_connectionD s �zMySQLConnection._get_connectionc C s | j dkr(| js(t| j | j�}|�� | _t� | _| �� | _zh| j� � | � � | �| j| j| j | j| j| j| j� | �| j� | jtj@ r�| j�� | j�d� W n ty� | j�� � Y n0 | j�st| jjd��rt| jjj��r| jj�� \}}}t|� t ||� dS )z�Open the connection to the MySQL server This method sets up and opens the connection to the MySQL server. Raises on errors. Zauthentication_kerberos_clientN�cipher)!re rZ r r� Zget_user_from_credentialsr8 rQ r� rR �open_connectionr� r� r[ r\ rX rY r^ r� Zset_converter_classrV r ZCOMPRESSZswitch_to_compressed_moder� rl �close_connectionr� �hasattrr� �callabler� rG rF )rn �clsr� Ztls_version�_rq rq rr �_open_connectionY sB � ���z MySQLConnection._open_connectionc C s4 | j s dS z| j �� W n ttfy. Y n0 dS )ah Shut down connection to MySQL Server. This method closes the socket. It raises no exceptions. Unlike `disconnect()`, `shutdown()` closes the client connection without attempting to send a QUIT command to the server first. Thus, it will not block if the connection is disrupted for some reason such as network failure. N)rR �shutdown�AttributeErrorr+ �rn rq rq rr r� � s zMySQLConnection.shutdownc C s� | j r$| j �� r$t| j t�� d � | js.dS z| �� W n ttfyP Y n0 zXz| j� � W n6 t y� } ztr�t| j |� � W Y d}~n d}~0 0 W tr�t| j � ntr�t| j � 0 d| _ dS )z Disconnect from the MySQL serverr N)Z_spanZis_recordingrJ �sys�exc_inforR �cmd_quitr� r+ r� rl r6 rI rS )rn �errrq rq rr rm � s&