Skip to content

Commit a12de4c

Browse files
author
Bogdan Degtyariov
committed
Bug#34999729 - Old OCI authentication option values can be wrongly used on a new connection.
Change-Id: Ie3e0309d48d801912bb8993ae860959cb62dd5f0
1 parent 1931896 commit a12de4c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

jdbc/driver/mysql_connection.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ std::mutex callback_mutex;
9999

100100
sql::Fido_Callback * fido_callback_instance = nullptr;
101101

102+
bool oci_plugin_is_loaded = false;
103+
102104
static void fido_callback_func(const char* msg)
103105
{
104106
if (!fido_callback_instance)
@@ -1023,6 +1025,7 @@ void MySQL_Connection::init(ConnectOptionsMap & properties)
10231025
"authentication_oci_client",
10241026
"oci-config-file",
10251027
*p_s);
1028+
oci_plugin_is_loaded = true;
10261029
} catch (sql::InvalidArgumentException &e) {
10271030
throw ::sql::SQLUnsupportedOptionException(
10281031
"Failed to set config file for authentication_oci_client plugin",
@@ -1042,6 +1045,7 @@ void MySQL_Connection::init(ConnectOptionsMap & properties)
10421045
proxy->plugin_option(MYSQL_CLIENT_AUTHENTICATION_PLUGIN,
10431046
"authentication_oci_client",
10441047
"authentication-oci-client-config-profile", *p_s);
1048+
oci_plugin_is_loaded = true;
10451049
} catch (sql::InvalidArgumentException &e) {
10461050
throw ::sql::SQLUnsupportedOptionException(
10471051
"Failed to set config profile for authentication_oci_client plugin",
@@ -1096,6 +1100,34 @@ void MySQL_Connection::init(ConnectOptionsMap & properties)
10961100

10971101
} /* End of cycle on connection options map */
10981102

1103+
if (oci_plugin_is_loaded) {
1104+
if (properties.find(OPT_OCI_CONFIG_FILE) == properties.end()) {
1105+
// If OCI plugin is loaded, but oci-config-file is not explicitly set
1106+
// the option value needs resetting.
1107+
try {
1108+
proxy->plugin_option(MYSQL_CLIENT_AUTHENTICATION_PLUGIN,
1109+
"authentication_oci_client",
1110+
"oci-config-file",
1111+
nullptr);
1112+
} catch (sql::InvalidArgumentException &) {
1113+
// Do nothing, the exception is expected.
1114+
}
1115+
}
1116+
1117+
if (properties.find(OPT_OCI_CLIENT_CONFIG_PROFILE) == properties.end()) {
1118+
// If OCI plugin is loaded, but oci-config-profile is not explicitly set
1119+
// the option value needs resetting.
1120+
try {
1121+
proxy->plugin_option(MYSQL_CLIENT_AUTHENTICATION_PLUGIN,
1122+
"authentication_oci_client",
1123+
"authentication-oci-client-config-profile",
1124+
nullptr);
1125+
} catch (sql::InvalidArgumentException &) {
1126+
// Do nothing, the exception is expected.
1127+
}
1128+
}
1129+
1130+
}
10991131

11001132
#undef PROCESS_CONNSTR_OPTION
11011133

0 commit comments

Comments
 (0)