From 433bf00a55e1fd7402a410793ba68976a775fac7 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 30 May 2015 13:58:00 -0400 Subject: --spin now works when given a short hostname that only resolves to an ipv6 address. --- src/Propellor/Spin.hs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/Propellor/Spin.hs') diff --git a/src/Propellor/Spin.hs b/src/Propellor/Spin.hs index 986305d7..3ff1ec21 100644 --- a/src/Propellor/Spin.hs +++ b/src/Propellor/Spin.hs @@ -14,8 +14,7 @@ import System.Posix.Directory import Control.Concurrent.Async import qualified Data.ByteString as B import qualified Data.Set as S -import qualified Network.BSD as BSD -import Network.Socket (inet_ntoa) +import Network.Socket (getAddrInfo, defaultHints, AddrInfo(..), AddrInfoFlag(..), SockAddr) import Propellor import Propellor.Protocol @@ -98,17 +97,21 @@ spin target relay hst = do getSshTarget :: HostName -> Host -> IO String getSshTarget target hst | null configips = return target - | otherwise = go =<< tryIO (BSD.getHostByName target) + | otherwise = go =<< tryIO (dnslookup target) where go (Left e) = useip (show e) - go (Right hostentry) = ifM (anyM matchingconfig (BSD.hostAddresses hostentry)) - ( return target - , do - ips <- mapM inet_ntoa (BSD.hostAddresses hostentry) - useip ("DNS " ++ show ips ++ " vs configured " ++ show configips) - ) + go (Right addrinfos) = do + configaddrinfos <- catMaybes <$> mapM iptoaddr configips + if any (`elem` configaddrinfos) (map addrAddress addrinfos) + then return target + else useip ("DNS lookup did not return any of the expected addresses " ++ show configips) - matchingconfig a = flip elem configips <$> inet_ntoa a + dnslookup h = getAddrInfo (Just $ defaultHints { addrFlags = [AI_CANONNAME] }) (Just h) Nothing + + -- Convert a string containing an IP address into a SockAddr. + iptoaddr :: String -> IO (Maybe SockAddr) + iptoaddr ip = catchDefaultIO Nothing $ headMaybe . map addrAddress + <$> getAddrInfo (Just $ defaultHints { addrFlags = [AI_NUMERICHOST] }) (Just ip) Nothing useip why = case headMaybe configips of Nothing -> return target -- cgit v1.2.3 From 536d9fec70eb3343e51200915555ac651a57f3f4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 30 May 2015 14:02:25 -0400 Subject: propellor spin --- src/Propellor/Spin.hs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/Propellor/Spin.hs') diff --git a/src/Propellor/Spin.hs b/src/Propellor/Spin.hs index 3ff1ec21..9685a486 100644 --- a/src/Propellor/Spin.hs +++ b/src/Propellor/Spin.hs @@ -102,6 +102,7 @@ getSshTarget target hst go (Left e) = useip (show e) go (Right addrinfos) = do configaddrinfos <- catMaybes <$> mapM iptoaddr configips + print (configips, configaddrinfos, map addrAddress addrinfos) if any (`elem` configaddrinfos) (map addrAddress addrinfos) then return target else useip ("DNS lookup did not return any of the expected addresses " ++ show configips) -- cgit v1.2.3 From 7b8b77936096e9a081494bce2756b9793d98a345 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 30 May 2015 14:03:23 -0400 Subject: revert test --- config-joey.hs | 2 +- src/Propellor/Spin.hs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'src/Propellor/Spin.hs') diff --git a/config-joey.hs b/config-joey.hs index 0219c5f2..73c9687b 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -145,7 +145,7 @@ orca = standardSystem "orca.kitenet.net" Unstable "amd64" honeybee :: Host honeybee = standardSystem "honeybee.kitenet.net" Testing "armhf" [ "Arm git-annex build box." ] - & ipv6 "2001:4830:1600:187::3" + & ipv6 "2001:4830:1600:187::2" -- No unattended upgrades as there is currently no console access. -- (Also, system is not currently running a stock kernel, diff --git a/src/Propellor/Spin.hs b/src/Propellor/Spin.hs index 9685a486..3ff1ec21 100644 --- a/src/Propellor/Spin.hs +++ b/src/Propellor/Spin.hs @@ -102,7 +102,6 @@ getSshTarget target hst go (Left e) = useip (show e) go (Right addrinfos) = do configaddrinfos <- catMaybes <$> mapM iptoaddr configips - print (configips, configaddrinfos, map addrAddress addrinfos) if any (`elem` configaddrinfos) (map addrAddress addrinfos) then return target else useip ("DNS lookup did not return any of the expected addresses " ++ show configips) -- cgit v1.2.3 From f387bbcf2d7417cf9389eff92d12f28af26cce3e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 30 Jul 2015 12:01:15 -0400 Subject: Work around broken git pull option parser in git 2.5.0, which broke use of --upload-pack to send a git push when running propellor --spin. --- debian/changelog | 3 +++ src/Propellor/Spin.hs | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/Propellor/Spin.hs') diff --git a/debian/changelog b/debian/changelog index f4fcf35c..2375dfd5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,9 @@ propellor (2.7.0) UNRELEASED; urgency=medium * Added onChangeFlagOnFail which is often a safer alternative to onChange. Thanks, Antoine Eiche. + * Work around broken git pull option parser in git 2.5.0, + which broke use of --upload-pack to send a git push when running + propellor --spin. -- Joey Hess Mon, 20 Jul 2015 12:01:38 -0400 diff --git a/src/Propellor/Spin.hs b/src/Propellor/Spin.hs index 3ff1ec21..61d519c3 100644 --- a/src/Propellor/Spin.hs +++ b/src/Propellor/Spin.hs @@ -147,11 +147,15 @@ update forhost = do hout <- dup stdOutput hClose stdin hClose stdout + -- Not using git pull because git 2.5.0 badly + -- broke its option parser. unlessM (boolSystem "git" (pullparams hin hout)) $ - errorMessage "git pull from client failed" + errorMessage "git fetch from client failed" + unlessM (boolSystem "git" [Param "merge", Param "FETCH_HEAD"]) $ + errorMessage "git merge from client failed" where pullparams hin hout = - [ Param "pull" + [ Param "fetch" , Param "--progress" , Param "--upload-pack" , Param $ "./propellor --gitpush " ++ show hin ++ " " ++ show hout -- cgit v1.2.3