summaryrefslogtreecommitdiff
path: root/src/Propellor
diff options
context:
space:
mode:
authorJoey Hess2018-07-11 12:12:57 -0400
committerJoey Hess2018-07-11 12:12:57 -0400
commit45350d2905e362bfbeacf8e625ee2f37c1710b0d (patch)
tree2bdbbaa47d91b56df56a8909a49c2741d05e1f2b /src/Propellor
parent58a7ba614753e5462b08ef91dd2663e70cd7742c (diff)
parentece3849c9df1acc48a40c9d3d2e627fb9f33a8e0 (diff)
Merge branch 'master' into joeyconfig
Diffstat (limited to 'src/Propellor')
-rw-r--r--src/Propellor/Property/Dns.hs25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/Propellor/Property/Dns.hs b/src/Propellor/Property/Dns.hs
index d99a76b0..8e38a75e 100644
--- a/src/Propellor/Property/Dns.hs
+++ b/src/Propellor/Property/Dns.hs
@@ -26,6 +26,7 @@ import Utility.Applicative
import qualified Data.Map as M
import qualified Data.Set as S
+import qualified Data.List.Split as Split (chunksOf)
import Data.List
-- | Primary dns server for a domain, using bind.
@@ -321,11 +322,33 @@ rValue (SSHFP x y s) = Just $ unwords
, s
]
rValue (INCLUDE f) = Just f
-rValue (TXT s) = Just $ [q] ++ filter (/= q) s ++ [q]
+rValue (TXT s) = Just $ zoneFileString s
where
+ op = '('
+ cp = ')'
+ w = ' '
q = '"'
rValue (PTR _) = Nothing
+-- Bind has a limit on the length of a string in its zone file,
+-- but a string can be split into sections that are glued together
+-- inside parens to configure a longer value.
+--
+-- This adds quotes around each substring.
+zoneFileString :: String -> String
+zoneFileString s = concat
+ [ [op, w]
+ , (intercalate "\n\t" $
+ map (\x -> [q] ++ filter (/= q) x ++ [q]) $
+ Split.chunksOf 255 s)
+ , [w, cp]
+ ]
+ where
+ op = '('
+ cp = ')'
+ w = ' '
+ q = '"'
+
-- | Adjusts the serial number of the zone to always be larger
-- than the serial number in the Zone record,
-- and always be larger than the passed SerialNumber.