Lines Matching refs:conn
37 MYSQLND_CONN_DATA * const conn, in mysqlnd_run_authentication() argument
77 …struct st_mysqlnd_authentication_plugin * auth_plugin = conn->m->fetch_auth_plugin_by_name(request… in mysqlnd_run_authentication()
85 …SET_CLIENT_ERROR(conn->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "The server requested aut… in mysqlnd_run_authentication()
100 if (conn->authentication_plugin_data.s) { in mysqlnd_run_authentication()
101 mnd_pefree(conn->authentication_plugin_data.s, conn->persistent); in mysqlnd_run_authentication()
102 conn->authentication_plugin_data.s = NULL; in mysqlnd_run_authentication()
104 conn->authentication_plugin_data.l = plugin_data_len; in mysqlnd_run_authentication()
105 …conn->authentication_plugin_data.s = mnd_pemalloc(conn->authentication_plugin_data.l, conn->persis… in mysqlnd_run_authentication()
106 if (!conn->authentication_plugin_data.s) { in mysqlnd_run_authentication()
107 SET_OOM_ERROR(conn->error_info); in mysqlnd_run_authentication()
110 memcpy(conn->authentication_plugin_data.s, plugin_data, plugin_data_len); in mysqlnd_run_authentication()
116 NULL, &scrambled_data_len, conn, user, passwd, in mysqlnd_run_authentication()
118 session_options, conn->protocol_frame_codec->data, in mysqlnd_run_authentication()
122 if (conn->error_info->error_no) { in mysqlnd_run_authentication()
126 …ret = mysqlnd_auth_handshake(conn, user, passwd, passwd_len, db, db_len, session_options, mysql_fl… in mysqlnd_run_authentication()
136 ret = mysqlnd_auth_change_user(conn, user, strlen(user), passwd, passwd_len, db, db_len, silent, in mysqlnd_run_authentication()
160 DBG_INF_FMT("conn->error_info->error_no = %d", conn->error_info->error_no); in mysqlnd_run_authentication()
161 } while (ret == FAIL && conn->error_info->error_no == 0 && switch_to_auth_protocol != NULL); in mysqlnd_run_authentication()
165 conn->m->set_client_option(conn, MYSQLND_OPT_AUTH_PROTOCOL, requested_protocol); in mysqlnd_run_authentication()
182 mysqlnd_switch_to_ssl_if_needed(MYSQLND_CONN_DATA * const conn, in mysqlnd_switch_to_ssl_if_needed() argument
198 ret = conn->command->enable_ssl(conn, client_capabilities, server_capabilities, charset_no); in mysqlnd_switch_to_ssl_if_needed()
208 MYSQLND_CONN_DATA * const conn, in mysqlnd_connect_run_authentication() argument
225 …ret = mysqlnd_switch_to_ssl_if_needed(conn, charset_no, server_capabilities, session_options, mysq… in mysqlnd_connect_run_authentication()
227 ret = mysqlnd_run_authentication(conn, user, passwd, passwd_len, db, db_len, in mysqlnd_connect_run_authentication()
238 mysqlnd_auth_handshake(MYSQLND_CONN_DATA * conn, in mysqlnd_auth_handshake() argument
266 conn->payload_decoder_factory->m.init_auth_response_packet(&auth_resp_packet); in mysqlnd_auth_handshake()
271 conn->payload_decoder_factory->m.init_change_auth_response_packet(&change_auth_resp_packet); in mysqlnd_auth_handshake()
276 if (!PACKET_WRITE(conn, &change_auth_resp_packet)) { in mysqlnd_auth_handshake()
277 SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT); in mysqlnd_auth_handshake()
278 SET_CLIENT_ERROR(conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone); in mysqlnd_auth_handshake()
286 conn->payload_decoder_factory->m.init_auth_packet(&auth_packet); in mysqlnd_auth_handshake()
305 if (conn->server_capabilities & CLIENT_CONNECT_ATTRS) { in mysqlnd_auth_handshake()
306 auth_packet.connect_attr = conn->options->connect_attr; in mysqlnd_auth_handshake()
309 if (!PACKET_WRITE(conn, &auth_packet)) { in mysqlnd_auth_handshake()
315 conn->charset = mysqlnd_find_charset_nr(auth_packet.charset_no); in mysqlnd_auth_handshake()
322 if (FAIL == auth_plugin->methods.handle_server_response(auth_plugin, conn, in mysqlnd_auth_handshake()
330 if (FAIL == PACKET_READ(conn, &auth_resp_packet) || auth_resp_packet.response_code >= 0xFE) { in mysqlnd_auth_handshake()
335 SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, mysqlnd_old_passwd); in mysqlnd_auth_handshake()
350 …strlcpy(conn->error_info->sqlstate, auth_resp_packet.sqlstate, sizeof(conn->error_info->sqlstate)); in mysqlnd_auth_handshake()
353 …SET_CLIENT_ERROR(conn->error_info, auth_resp_packet.error_no, UNKNOWN_SQLSTATE, auth_resp_packet.e… in mysqlnd_auth_handshake()
358 …SET_NEW_MESSAGE(conn->last_message.s, conn->last_message.l, auth_resp_packet.message, auth_resp_pa… in mysqlnd_auth_handshake()
369 mysqlnd_auth_change_user(MYSQLND_CONN_DATA * const conn, in mysqlnd_auth_change_user() argument
391 const MYSQLND_CHARSET * old_cs = conn->charset; in mysqlnd_auth_change_user()
396 conn->payload_decoder_factory->m.init_change_user_response_packet(&chg_user_resp); in mysqlnd_auth_change_user()
401 conn->payload_decoder_factory->m.init_change_auth_response_packet(&change_auth_resp_packet); in mysqlnd_auth_change_user()
406 if (!PACKET_WRITE(conn, &change_auth_resp_packet)) { in mysqlnd_auth_change_user()
407 SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT); in mysqlnd_auth_change_user()
408 SET_CLIENT_ERROR(conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone); in mysqlnd_auth_change_user()
417 conn->payload_decoder_factory->m.init_auth_packet(&auth_packet); in mysqlnd_auth_change_user()
429 if (conn->server_capabilities & CLIENT_CONNECT_ATTRS) { in mysqlnd_auth_change_user()
430 auth_packet.connect_attr = conn->options->connect_attr; in mysqlnd_auth_change_user()
433 if (conn->m->get_server_version(conn) >= 50123) { in mysqlnd_auth_change_user()
434 auth_packet.charset_no = conn->charset->nr; in mysqlnd_auth_change_user()
437 if (!PACKET_WRITE(conn, &auth_packet)) { in mysqlnd_auth_change_user()
438 SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT); in mysqlnd_auth_change_user()
439 SET_CLIENT_ERROR(conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone); in mysqlnd_auth_change_user()
448 if (FAIL == auth_plugin->methods.handle_server_response(auth_plugin, conn, in mysqlnd_auth_change_user()
456 ret = PACKET_READ(conn, &chg_user_resp); in mysqlnd_auth_change_user()
457 COPY_CLIENT_ERROR(conn->error_info, chg_user_resp.error_info); in mysqlnd_auth_change_user()
463 SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, mysqlnd_old_passwd); in mysqlnd_auth_change_user()
478 if (conn->error_info->error_no) { in mysqlnd_auth_change_user()
485 if (conn->m->get_server_version(conn) > 50113L &&conn->m->get_server_version(conn) < 50118L) { in mysqlnd_auth_change_user()
488 conn->payload_decoder_factory->m.init_ok_packet(&redundant_error_packet); in mysqlnd_auth_change_user()
489 PACKET_READ(conn, &redundant_error_packet); in mysqlnd_auth_change_user()
491 DBG_INF_FMT("Server is %u, buggy, sends two ERR messages", conn->m->get_server_version(conn)); in mysqlnd_auth_change_user()
497 tmp = mnd_pestrndup(user, user_len, conn->persistent); in mysqlnd_auth_change_user()
498 if (conn->username.s) { in mysqlnd_auth_change_user()
499 mnd_pefree(conn->username.s, conn->persistent); in mysqlnd_auth_change_user()
501 conn->username.s = tmp; in mysqlnd_auth_change_user()
503 tmp = mnd_pestrdup(passwd, conn->persistent); in mysqlnd_auth_change_user()
504 if (conn->password.s) { in mysqlnd_auth_change_user()
505 mnd_pefree(conn->password.s, conn->persistent); in mysqlnd_auth_change_user()
507 conn->password.s = tmp; in mysqlnd_auth_change_user()
509 if (conn->last_message.s) { in mysqlnd_auth_change_user()
510 mnd_efree(conn->last_message.s); in mysqlnd_auth_change_user()
511 conn->last_message.s = NULL; in mysqlnd_auth_change_user()
513 UPSERT_STATUS_RESET(conn->upsert_status); in mysqlnd_auth_change_user()
515 if (conn->m->get_server_version(conn) < 50123) { in mysqlnd_auth_change_user()
516 ret = conn->m->set_charset(conn, old_cs->name); in mysqlnd_auth_change_user()
521 SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, mysqlnd_old_passwd); in mysqlnd_auth_change_user()
579 MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd, in mysqlnd_native_auth_get_auth_data() argument
593 …SET_CLIENT_ERROR(conn->error_info, CR_MALFORMED_PACKET, UNKNOWN_SQLSTATE, "The server sent wrong l… in mysqlnd_native_auth_get_auth_data()
640 MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd, in mysqlnd_pam_auth_get_auth_data() argument
720 mysqlnd_sha256_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_public_key, size_t pas… in mysqlnd_sha256_public_encrypt() argument
734 SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long"); in mysqlnd_sha256_public_encrypt()
792 mysqlnd_sha256_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_public_key, size_t pas… in mysqlnd_sha256_public_encrypt() argument
815 SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long"); in mysqlnd_sha256_public_encrypt()
836 mysqlnd_sha256_get_rsa_key(MYSQLND_CONN_DATA * conn, in mysqlnd_sha256_get_rsa_key() argument
856 conn->payload_decoder_factory->m.init_sha256_pk_request_packet(&pk_req_packet); in mysqlnd_sha256_get_rsa_key()
857 conn->payload_decoder_factory->m.init_sha256_pk_request_response_packet(&pk_resp_packet); in mysqlnd_sha256_get_rsa_key()
859 if (! PACKET_WRITE(conn, &pk_req_packet)) { in mysqlnd_sha256_get_rsa_key()
862 SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT); in mysqlnd_sha256_get_rsa_key()
865 if (FAIL == PACKET_READ(conn, &pk_resp_packet) || NULL == pk_resp_packet.public_key) { in mysqlnd_sha256_get_rsa_key()
868 SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT); in mysqlnd_sha256_get_rsa_key()
881 SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, in mysqlnd_sha256_get_rsa_key()
909 MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd, in mysqlnd_sha256_auth_get_auth_data() argument
922 if (conn->vio->data->ssl) { in mysqlnd_sha256_auth_get_auth_data()
930 server_public_key = mysqlnd_sha256_get_rsa_key(conn, session_options, pfc_data); in mysqlnd_sha256_auth_get_auth_data()
938 ret = mysqlnd_sha256_public_encrypt(conn, server_public_key, passwd_len, auth_data_len, xor_str); in mysqlnd_sha256_auth_get_auth_data()
1014 mysqlnd_caching_sha2_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_public_key, size… in mysqlnd_caching_sha2_public_encrypt() argument
1027 SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long"); in mysqlnd_caching_sha2_public_encrypt()
1043 mysqlnd_caching_sha2_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_public_key, size… in mysqlnd_caching_sha2_public_encrypt() argument
1065 SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long"); in mysqlnd_caching_sha2_public_encrypt()
1087 MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd, in mysqlnd_caching_sha2_get_auth_data() argument
1100 …SET_CLIENT_ERROR(conn->error_info, CR_MALFORMED_PACKET, UNKNOWN_SQLSTATE, "The server sent wrong l… in mysqlnd_caching_sha2_get_auth_data()
1120 mysqlnd_caching_sha2_get_key(MYSQLND_CONN_DATA *conn) in mysqlnd_caching_sha2_get_key() argument
1123 const MYSQLND_PFC_DATA * const pfc_data = conn->protocol_frame_codec->data; in mysqlnd_caching_sha2_get_key()
1138 conn->payload_decoder_factory->m.init_cached_sha2_result_packet(&req_packet); in mysqlnd_caching_sha2_get_key()
1139 conn->payload_decoder_factory->m.init_sha256_pk_request_response_packet(&pk_resp_packet); in mysqlnd_caching_sha2_get_key()
1142 if (! PACKET_WRITE(conn, &req_packet)) { in mysqlnd_caching_sha2_get_key()
1145 SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT); in mysqlnd_caching_sha2_get_key()
1148 if (FAIL == PACKET_READ(conn, &pk_resp_packet) || NULL == pk_resp_packet.public_key) { in mysqlnd_caching_sha2_get_key()
1151 SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT); in mysqlnd_caching_sha2_get_key()
1164 SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, in mysqlnd_caching_sha2_get_key()
1190 mysqlnd_caching_sha2_get_and_use_key(MYSQLND_CONN_DATA *conn, in mysqlnd_caching_sha2_get_and_use_key() argument
1196 mysqlnd_rsa_t server_public_key = mysqlnd_caching_sha2_get_key(conn); in mysqlnd_caching_sha2_get_and_use_key()
1207 …server_public_key_len = mysqlnd_caching_sha2_public_encrypt(conn, server_public_key, passwd_len, c… in mysqlnd_caching_sha2_get_and_use_key()
1215 static int is_secure_transport(MYSQLND_CONN_DATA *conn) { in is_secure_transport() argument
1216 if (conn->vio->data->ssl) { in is_secure_transport()
1220 return strcmp(conn->vio->data->stream->ops->label, "unix_socket") == 0; in is_secure_transport()
1226 MYSQLND_CONN_DATA * conn, in mysqlnd_caching_sha2_handle_server_response() argument
1242 conn->payload_decoder_factory->m.init_cached_sha2_result_packet(&result_packet); in mysqlnd_caching_sha2_handle_server_response()
1243 if (FAIL == PACKET_READ(conn, &result_packet)) { in mysqlnd_caching_sha2_handle_server_response()
1250 strlcpy(conn->error_info->sqlstate, result_packet.sqlstate, sizeof(conn->error_info->sqlstate)); in mysqlnd_caching_sha2_handle_server_response()
1253 … SET_CLIENT_ERROR(conn->error_info, result_packet.error_no, UNKNOWN_SQLSTATE, result_packet.error); in mysqlnd_caching_sha2_handle_server_response()
1266 if (is_secure_transport(conn)) { in mysqlnd_caching_sha2_handle_server_response()
1270 PACKET_WRITE(conn, &result_packet); in mysqlnd_caching_sha2_handle_server_response()
1273 …result_packet.password_len = mysqlnd_caching_sha2_get_and_use_key(conn, auth_plugin_data, auth_plu… in mysqlnd_caching_sha2_handle_server_response()
1274 PACKET_WRITE(conn, &result_packet); in mysqlnd_caching_sha2_handle_server_response()