From 7c55455944e94d2d88f1f5bebf940c3cba0c2417 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sun, 24 Jun 2018 13:48:24 +0000 Subject: update rValue of Dns TXT record type The TXT record's string is split into strings of length <= 255 characters and these strings are enclosed inside a pair of parentheses. Signed-off-by: rsiddharth --- src/Propellor/Property/Dns.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/Propellor') diff --git a/src/Propellor/Property/Dns.hs b/src/Propellor/Property/Dns.hs index d99a76b0..c89ce271 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,8 +322,15 @@ 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 $ [op] ++ [w] + ++ (intercalate "\n\t" $ + map (\x -> [q] ++ filter (/= q) x ++ [q]) $ + Split.chunksOf 255 s) + ++ [w] ++ [cp] where + op = '(' + cp = ')' + w = ' ' q = '"' rValue (PTR _) = Nothing -- cgit v1.2.3 From 30ce1535b66f402ff8316554000f1a3dc729c26f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 24 Jun 2018 11:32:46 -0400 Subject: refactor could use zoneFileString for other things eg SSHFP. I have not yet, because AFAICS, SSHFP already splits the key up in a different way and while using zoneFileString should be ok, I'd need to test it.. --- src/Propellor/Property/Dns.hs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/Propellor') diff --git a/src/Propellor/Property/Dns.hs b/src/Propellor/Property/Dns.hs index c89ce271..8e38a75e 100644 --- a/src/Propellor/Property/Dns.hs +++ b/src/Propellor/Property/Dns.hs @@ -322,17 +322,32 @@ rValue (SSHFP x y s) = Just $ unwords , s ] rValue (INCLUDE f) = Just f -rValue (TXT s) = Just $ [op] ++ [w] - ++ (intercalate "\n\t" $ +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] + , [w, cp] + ] where op = '(' cp = ')' w = ' ' q = '"' -rValue (PTR _) = Nothing -- | Adjusts the serial number of the zone to always be larger -- than the serial number in the Zone record, -- cgit v1.2.3