From 9fe740430fd459707f4fd8b0dd073a496326d48e Mon Sep 17 00:00:00 2001 From: Igor Pashev Date: Fri, 17 Jun 2016 17:29:18 +0800 Subject: Work around MariaDB's libmysqlclient See https://jira.mariadb.org/browse/MDEV-10246 --- src/Main.hs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index 1f8cc89..e9a29b7 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -7,8 +7,9 @@ module Main ( import Data.ByteString.Char8 (pack) import Data.Either.Utils (forceEither) import Data.Maybe (fromJust) +import Data.List (isPrefixOf) import Data.Version (showVersion) -import Database.MySQL.Base (ConnectInfo(..)) +import Database.MySQL.Base (ConnectInfo(..), defaultSSLInfo) import Database.MySQL.Base.Types (Option(ReadDefaultFile, ReadDefaultGroup)) import Paths_mywatch (getDataDir, version) -- from cabal import System.Environment (getArgs) @@ -51,15 +52,19 @@ main = do port = O.getArg args $ O.longOption "port" socket = fromJust $ O.getArg args $ O.longOption "socket" datadir = fromJust $ O.getArg args $ O.longOption "datadir" - servers <- filter ("client" /=) . Cf.sections . forceEither <$> Cf.readfile Cf.emptyCP file + + cf <- forceEither <$> Cf.readfile Cf.emptyCP file let + servers = filter ("client" /=) . Cf.sections $ cf myInfo = map (\g -> ConnectInfo { connectDatabase = "", connectHost = "", connectPassword = "", connectPath = "", connectPort = 0, - connectSSL = Nothing, + -- FIXME: https://jira.mariadb.org/browse/MDEV-10246 + connectSSL = if any (isPrefixOf "ssl") (forceEither $ Cf.options cf g) + then Just defaultSSLInfo else Nothing, connectUser = "", -- FIXME: Work aroung buggy mysql: unsafeUseAsCString creates garbage. connectOptions = [ ReadDefaultFile file, ReadDefaultGroup (pack $ g ++ "\0") ] -- cgit v1.2.3