From bfe8375d46e78bc6dd796ba1d0bdce577dbd123c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 31 Dec 2015 12:40:42 -0400 Subject: actually parse service lines So whitespace etc changes don't matter --- src/Propellor/Property/Postfix.hs | 17 ++++++++++------- src/Propellor/Property/SiteSpecific/JoeySites.hs | 3 ++- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/Propellor/Property/Postfix.hs b/src/Propellor/Property/Postfix.hs index b6a1d170..df244061 100644 --- a/src/Propellor/Property/Postfix.hs +++ b/src/Propellor/Property/Postfix.hs @@ -139,14 +139,14 @@ data Service = Service , serviceCommand :: String , serviceOpts :: ServiceOpts } - deriving (Show) + deriving (Show, Eq) data ServiceType = InetService (Maybe HostName) ServicePort | UnixService FilePath PrivateService | FifoService FilePath PrivateService | PassService FilePath PrivateService - deriving (Show) + deriving (Show, Eq) -- Can be a port number or service name such as "smtp". type ServicePort = String @@ -160,7 +160,7 @@ data ServiceOpts = ServiceOpts , serviceWakeupTime :: Maybe Int , serviceProcessLimit :: Maybe Int } - deriving (Show) + deriving (Show, Eq) defServiceOpts :: ServiceOpts defServiceOpts = ServiceOpts @@ -254,13 +254,16 @@ parseServiceLine l = Service -- | Enables a `Service` in postfix's `masterCfFile`. service :: Service -> RevertableProperty NoInfo service s = (enable disable) - `describe` ("enabled postfix service " ++ show (serviceType s)) + `describe` desc where - enable = masterCfFile `File.containsLine` l + desc = "enabled postfix service " ++ show (serviceType s) + enable = masterCfFile `File.containsLine` (formatServiceLine s) `onChange` reloaded - disable = masterCfFile `File.lacksLine` l + disable = File.fileProperty desc (filter (not . matches)) masterCfFile `onChange` reloaded - l = formatServiceLine s + matches l = case parseServiceLine l of + Just s' | s' == s -> True + _ -> False -- | Installs saslauthd and configures it for postfix, authenticating -- against PAM. diff --git a/src/Propellor/Property/SiteSpecific/JoeySites.hs b/src/Propellor/Property/SiteSpecific/JoeySites.hs index 987b4187..f140404d 100644 --- a/src/Propellor/Property/SiteSpecific/JoeySites.hs +++ b/src/Propellor/Property/SiteSpecific/JoeySites.hs @@ -709,7 +709,8 @@ kiteMailServer = propertyList "kitenet.net mail server" $ props -- verification via tls cert. postfixClientRelay :: Context -> Property HasInfo postfixClientRelay ctx = Postfix.mainCfFile `File.containsLines` - [ "relayhost = kitenet.net" + -- Using smtps not smtp because more networks firewall smtp + [ "relayhost = kitenet.net:smtps" , "smtp_tls_CAfile = /etc/ssl/certs/joeyca.pem" , "smtp_tls_cert_file = /etc/ssl/certs/postfix.pem" , "smtp_tls_key_file = /etc/ssl/private/postfix.pem" -- cgit v1.2.3