DBD-MariaDB
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
"\$::test_mysql_config = \$opt->{'mysql_config'} if \$source->{'mysql_config'} eq 'User\\'s choice';\n" .
"\$::test_cflags = \$opt->{'cflags'} if \$source->{'cflags'} eq 'User\\'s choice';\n" .
"\$::test_libs = \$opt->{'libs'} if \$source->{'libs'} eq 'User\\'s choice';\n" .
"} 1;\n")) &&
close(FILE)) || die "Failed to create $fileName: $!";
my $cflags = "-I\$(DBI_INSTARCH_DIR) $opt->{'cflags'}";
$cflags .= " -DHAVE_DBI_1_634" if eval { DBI->VERSION(1.634) };
$cflags .= " -DHAVE_DBI_1_642" if eval { DBI->VERSION(1.642) };
$cflags .= " -DHAVE_EMBEDDED" if $have_embedded;
$cflags .= " -DHAVE_GET_CHARSET_NUMBER" if $have_get_charset_number;
$cflags .= " -DHAVE_GET_OPTION" if $have_get_option;
$cflags .= " -DHAVE_DEINITIALIZE_SSL" if $have_deinitialize_ssl;
$cflags .= " -DHAVE_PROBLEM_WITH_OPENSSL" if $have_problem_with_openssl;
my %o =
(
'NAME' => 'DBD::MariaDB',
'INC' => $cflags,
'dist' => {
'SUFFIX' => ".gz",
#endif
if (DBIc_TRACE_LEVEL(imp_xxh) >= 2)
PerlIO_printf(DBIc_LOGPIO(imp_xxh),
"imp_dbh->mariadb_dr_connect: host = |%s|, port = %u,"
" uid = %s, pwd = %s\n",
host ? host : "NULL", port,
user ? user : "NULL",
!password ? "NULL" : !password[0] ? "" : "****");
#if !defined(HAVE_EMBEDDED) && defined(HAVE_BROKEN_INIT)
if (imp_drh->non_embedded_finished)
{
mariadb_dr_do_error(dbh, CR_CONNECTION_ERROR, "Connection error: Method disconnect_all() was already called and library functions unloaded", "HY000");
return FALSE;
}
#endif
/* host=localhost means to connect via unix socket, host=embedded means to use embedded server, so do not allow specifying port */
if (port && host && (strcmp(host, "localhost") == 0 || strcmp(host, "embedded") == 0))
{
/* when connecting via unix socket do not allow specifying port or host != localhost */
if (mysql_socket && (port || (host && strcmp(host, "localhost") != 0)))
{
mariadb_dr_do_error(dbh, CR_CONNECTION_ERROR, "Connection error: host or port cannot be specified together with mariadb_socket", "HY000");
return FALSE;
}
if (host && strcmp(host, "embedded") == 0)
{
#ifndef HAVE_EMBEDDED
mariadb_dr_do_error(dbh, CR_CONNECTION_ERROR, "Connection error: Embedded server is not supported", "HY000");
return FALSE;
#endif
if (sv && SvROK(sv))
{
SV** svp;
SV *embedded_groups = NULL;
SV *embedded_args = NULL;
STRLEN options_len;
char * options;
sv_2mortal(newRV_noinc((SV *)processed)); /* Automatically free HV processed */
/* These options are already handled and processed */
(void)hv_stores(processed, "host", &PL_sv_yes);
(void)hv_stores(processed, "port", &PL_sv_yes);
(void)hv_stores(processed, "user", &PL_sv_yes);
(void)hv_stores(processed, "password", &PL_sv_yes);
(void)hv_stores(processed, "database", &PL_sv_yes);
(void)hv_stores(processed, "mariadb_socket", &PL_sv_yes);
#ifdef HAVE_EMBEDDED
if (host && strcmp(host, "embedded") == 0)
{
(void)hv_stores(processed, "mariadb_embedded_groups", &PL_sv_yes);
(void)hv_stores(processed, "mariadb_embedded_options", &PL_sv_yes);
mysql_options(sock, MYSQL_OPT_USE_EMBEDDED_CONNECTION, NULL);
imp_dbh->is_embedded = TRUE;
host = NULL;
}
else
{
mysql_options(sock, MYSQL_OPT_USE_REMOTE_CONNECTION, NULL);
}
#endif
/* thanks to Peter John Edwards for mysql_init_command */
if (imp_drh->embedded_started)
{
warn("DBD::MariaDB disconnect_all: Embedded server was not properly stopped (possible bug in driver)");
ret = 0;
}
/* Some MariaDB and MySQL clients with Embedded server support have a bug which cause segfault
* when trying to call mysql_server_end() when Embedded server was not started. So do not call
* mysql_server_end() for normal connections when we have Embedded server support. */
#ifndef HAVE_EMBEDDED
if (imp_drh->non_embedded_started)
{
#if defined(HAVE_DEINITIALIZE_SSL) || !defined(HAVE_PROBLEM_WITH_OPENSSL)
#ifndef HAVE_BROKEN_INIT
warn("DBD::MariaDB disconnect_all: Client library was not properly deinitialized (possible bug in driver)");
ret = 0;
#else
mysql_server_end();
imp_drh->non_embedded_started = FALSE;
imp_drh->non_embedded_finished = TRUE;
/* mysql_error(NULL) returns last error message, needs MySQL 5.0.60+ or 5.1.24+; does not work with MariaDB Connector/C yet: https://jira.mariadb.org/browse/CONC-374 */
#if ((MYSQL_VERSION_ID >= 50060 && MYSQL_VERSION_ID < 50100) || MYSQL_VERSION_ID >= 50124) && !defined(MARIADB_PACKAGE_VERSION)
#define HAVE_LAST_ERROR
#endif
/*
* MySQL and MariaDB Embedded are affected by https://jira.mariadb.org/browse/MDEV-16578
* MariaDB 10.2.2+ prior to 10.2.19 and 10.3.9 and MariaDB Connector/C prior to 3.0.5 are affected by https://jira.mariadb.org/browse/CONC-336
* MySQL 8.0.4+ prior to 8.0.20 is affected too by https://bugs.mysql.com/bug.php?id=93276
*/
#if defined(HAVE_EMBEDDED) || (!defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 80004 && MYSQL_VERSION_ID < 80020) || (defined(MARIADB_PACKAGE_VERSION) && (!defined(MARIADB_PACKAGE_VERSION_ID) || MARIADB_PACKAGE_VERSION_ID < 30005)) || (defined(...
#define HAVE_BROKEN_INIT
#endif
/*
* Check which SSL settings are supported by API at compile time
*/
/* Use mysql_options with MYSQL_OPT_SSL_VERIFY_SERVER_CERT */
#if ((MYSQL_VERSION_ID >= 50023 && MYSQL_VERSION_ID < 50100) || MYSQL_VERSION_ID >= 50111) && (MYSQL_VERSION_ID < 80000 || defined(MARIADB_BASE_VERSION))
#define HAVE_SSL_VERIFY
#endif
/* Use mysql_options with MYSQL_OPT_SSL_ENFORCE (CVE-2015-3152, fix for MySQL) */
#if !defined(MARIADB_BASE_VERSION) && !defined(HAVE_EMBEDDED) && MYSQL_VERSION_ID >= 50703 && MYSQL_VERSION_ID < 80000 && MYSQL_VERSION_ID != 60000
#define HAVE_SSL_ENFORCE
#endif
/* Use mysql_options with MYSQL_OPT_SSL_MODE (CVE-2015-3152, fix for MySQL) */
#if !defined(MARIADB_BASE_VERSION) && !defined(HAVE_EMBEDDED) && MYSQL_VERSION_ID >= 50711 && MYSQL_VERSION_ID != 60000
#define HAVE_SSL_MODE
#endif
/* Use mysql_options with MYSQL_OPT_SSL_MODE, but only SSL_MODE_REQUIRED is supported (CVE-2017-3305, fix for MySQL) */
#if !defined(MARIADB_BASE_VERSION) && !defined(HAVE_EMBEDDED) && ((MYSQL_VERSION_ID >= 50636 && MYSQL_VERSION_ID < 50700) || (MYSQL_VERSION_ID >= 50555 && MYSQL_VERSION_ID < 50600))
#define HAVE_SSL_MODE_ONLY_REQUIRED
#endif
/*
* Check which SSL settings are supported by API at runtime
*/
/* MYSQL_OPT_SSL_VERIFY_SERVER_CERT automatically enforce SSL mode (CVE-2015-3152 and CVE-2017-3305 and CVE-2018-2767, fix for MariaDB) */
PERL_STATIC_INLINE bool ssl_verify_also_enforce_ssl(void) {
#ifdef MARIADB_BASE_VERSION
unsigned long version = mysql_get_client_version();
#ifdef HAVE_EMBEDDED
return ((version >= 50560 && version < 50600) || (version >= 100035 && version < 100100) || (version >= 100133 && version < 100200) || (version >= 100215 && version < 100300) || version >= 100307);
#else
return ((version >= 50556 && version < 50600) || (version >= 100031 && version < 100100) || (version >= 100123 && version < 100200) || (version >= 100206 && version < 100300) || version >= 100301);
#endif
#else
return FALSE;
#endif
}
/* MYSQL_OPT_SSL_VERIFY_SERVER_CERT is not vulnerable (CVE-2016-2047) and can be used */
* This declares a variable called "imp_drh" of type
* "struct imp_drh_st *".
*/
struct imp_drh_st {
dbih_drc_t com; /* MUST be first element in structure */
struct mariadb_list_entry *active_imp_dbhs; /* List of imp_dbh structures with active MYSQL* */
struct mariadb_list_entry *taken_pmysqls; /* List of active MYSQL* from take_imp_data() */
unsigned long int instances;
bool non_embedded_started;
#if !defined(HAVE_EMBEDDED) && defined(HAVE_BROKEN_INIT)
bool non_embedded_finished;
#endif
bool embedded_started;
SV *embedded_args;
SV *embedded_groups;
};
/*
* Likewise, this is our part of the database handle, as returned
( run in 0.882 second using v1.01-cache-2.11-cpan-71847e10f99 )