Lines Matching refs:conn
39 MYSQLND_CONN_DATA * const conn, in mysqlnd_run_authentication() argument
79 …struct st_mysqlnd_authentication_plugin * auth_plugin = conn->m->fetch_auth_plugin_by_name(request… in mysqlnd_run_authentication()
87 …SET_CLIENT_ERROR(conn->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "The server requested aut… in mysqlnd_run_authentication()
102 if (conn->authentication_plugin_data.s) { in mysqlnd_run_authentication()
103 mnd_pefree(conn->authentication_plugin_data.s, conn->persistent); in mysqlnd_run_authentication()
104 conn->authentication_plugin_data.s = NULL; in mysqlnd_run_authentication()
106 conn->authentication_plugin_data.l = plugin_data_len; in mysqlnd_run_authentication()
107 …conn->authentication_plugin_data.s = mnd_pemalloc(conn->authentication_plugin_data.l, conn->persis… in mysqlnd_run_authentication()
108 if (!conn->authentication_plugin_data.s) { in mysqlnd_run_authentication()
109 SET_OOM_ERROR(conn->error_info); in mysqlnd_run_authentication()
112 memcpy(conn->authentication_plugin_data.s, plugin_data, plugin_data_len); in mysqlnd_run_authentication()
118 NULL, &scrambled_data_len, conn, user, passwd, in mysqlnd_run_authentication()
120 session_options, conn->protocol_frame_codec->data, in mysqlnd_run_authentication()
124 if (conn->error_info->error_no) { in mysqlnd_run_authentication()
128 …ret = mysqlnd_auth_handshake(conn, user, passwd, passwd_len, db, db_len, session_options, mysql_fl… in mysqlnd_run_authentication()
138 ret = mysqlnd_auth_change_user(conn, user, strlen(user), passwd, passwd_len, db, db_len, silent, in mysqlnd_run_authentication()
162 DBG_INF_FMT("conn->error_info->error_no = %d", conn->error_info->error_no); in mysqlnd_run_authentication()
163 } while (ret == FAIL && conn->error_info->error_no == 0 && switch_to_auth_protocol != NULL); in mysqlnd_run_authentication()
167 conn->m->set_client_option(conn, MYSQLND_OPT_AUTH_PROTOCOL, requested_protocol); in mysqlnd_run_authentication()
184 mysqlnd_switch_to_ssl_if_needed(MYSQLND_CONN_DATA * const conn, in mysqlnd_switch_to_ssl_if_needed() argument
200 ret = conn->command->enable_ssl(conn, client_capabilities, server_capabilities, charset_no); in mysqlnd_switch_to_ssl_if_needed()
210 MYSQLND_CONN_DATA * const conn, in mysqlnd_connect_run_authentication() argument
227 …ret = mysqlnd_switch_to_ssl_if_needed(conn, charset_no, server_capabilities, session_options, mysq… in mysqlnd_connect_run_authentication()
229 ret = mysqlnd_run_authentication(conn, user, passwd, passwd_len, db, db_len, in mysqlnd_connect_run_authentication()
240 mysqlnd_auth_handshake(MYSQLND_CONN_DATA * conn, in mysqlnd_auth_handshake() argument
268 conn->payload_decoder_factory->m.init_auth_response_packet(&auth_resp_packet); in mysqlnd_auth_handshake()
273 conn->payload_decoder_factory->m.init_change_auth_response_packet(&change_auth_resp_packet); in mysqlnd_auth_handshake()
278 if (!PACKET_WRITE(conn, &change_auth_resp_packet)) { in mysqlnd_auth_handshake()
279 SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT); in mysqlnd_auth_handshake()
280 SET_CLIENT_ERROR(conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone); in mysqlnd_auth_handshake()
288 conn->payload_decoder_factory->m.init_auth_packet(&auth_packet); in mysqlnd_auth_handshake()
307 if (conn->server_capabilities & CLIENT_CONNECT_ATTRS) { in mysqlnd_auth_handshake()
308 auth_packet.connect_attr = conn->options->connect_attr; in mysqlnd_auth_handshake()
311 if (!PACKET_WRITE(conn, &auth_packet)) { in mysqlnd_auth_handshake()
317 conn->charset = mysqlnd_find_charset_nr(auth_packet.charset_no); in mysqlnd_auth_handshake()
324 if (FAIL == auth_plugin->methods.handle_server_response(auth_plugin, conn, in mysqlnd_auth_handshake()
332 if (FAIL == PACKET_READ(conn, &auth_resp_packet) || auth_resp_packet.response_code >= 0xFE) { in mysqlnd_auth_handshake()
337 SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, mysqlnd_old_passwd); in mysqlnd_auth_handshake()
352 …strlcpy(conn->error_info->sqlstate, auth_resp_packet.sqlstate, sizeof(conn->error_info->sqlstate)); in mysqlnd_auth_handshake()
355 …SET_CLIENT_ERROR(conn->error_info, auth_resp_packet.error_no, UNKNOWN_SQLSTATE, auth_resp_packet.e… in mysqlnd_auth_handshake()
360 …SET_NEW_MESSAGE(conn->last_message.s, conn->last_message.l, auth_resp_packet.message, auth_resp_pa… in mysqlnd_auth_handshake()
371 mysqlnd_auth_change_user(MYSQLND_CONN_DATA * const conn, in mysqlnd_auth_change_user() argument
393 const MYSQLND_CHARSET * old_cs = conn->charset; in mysqlnd_auth_change_user()
398 conn->payload_decoder_factory->m.init_change_user_response_packet(&chg_user_resp); in mysqlnd_auth_change_user()
403 conn->payload_decoder_factory->m.init_change_auth_response_packet(&change_auth_resp_packet); in mysqlnd_auth_change_user()
408 if (!PACKET_WRITE(conn, &change_auth_resp_packet)) { in mysqlnd_auth_change_user()
409 SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT); in mysqlnd_auth_change_user()
410 SET_CLIENT_ERROR(conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone); in mysqlnd_auth_change_user()
419 conn->payload_decoder_factory->m.init_auth_packet(&auth_packet); in mysqlnd_auth_change_user()
431 if (conn->server_capabilities & CLIENT_CONNECT_ATTRS) { in mysqlnd_auth_change_user()
432 auth_packet.connect_attr = conn->options->connect_attr; in mysqlnd_auth_change_user()
435 if (conn->m->get_server_version(conn) >= 50123) { in mysqlnd_auth_change_user()
436 auth_packet.charset_no = conn->charset->nr; in mysqlnd_auth_change_user()
439 if (!PACKET_WRITE(conn, &auth_packet)) { in mysqlnd_auth_change_user()
440 SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT); in mysqlnd_auth_change_user()
441 SET_CLIENT_ERROR(conn->error_info, CR_SERVER_GONE_ERROR, UNKNOWN_SQLSTATE, mysqlnd_server_gone); in mysqlnd_auth_change_user()
450 if (FAIL == auth_plugin->methods.handle_server_response(auth_plugin, conn, in mysqlnd_auth_change_user()
458 ret = PACKET_READ(conn, &chg_user_resp); in mysqlnd_auth_change_user()
459 COPY_CLIENT_ERROR(conn->error_info, chg_user_resp.error_info); in mysqlnd_auth_change_user()
465 SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, mysqlnd_old_passwd); in mysqlnd_auth_change_user()
480 if (conn->error_info->error_no) { in mysqlnd_auth_change_user()
487 if (conn->m->get_server_version(conn) > 50113L &&conn->m->get_server_version(conn) < 50118L) { in mysqlnd_auth_change_user()
490 conn->payload_decoder_factory->m.init_ok_packet(&redundant_error_packet); in mysqlnd_auth_change_user()
491 PACKET_READ(conn, &redundant_error_packet); in mysqlnd_auth_change_user()
493 DBG_INF_FMT("Server is %u, buggy, sends two ERR messages", conn->m->get_server_version(conn)); in mysqlnd_auth_change_user()
499 tmp = mnd_pestrndup(user, user_len, conn->persistent); in mysqlnd_auth_change_user()
500 if (conn->username.s) { in mysqlnd_auth_change_user()
501 mnd_pefree(conn->username.s, conn->persistent); in mysqlnd_auth_change_user()
503 conn->username.s = tmp; in mysqlnd_auth_change_user()
505 tmp = mnd_pestrdup(passwd, conn->persistent); in mysqlnd_auth_change_user()
506 if (conn->password.s) { in mysqlnd_auth_change_user()
507 mnd_pefree(conn->password.s, conn->persistent); in mysqlnd_auth_change_user()
509 conn->password.s = tmp; in mysqlnd_auth_change_user()
511 if (conn->last_message.s) { in mysqlnd_auth_change_user()
512 mnd_efree(conn->last_message.s); in mysqlnd_auth_change_user()
513 conn->last_message.s = NULL; in mysqlnd_auth_change_user()
515 UPSERT_STATUS_RESET(conn->upsert_status); in mysqlnd_auth_change_user()
517 if (conn->m->get_server_version(conn) < 50123) { in mysqlnd_auth_change_user()
518 ret = conn->m->set_charset(conn, old_cs->name); in mysqlnd_auth_change_user()
523 SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, mysqlnd_old_passwd); in mysqlnd_auth_change_user()
581 MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd, in mysqlnd_native_auth_get_auth_data() argument
595 …SET_CLIENT_ERROR(conn->error_info, CR_MALFORMED_PACKET, UNKNOWN_SQLSTATE, "The server sent wrong l… in mysqlnd_native_auth_get_auth_data()
642 MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd, in mysqlnd_pam_auth_get_auth_data() argument
722 mysqlnd_sha256_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_public_key, size_t pas… in mysqlnd_sha256_public_encrypt() argument
736 SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long"); in mysqlnd_sha256_public_encrypt()
794 mysqlnd_sha256_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_public_key, size_t pas… in mysqlnd_sha256_public_encrypt() argument
817 SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long"); in mysqlnd_sha256_public_encrypt()
838 mysqlnd_sha256_get_rsa_key(MYSQLND_CONN_DATA * conn, in mysqlnd_sha256_get_rsa_key() argument
858 conn->payload_decoder_factory->m.init_sha256_pk_request_packet(&pk_req_packet); in mysqlnd_sha256_get_rsa_key()
859 conn->payload_decoder_factory->m.init_sha256_pk_request_response_packet(&pk_resp_packet); in mysqlnd_sha256_get_rsa_key()
861 if (! PACKET_WRITE(conn, &pk_req_packet)) { in mysqlnd_sha256_get_rsa_key()
864 SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT); in mysqlnd_sha256_get_rsa_key()
867 if (FAIL == PACKET_READ(conn, &pk_resp_packet) || NULL == pk_resp_packet.public_key) { in mysqlnd_sha256_get_rsa_key()
870 SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT); in mysqlnd_sha256_get_rsa_key()
883 SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, in mysqlnd_sha256_get_rsa_key()
911 MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd, in mysqlnd_sha256_auth_get_auth_data() argument
924 if (conn->vio->data->ssl) { in mysqlnd_sha256_auth_get_auth_data()
932 server_public_key = mysqlnd_sha256_get_rsa_key(conn, session_options, pfc_data); in mysqlnd_sha256_auth_get_auth_data()
940 ret = mysqlnd_sha256_public_encrypt(conn, server_public_key, passwd_len, auth_data_len, xor_str); in mysqlnd_sha256_auth_get_auth_data()
1016 mysqlnd_caching_sha2_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_public_key, size… in mysqlnd_caching_sha2_public_encrypt() argument
1029 SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long"); in mysqlnd_caching_sha2_public_encrypt()
1045 mysqlnd_caching_sha2_public_encrypt(MYSQLND_CONN_DATA * conn, mysqlnd_rsa_t server_public_key, size… in mysqlnd_caching_sha2_public_encrypt() argument
1067 SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, "password is too long"); in mysqlnd_caching_sha2_public_encrypt()
1089 MYSQLND_CONN_DATA * conn, const char * const user, const char * const passwd, in mysqlnd_caching_sha2_get_auth_data() argument
1102 …SET_CLIENT_ERROR(conn->error_info, CR_MALFORMED_PACKET, UNKNOWN_SQLSTATE, "The server sent wrong l… in mysqlnd_caching_sha2_get_auth_data()
1122 mysqlnd_caching_sha2_get_key(MYSQLND_CONN_DATA *conn) in mysqlnd_caching_sha2_get_key() argument
1125 const MYSQLND_PFC_DATA * const pfc_data = conn->protocol_frame_codec->data; in mysqlnd_caching_sha2_get_key()
1140 conn->payload_decoder_factory->m.init_cached_sha2_result_packet(&req_packet); in mysqlnd_caching_sha2_get_key()
1141 conn->payload_decoder_factory->m.init_sha256_pk_request_response_packet(&pk_resp_packet); in mysqlnd_caching_sha2_get_key()
1144 if (! PACKET_WRITE(conn, &req_packet)) { in mysqlnd_caching_sha2_get_key()
1147 SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT); in mysqlnd_caching_sha2_get_key()
1150 if (FAIL == PACKET_READ(conn, &pk_resp_packet) || NULL == pk_resp_packet.public_key) { in mysqlnd_caching_sha2_get_key()
1153 SET_CONNECTION_STATE(&conn->state, CONN_QUIT_SENT); in mysqlnd_caching_sha2_get_key()
1166 SET_CLIENT_ERROR(conn->error_info, CR_UNKNOWN_ERROR, UNKNOWN_SQLSTATE, in mysqlnd_caching_sha2_get_key()
1192 mysqlnd_caching_sha2_get_and_use_key(MYSQLND_CONN_DATA *conn, in mysqlnd_caching_sha2_get_and_use_key() argument
1198 mysqlnd_rsa_t server_public_key = mysqlnd_caching_sha2_get_key(conn); in mysqlnd_caching_sha2_get_and_use_key()
1209 …server_public_key_len = mysqlnd_caching_sha2_public_encrypt(conn, server_public_key, passwd_len, c… in mysqlnd_caching_sha2_get_and_use_key()
1217 static int is_secure_transport(MYSQLND_CONN_DATA *conn) { in is_secure_transport() argument
1218 if (conn->vio->data->ssl) { in is_secure_transport()
1222 return strcmp(conn->vio->data->stream->ops->label, "unix_socket") == 0; in is_secure_transport()
1228 MYSQLND_CONN_DATA * conn, in mysqlnd_caching_sha2_handle_server_response() argument
1244 conn->payload_decoder_factory->m.init_cached_sha2_result_packet(&result_packet); in mysqlnd_caching_sha2_handle_server_response()
1245 if (FAIL == PACKET_READ(conn, &result_packet)) { in mysqlnd_caching_sha2_handle_server_response()
1252 strlcpy(conn->error_info->sqlstate, result_packet.sqlstate, sizeof(conn->error_info->sqlstate)); in mysqlnd_caching_sha2_handle_server_response()
1255 … SET_CLIENT_ERROR(conn->error_info, result_packet.error_no, UNKNOWN_SQLSTATE, result_packet.error); in mysqlnd_caching_sha2_handle_server_response()
1268 if (is_secure_transport(conn)) { in mysqlnd_caching_sha2_handle_server_response()
1272 PACKET_WRITE(conn, &result_packet); in mysqlnd_caching_sha2_handle_server_response()
1275 …result_packet.password_len = mysqlnd_caching_sha2_get_and_use_key(conn, auth_plugin_data, auth_plu… in mysqlnd_caching_sha2_handle_server_response()
1276 PACKET_WRITE(conn, &result_packet); in mysqlnd_caching_sha2_handle_server_response()