Make propellor resistent to changes to shared libraries, such as libffi

* Make propellor resistent to changes to shared libraries, such as libffi,
  which might render the propellor binary unable to run. This is dealt with
  by checking the binary both when running propellor on a remote host,
  and by Cron.runPropellor. If the binary doesn't work, it will be rebuilt.
* Note that since a new switch had to be added to allow testing the binary,
  upgrading to this version will cause a rebuild from scratch of propellor.
This commit is contained in:
Joey Hess 2015-04-02 10:20:44 -04:00
parent 015b249c66
commit 86783dc52d
6 changed files with 38 additions and 6 deletions

11
debian/changelog vendored
View File

@ -1,3 +1,14 @@
propellor (2.2.2) UNRELEASED; urgency=medium
* Make propellor resistent to changes to shared libraries, such as libffi,
which might render the propellor binary unable to run. This is dealt with
by checking the binary both when running propellor on a remote host,
and by Cron.runPropellor. If the binary doesn't work, it will be rebuilt.
* Note that since a new switch had to be added to allow testing the binary,
upgrading to this version will cause a rebuild from scratch of propellor.
-- Joey Hess <id@joeyh.name> Thu, 02 Apr 2015 10:09:46 -0400
propellor (2.2.1) unstable; urgency=medium
* userScriptProperty now passes --shell /bin/sh, so it can be used

View File

@ -95,6 +95,10 @@ and configured in haskell.
(This will result in a trapezoid pattern in gitk.)
* propellor --check
If propellor is able to run, this simply exists successfully.
* propellor hostname
When run with a hostname and no other options, propellor will

View File

@ -1,5 +1,6 @@
module Propellor.Bootstrap (
bootstrapPropellorCommand,
checkBinaryCommand,
installGitCommand,
buildPropellor,
) where
@ -12,14 +13,24 @@ import Data.List
type ShellCommand = String
-- Shell command line to build propellor, used when bootstrapping on a new
-- host. Should be run inside the propellor config dir, and will install
-- all necessary build dependencies.
-- Shell command line to ensure propellor is bootstrapped and ready to run.
-- Should be run inside the propellor config dir, and will install
-- all necessary build dependencies and build propellor.
bootstrapPropellorCommand :: ShellCommand
bootstrapPropellorCommand = "if ! test -x ./propellor; then " ++ go ++ "; fi"
bootstrapPropellorCommand = "if ! test -x ./propellor; then " ++ go ++ "; fi;" ++ checkBinaryCommand
where
go = intercalate " && "
[ depsCommand
, buildCommand
]
-- Use propellor --check to detect if the local propellor binary has
-- stopped working (eg due to library changes), and must be rebuilt.
checkBinaryCommand :: ShellCommand
checkBinaryCommand = "if test -x ./propellor && ! ./propellor --check; then " ++ go ++ "; fi"
where
go = intercalate " && "
[ depsCommand
[ "cabal clean"
, buildCommand
]

View File

@ -33,6 +33,7 @@ usage h = hPutStrLn h $ unlines
, " propellor --list-fields"
, " propellor --merge"
, " propellor --build"
, " propellor --check"
]
usageError :: [String] -> IO a
@ -43,6 +44,7 @@ usageError ps = do
processCmdLine :: IO CmdLine
processCmdLine = go =<< getArgs
where
go ("--check":_) = return Check
go ("--spin":ps) = case reverse ps of
(r:"--via":hs) -> Spin
<$> mapM hostname (reverse hs)
@ -91,6 +93,7 @@ defaultMain hostlist = do
where
go _ (Serialized cmdline) = go True cmdline
go _ (Continue cmdline) = go False cmdline
go _ Check = return ()
go _ (Set field context) = setPrivData field context
go _ (Dump field context) = dumpPrivData field context
go _ (Edit field context) = editPrivData field context

View File

@ -3,6 +3,7 @@ module Propellor.Property.Cron where
import Propellor
import qualified Propellor.Property.File as File
import qualified Propellor.Property.Apt as Apt
import Propellor.Bootstrap
import Utility.SafeCommand
import Utility.FileMode
@ -81,4 +82,5 @@ niceJob desc times user cddir command = job desc times user cddir
-- | Installs a cron job to run propellor.
runPropellor :: Times -> Property NoInfo
runPropellor times = niceJob "propellor" times "root" localdir "./propellor"
runPropellor times = niceJob "propellor" times "root" localdir
(bootstrapPropellorCommand ++ "; ./propellor")

View File

@ -23,5 +23,6 @@ data CmdLine
| DockerChain HostName String
| ChrootChain HostName FilePath Bool Bool
| GitPush Fd Fd
| Check
deriving (Read, Show, Eq)