Skip to content

Commit

Permalink
Add explicit support for MariaDB in addition to MySQL
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrandtbuffalo authored and sunnavy committed Jan 19, 2024
1 parent b9ebe76 commit f57cbc0
Show file tree
Hide file tree
Showing 21 changed files with 737 additions and 44 deletions.
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ AC_SUBST(LIBS_GROUP)
dnl DB_TYPE
AC_ARG_WITH(db-type,
AS_HELP_STRING([--with-db-type=TYPE],
[sort of database RT will use (default: mysql) (mysql, Pg, Oracle and SQLite are valid)]),
[sort of database RT will use (default: mysql) (mysql, MariaDB Pg, Oracle and SQLite are valid)]),
DB_TYPE=$withval,
DB_TYPE=mysql)
if test "$DB_TYPE" != 'mysql' -a "$DB_TYPE" != 'Pg' -a "$DB_TYPE" != 'SQLite' -a "$DB_TYPE" != 'Oracle' ; then
AC_MSG_ERROR([Only Oracle, Pg, mysql and SQLite are valid db types])
if test "$DB_TYPE" != 'mysql' -a "$DB_TYPE" != 'MariaDB' -a "$DB_TYPE" != 'Pg' -a "$DB_TYPE" != 'SQLite' -a "$DB_TYPE" != 'Oracle' ; then
AC_MSG_ERROR([Only Oracle, Pg, mysql, MariaDB and SQLite are valid db types])
fi
AC_SUBST(DB_TYPE)

Expand Down
4 changes: 3 additions & 1 deletion etc/RT_Config.pm.in
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ Set( @StaticRoots, () );
=item C<$DatabaseType>

Database driver being used; case matters. Valid types are "mysql",
"Oracle", and "Pg". "SQLite" is also available for non-production use.
"MariaDB", "Oracle", and "Pg".

"SQLite" is also available for non-production use.

=cut

Expand Down
38 changes: 38 additions & 0 deletions etc/acl.MariaDB
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

sub acl {
my $dbh = shift;
my $db_name = RT->Config->Get('DatabaseName');
my $db_rthost = RT->Config->Get('DatabaseRTHost');
my $db_user = RT->Config->Get('DatabaseUser');
my $db_pass = RT->Config->Get('DatabasePassword');
unless ( $db_user ) {
RT->Logger->warn("DatabaseUser option is not defined or empty. Skipping...");
return;
}
if ( $db_user eq 'root' ) {
RT->Logger->warn("DatabaseUser is root. Skipping...");
return;
}
$db_name =~ s/([_%\\])/\\$1/g;

if ( my $version = ( $dbh->selectrow_array("show variables like 'version'") )[1] ) {
if ( $version !~ /mariadb/i && $version =~ /^(\d+)\./ ) {
# run 2 part acl update for mysql 8 or higher
if ( $1 >= 8 ) {
return (
"CREATE USER IF NOT EXISTS '$db_user'\@'$db_rthost' IDENTIFIED BY '$db_pass';",
"GRANT SELECT,INSERT,CREATE,INDEX,UPDATE,DELETE ON `$db_name`.* TO '$db_user'\@'$db_rthost';",
);
}
}
}

return (
"GRANT SELECT,INSERT,CREATE,INDEX,UPDATE,DELETE
ON `$db_name`.*
TO '$db_user'\@'$db_rthost'
IDENTIFIED BY '$db_pass';",
);
}

1;
7 changes: 6 additions & 1 deletion etc/cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ requires 'DateTime', '>= 0.44';
requires 'DateTime::Format::Natural', '>= 0.67';
requires 'DateTime::Locale', '>= 0.40, != 1.00, != 1.01';
requires 'DBI', '>= 1.37';
requires 'DBIx::SearchBuilder', '>= 1.80';
requires 'DBIx::SearchBuilder', '>= 1.81';
requires 'Devel::GlobalDestruction';
requires 'Devel::StackTrace', '>= 1.19, != 1.28, != 1.29';
requires 'Digest::base';
Expand Down Expand Up @@ -163,6 +163,11 @@ feature 'mysql' => sub {
requires 'DBD::mysql', '>= 2.1018, != 4.042';
};

feature 'mariadb' => sub {
requires 'DBD::MariaDB', '>= 1.23';
requires 'Apache::Session::MariaDB';
};

feature 'oracle' => sub {
requires 'DBD::Oracle', '!= 1.23';
};
Expand Down
Loading

0 comments on commit f57cbc0

Please sign in to comment.