-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add explicit support for MariaDB in addition to MySQL
- Loading branch information
1 parent
b9ebe76
commit f57cbc0
Showing
21 changed files
with
737 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.