From 239581c75901c3305eaa9298cf41de28a57bd099 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 22 Nov 2014 20:17:46 -0400 Subject: reorg --- propellor.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'propellor.cabal') diff --git a/propellor.cabal b/propellor.cabal index 9fe7a26f..20aba22e 100644 --- a/propellor.cabal +++ b/propellor.cabal @@ -121,7 +121,7 @@ Library Other-Modules: Propellor.Git Propellor.Gpg - Propellor.Server + Propellor.Spin Propellor.Ssh Propellor.PrivData.Paths Propellor.Protocol -- cgit v1.2.3 From 5fefb161c388f72fa598c238295ce1f051cc0029 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 22 Nov 2014 22:37:25 -0400 Subject: propellor spin --- propellor.cabal | 1 + src/Propellor/Property/Chroot.hs | 5 ++++- src/Propellor/Property/Chroot/Util.hs | 15 +++++++++++++++ src/Propellor/Property/Debootstrap.hs | 14 +++----------- 4 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 src/Propellor/Property/Chroot/Util.hs (limited to 'propellor.cabal') diff --git a/propellor.cabal b/propellor.cabal index 20aba22e..a09a80d1 100644 --- a/propellor.cabal +++ b/propellor.cabal @@ -126,6 +126,7 @@ Library Propellor.PrivData.Paths Propellor.Protocol Propellor.Shim + Propellor.Property.Chroot.Util Utility.Applicative Utility.Data Utility.Directory diff --git a/src/Propellor/Property/Chroot.hs b/src/Propellor/Property/Chroot.hs index f45e2fc1..3da8b0d6 100644 --- a/src/Propellor/Property/Chroot.hs +++ b/src/Propellor/Property/Chroot.hs @@ -11,6 +11,7 @@ module Propellor.Property.Chroot ( import Propellor import Propellor.Types.Chroot +import Propellor.Property.Chroot.Util import qualified Propellor.Property.Debootstrap as Debootstrap import qualified Propellor.Property.Systemd.Core as Systemd import qualified Propellor.Shim as Shim @@ -109,12 +110,14 @@ propellChroot c@(Chroot loc _ _ _) mkproc systemdonly = property (chrootDesc c " chainprovision shim = do parenthost <- asks hostName cmd <- liftIO $ toChain parenthost c systemdonly + pe <- liftIO standardPathEnv let p = mkproc [ shim , "--continue" , show cmd ] - liftIO $ withHandle StdoutHandle createProcessSuccess p + let p' = p { env = Just pe } + liftIO $ withHandle StdoutHandle createProcessSuccess p' processChainOutput toChain :: HostName -> Chroot -> Bool -> IO CmdLine diff --git a/src/Propellor/Property/Chroot/Util.hs b/src/Propellor/Property/Chroot/Util.hs new file mode 100644 index 00000000..feb71d01 --- /dev/null +++ b/src/Propellor/Property/Chroot/Util.hs @@ -0,0 +1,15 @@ +module Propellor.Property.Chroot.Util where + +import Utility.Env +import Control.Applicative + +-- When chrooting, it's useful to ensure that PATH has all the standard +-- directories in it. This adds those directories to whatever PATH is +-- already set. +standardPathEnv :: IO [(String, String)] +standardPathEnv = do + path <- getEnvDefault "PATH" "/bin" + addEntry "PATH" (path ++ std) + <$> getEnvironment + where + std = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/src/Propellor/Property/Debootstrap.hs b/src/Propellor/Property/Debootstrap.hs index 32e892bb..ab5bddf4 100644 --- a/src/Propellor/Property/Debootstrap.hs +++ b/src/Propellor/Property/Debootstrap.hs @@ -8,6 +8,7 @@ module Propellor.Property.Debootstrap ( import Propellor import qualified Propellor.Property.Apt as Apt +import Propellor.Property.Chroot.Util import Utility.Path import Utility.SafeCommand import Utility.FileMode @@ -78,7 +79,7 @@ built target system@(System _ arch) config = , Param target ] cmd <- fromMaybe "debootstrap" <$> programPath - de <- debootstrapEnv + de <- standardPathEnv ifM (boolSystemEnv cmd params (Just de)) ( do fixForeignDev target @@ -234,15 +235,6 @@ makeWrapperScript dir = do ] modifyFileMode wrapperScript (addModes $ readModes ++ executeModes) --- workaround for http://bugs.debian.org/770658 -debootstrapEnv :: IO [(String, String)] -debootstrapEnv = do - path <- getEnvDefault "PATH" "/bin" - addEntry "PATH" (path ++ debianPath) - <$> getEnvironment - where - debianPath = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" - -- Work around for http://bugs.debian.org/770217 makeDevicesTarball :: IO () makeDevicesTarball = do @@ -257,7 +249,7 @@ makeDevicesTarball = do fixForeignDev :: FilePath -> IO () fixForeignDev target = whenM (doesFileExist (target ++ foreignDevFlag)) $ do - de <- debootstrapEnv + de <- standardPathEnv void $ boolSystemEnv "chroot" [ File target , Param "sh" -- cgit v1.2.3 From 6aa21366d57679f82fbaf96a90f93d2d1ac7f223 Mon Sep 17 00:00:00 2001 From: Félix Sipma Date: Sun, 23 Nov 2014 18:33:26 +0100 Subject: Group properties Signed-off-by: Félix Sipma --- propellor.cabal | 1 + src/Propellor/Property/Group.hs | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 src/Propellor/Property/Group.hs (limited to 'propellor.cabal') diff --git a/propellor.cabal b/propellor.cabal index a09a80d1..cd34d4bf 100644 --- a/propellor.cabal +++ b/propellor.cabal @@ -83,6 +83,7 @@ Library Propellor.Property.Firewall Propellor.Property.Git Propellor.Property.Gpg + Propellor.Property.Group Propellor.Property.Grub Propellor.Property.Network Propellor.Property.Nginx diff --git a/src/Propellor/Property/Group.hs b/src/Propellor/Property/Group.hs new file mode 100644 index 00000000..f03510cf --- /dev/null +++ b/src/Propellor/Property/Group.hs @@ -0,0 +1,14 @@ +module Propellor.Property.Group where + +import Propellor + +type GID = Int + +exists :: GroupName -> Maybe GID -> Property +exists group' mgid = check test (cmdProperty "addgroup" $ args mgid) + `describe` unwords ["group", group'] + where + groupFile = "/etc/group" + test = not <$> elem group' <$> words <$> readProcess "cut" ["-d:", "-f1", groupFile] + args Nothing = [group'] + args (Just gid) = ["--gid", show gid, group'] -- cgit v1.2.3