diff --git a/htest/Test/Ganeti/Confd/Utils.hs b/htest/Test/Ganeti/Confd/Utils.hs index 38b9dc37bf9043742f4980d314a41a2e8b341453..8c1590e01bba3c5fcc92508ccfd0c91e240c00be 100644 --- a/htest/Test/Ganeti/Confd/Utils.hs +++ b/htest/Test/Ganeti/Confd/Utils.hs @@ -59,8 +59,8 @@ prop_req_sign key (NonNegative timestamp) (Positive bad_delta) good_timestamp = timestamp + if pm then good_delta else (-good_delta) bad_delta' = fromIntegral C.confdMaxClockSkew + bad_delta bad_timestamp = timestamp + if pm then bad_delta' else (-bad_delta') - ts_ok = Confd.Utils.parseMessage key signed good_timestamp - ts_bad = Confd.Utils.parseMessage key signed bad_timestamp + ts_ok = Confd.Utils.parseRequest key signed good_timestamp + ts_bad = Confd.Utils.parseRequest key signed bad_timestamp in printTestCase "Failed to parse good message" (ts_ok ==? BasicTypes.Ok (encoded, crq)) .&&. printTestCase ("Managed to deserialise message with bad\ diff --git a/htools/Ganeti/Confd/Server.hs b/htools/Ganeti/Confd/Server.hs index 4ca0014c71418a8754beb5cafa1bf996a59181db..a7e52a17a07a29332f7aa34e714a32367ae14b36 100644 --- a/htools/Ganeti/Confd/Server.hs +++ b/htools/Ganeti/Confd/Server.hs @@ -459,7 +459,7 @@ onInotify inotify path cref mstate _ = responder :: CRef -> S.Socket -> HashKey -> String -> S.SockAddr -> IO () responder cfgref socket hmac msg peer = do ctime <- getCurrentTime - case parseMessage hmac msg ctime of + case parseRequest hmac msg ctime of Ok (origmsg, rq) -> do logDebug $ "Processing request: " ++ rStripSpace origmsg mcfg <- readIORef cfgref diff --git a/htools/Ganeti/Confd/Utils.hs b/htools/Ganeti/Confd/Utils.hs index 28fba06535e114054bed86f1c6ee3eee2a20479b..d19c9cfd6692a4da3431a2396496f1169900042c 100644 --- a/htools/Ganeti/Confd/Utils.hs +++ b/htools/Ganeti/Confd/Utils.hs @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA module Ganeti.Confd.Utils ( getClusterHmac , parseSignedMessage - , parseMessage + , parseRequest , signMessage , getCurrentTime ) where @@ -67,9 +67,9 @@ parseSignedMessage key str = do -- | Message parsing. This can either result in a good, valid message, -- or fail in the Result monad. -parseMessage :: HashKey -> String -> Integer +parseRequest :: HashKey -> String -> Integer -> Result (String, ConfdRequest) -parseMessage hmac msg curtime = do +parseRequest hmac msg curtime = do (salt, origmsg, request) <- parseSignedMessage hmac msg ts <- tryRead "Parsing timestamp" salt::Result Integer if abs (ts - curtime) > maxClockSkew