aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2016-06-17 17:29:18 +0800
committerIgor Pashev <pashev.igor@gmail.com>2016-06-17 17:29:18 +0800
commit9fe740430fd459707f4fd8b0dd073a496326d48e (patch)
tree3e6c344595d3aa90b5c77e0ae4642d404f6c0682
parentb41849d9cb4ccb856905a26bfc36b6ac7c5b1f32 (diff)
downloadmywatch-9fe740430fd459707f4fd8b0dd073a496326d48e.tar.gz
Work around MariaDB's libmysqlclient
See https://jira.mariadb.org/browse/MDEV-10246
-rw-r--r--src/Main.hs11
1 files 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") ]