From 0e452bb50b4718829b904af4ee26c8a4d77abea1 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 16 Jun 2016 21:17:21 +0900 Subject: applyToList combinator I think Joey wrote this at some point .. though it's possible I did --- src/Propellor/Property.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Propellor/Property.hs b/src/Propellor/Property.hs index af36ed58..3fff9e04 100644 --- a/src/Propellor/Property.hs +++ b/src/Propellor/Property.hs @@ -16,6 +16,7 @@ module Propellor.Property ( , check , fallback , revert + , applyToList -- * Property descriptions , describe , (==>) @@ -341,6 +342,14 @@ unsupportedOS' = go =<< getOS revert :: RevertableProperty setup undo -> RevertableProperty undo setup revert (RevertableProperty p1 p2) = RevertableProperty p2 p1 +-- | Apply a property to each element of a list. +applyToList + :: (Foldable t, Functor t, IsProp p, Combines p p, p ~ CombinedType p p) + => (b -> p) + -> t b + -> p +prop `applyToList` xs = foldr1 before $ prop <$> xs + makeChange :: IO () -> Propellor Result makeChange a = liftIO a >> return MadeChange -- cgit v1.2.3 From eaa4bf7b3f1636e4b9010b7131e680dd556cad95 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 16 Jun 2016 21:17:47 +0900 Subject: add Propellor.Property.Firejail --- src/Propellor/Property/Firejail.hs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/Propellor/Property/Firejail.hs diff --git a/src/Propellor/Property/Firejail.hs b/src/Propellor/Property/Firejail.hs new file mode 100644 index 00000000..98f7ab78 --- /dev/null +++ b/src/Propellor/Property/Firejail.hs @@ -0,0 +1,29 @@ +-- | Maintainer: Sean Whitton + +module Propellor.Property.Firejail ( + installed, + jailed, +) where + +import Propellor.Base +import qualified Propellor.Property.Apt as Apt +import qualified Propellor.Property.File as File + +-- | Ensures that Firejail is installed +installed :: Property DebianLike +installed = Apt.installed ["firejail"] + +-- | For each program name passed, create symlinks in @/usr/local/bin@ that +-- will launch that program in a Firejail sandbox. +-- +-- The profile for the sandbox will be the same as if the user had run +-- @firejail@ directly without passing @--profile@ (see "SECURITY PROFILES" in +-- firejail(1)). +-- +-- See "DESKTOP INTEGRATION" in firejail(1). +jailed :: [String] -> Property DebianLike +jailed ps = (jailed' `applyToList` ps) `requires` installed + +jailed' :: String -> Property UnixLike +jailed' p = ("/usr/local/bin" p) + `File.isSymlinkedTo` File.LinkTarget "/usr/bin/firejail" -- cgit v1.2.3 From c1b209031a5a584417fc72edf8e77ff0c21f5a88 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 19 Jun 2016 19:53:55 +0900 Subject: describe Firejail.jailed --- src/Propellor/Property/Firejail.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Propellor/Property/Firejail.hs b/src/Propellor/Property/Firejail.hs index 98f7ab78..2aa6cf3a 100644 --- a/src/Propellor/Property/Firejail.hs +++ b/src/Propellor/Property/Firejail.hs @@ -22,7 +22,9 @@ installed = Apt.installed ["firejail"] -- -- See "DESKTOP INTEGRATION" in firejail(1). jailed :: [String] -> Property DebianLike -jailed ps = (jailed' `applyToList` ps) `requires` installed +jailed ps = (jailed' `applyToList` ps) + `requires` installed + `describe` unwords ("firejail jailed":ps) jailed' :: String -> Property UnixLike jailed' p = ("/usr/local/bin" p) -- cgit v1.2.3 From 5e06e4d7f2e1442285060ba820df418f3508a449 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 19 Jun 2016 19:54:27 +0900 Subject: fix build on old GHC by importing Data.Foldable --- src/Propellor/Property.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Propellor/Property.hs b/src/Propellor/Property.hs index 3fff9e04..c68dc882 100644 --- a/src/Propellor/Property.hs +++ b/src/Propellor/Property.hs @@ -54,6 +54,7 @@ import System.Posix.Files import qualified Data.Hash.MD5 as MD5 import Data.List import Control.Applicative +import Data.Foldable hiding (elem) import Prelude import Propellor.Types -- cgit v1.2.3 From 9482099c688dbc90b60d0f12cb55a5705e5e74d5 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 19 Jun 2016 20:02:49 +0900 Subject: clean build on GHC 7.10 --- src/Propellor/Property.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Propellor/Property.hs b/src/Propellor/Property.hs index c68dc882..fe314941 100644 --- a/src/Propellor/Property.hs +++ b/src/Propellor/Property.hs @@ -54,8 +54,8 @@ import System.Posix.Files import qualified Data.Hash.MD5 as MD5 import Data.List import Control.Applicative -import Data.Foldable hiding (elem) -import Prelude +import Data.Foldable (Foldable, foldr1) +import Prelude hiding (Foldable) import Propellor.Types import Propellor.Types.Core @@ -349,7 +349,7 @@ applyToList => (b -> p) -> t b -> p -prop `applyToList` xs = foldr1 before $ prop <$> xs +prop `applyToList` xs = Data.Foldable.foldr1 before $ prop <$> xs makeChange :: IO () -> Propellor Result makeChange a = liftIO a >> return MadeChange -- cgit v1.2.3 From 0e09a8cfdffb2cd99cf86c04bade4a9261101a2c Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 19 Jun 2016 20:06:47 +0900 Subject: haddock tweak Slashes inside @monospace@ get misinterpreted. --- src/Propellor/Property/Firejail.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Propellor/Property/Firejail.hs b/src/Propellor/Property/Firejail.hs index 2aa6cf3a..b7841e07 100644 --- a/src/Propellor/Property/Firejail.hs +++ b/src/Propellor/Property/Firejail.hs @@ -13,7 +13,7 @@ import qualified Propellor.Property.File as File installed :: Property DebianLike installed = Apt.installed ["firejail"] --- | For each program name passed, create symlinks in @/usr/local/bin@ that +-- | For each program name passed, create symlinks in /usr/local/bin that -- will launch that program in a Firejail sandbox. -- -- The profile for the sandbox will be the same as if the user had run -- cgit v1.2.3