From 7e8a007b02280cee06cad5ac25db91af67d25b6b Mon Sep 17 00:00:00 2001 From: Xavier Guimard Date: Thu, 23 Aug 2018 07:01:22 +0200 Subject: [PATCH] Accept DBD::MariaDB (#1490) --- lemonldap-ng-common/lemonldap-ng.ini | 2 +- .../lib/Lemonldap/NG/Common/Apache/Session.pm | 3 +++ lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf.pm | 2 +- .../lib/Lemonldap/NG/Common/Conf/Backends/_DBI.pm | 8 +++++--- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lemonldap-ng-common/lemonldap-ng.ini b/lemonldap-ng-common/lemonldap-ng.ini index e9fe80556..802f71131 100644 --- a/lemonldap-ng-common/lemonldap-ng.ini +++ b/lemonldap-ng-common/lemonldap-ng.ini @@ -108,7 +108,7 @@ logLevel = warn ; ; type = RDBI ; ;type = CDBI -; dbiChain = DBI:mysql:database=lemonldap-ng;host=1.2.3.4 +; dbiChain = DBI:MariaDB:database=lemonldap-ng;host=1.2.3.4 ; dbiUser = lemonldap ; dbiPassword = password ; diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Apache/Session.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Apache/Session.pm index 3cfecfff0..e5597f049 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Apache/Session.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Apache/Session.pm @@ -174,6 +174,9 @@ sub get_key_from_all_sessions { $args->{unserialize} = \&Lemonldap::NG::Common::Apache::Session::Serialize::JSON::_unserialize; } + + # For now, Apache::Session::MariaDB doesn't exists. + # Apache::Session::Browseable::MariaDB has its own get_key_from_all_sessions if ( $backend =~ /^Apache::Session::(SQLite\d?|MySQL|MySQL::NoLock|Postgres|Oracle|Sybase|Informix)$/ ) diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf.pm index 1ac1bd891..9e4a91563 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf.pm @@ -45,7 +45,7 @@ BEGIN { # - Nothing: default configuration file is tested, # - { confFile => "/path/to/storage.conf" }, # - { Type => "File", dirName => "/path/to/conf/dir/" }, -# - { Type => "DBI", dbiChain => "DBI:mysql:database=lemonldap-ng;host=1.2.3.4", +# - { Type => "DBI", dbiChain => "DBI:MariaDB:database=lemonldap-ng;host=1.2.3.4", # dbiUser => "user", dbiPassword => "password" }, # - { Type => "SOAP", proxy => "https://auth.example.com/config" }, # - { Type => "LDAP", ldapServer => "ldap://localhost", ldapConfBranch => "ou=conf,ou=applications,dc=example,dc=com", diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Backends/_DBI.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Backends/_DBI.pm index 92985d195..1d7562ec2 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Backends/_DBI.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/Backends/_DBI.pm @@ -70,12 +70,14 @@ sub _dbh { elsif ( $self->{dbiChain} =~ /^dbi:pg/i ) { $self->{_dbh}->{pg_enable_utf8} = 1; } + + # DBD::MariaDB should have o problem here return $self->{_dbh}; } sub lock { my $self = shift; - if ( $self->{dbiChain} =~ /^dbi:mysql:/i ) { + if ( $self->{dbiChain} =~ /^dbi:(?:MariaDB|mysql):/i ) { my @row = $self->_dbh->selectrow_array("SELECT GET_LOCK('lmconf', 0)"); return $row[0] || 0; } @@ -84,7 +86,7 @@ sub lock { sub isLocked { my $self = shift; - if ( $self->{dbiChain} =~ /^dbi:mysql:/i ) { + if ( $self->{dbiChain} =~ /^dbi:(?:MariaDB|mysql):/i ) { my @row = $self->_dbh->selectrow_array("SELECT IS_FREE_LOCK('lmconf')"); return $row[0] ? 0 : 1; } @@ -93,7 +95,7 @@ sub isLocked { sub unlock { my $self = shift; - if ( $self->{dbiChain} =~ /^dbi:mysql:/i ) { + if ( $self->{dbiChain} =~ /^dbi:(?:MariaDB|mysql):/i ) { my @row = $self->_dbh->selectrow_array("SELECT RELEASE_LOCK('lmconf')"); return $row[0] || 0; }